1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 19:15:09 +00:00

LibWeb: Clarify WebIDL::Promise as an alias for JS::PromiseCapability

This patch adds the WebIDL::Promise type explicitly defined in the
WebIDL spec to be a PromiseCapability Record from ecma262.
This commit is contained in:
networkException 2023-02-13 11:58:39 +01:00 committed by Linus Groh
parent 863afbaf38
commit f1dd4f42bc
6 changed files with 38 additions and 32 deletions

View file

@ -151,13 +151,13 @@ JS::NonnullGCPtr<JS::Promise> fetch_impl(JS::VM& vm, RequestInfo const& input, R
}
// https://fetch.spec.whatwg.org/#abort-fetch
void abort_fetch(JS::VM& vm, JS::PromiseCapability const& promise_capability, JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Response> response_object, JS::Value error)
void abort_fetch(JS::VM& vm, WebIDL::Promise const& promise, JS::NonnullGCPtr<Infrastructure::Request> request, JS::GCPtr<Response> response_object, JS::Value error)
{
dbgln_if(WEB_FETCH_DEBUG, "Fetch: Aborting fetch with: request @ {}, error = {}", request.ptr(), error);
// 1. Reject promise with error.
// NOTE: This is a no-op if promise has already fulfilled.
WebIDL::reject_promise(vm, promise_capability, error);
WebIDL::reject_promise(vm, promise, error);
// 2. If requests body is non-null and is readable, then cancel requests body with error.
if (auto* body = request->body().get_pointer<Infrastructure::Body>(); body != nullptr && body->stream()->is_readable()) {