mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +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:
parent
863afbaf38
commit
f1dd4f42bc
6 changed files with 38 additions and 32 deletions
|
@ -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 request’s body is non-null and is readable, then cancel request’s body with error.
|
||||
if (auto* body = request->body().get_pointer<Infrastructure::Body>(); body != nullptr && body->stream()->is_readable()) {
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibWeb/Fetch/Request.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
namespace Web::Fetch {
|
||||
|
||||
JS::NonnullGCPtr<JS::Promise> fetch_impl(JS::VM&, RequestInfo const& input, RequestInit const& init = {});
|
||||
void abort_fetch(JS::VM&, JS::PromiseCapability const&, JS::NonnullGCPtr<Infrastructure::Request>, JS::GCPtr<Response>, JS::Value error);
|
||||
void abort_fetch(JS::VM&, WebIDL::Promise const&, JS::NonnullGCPtr<Infrastructure::Request>, JS::GCPtr<Response>, JS::Value error);
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ WebIDL::ExceptionOr<Body> Body::clone() const
|
|||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#fully-reading-body-as-promise
|
||||
JS::NonnullGCPtr<JS::PromiseCapability> Body::fully_read_as_promise() const
|
||||
JS::NonnullGCPtr<WebIDL::Promise> Body::fully_read_as_promise() const
|
||||
{
|
||||
auto& vm = Bindings::main_thread_vm();
|
||||
auto& realm = *vm.current_realm();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/FileAPI/Blob.h>
|
||||
#include <LibWeb/Streams/ReadableStream.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
namespace Web::Fetch::Infrastructure {
|
||||
|
||||
|
@ -32,7 +33,7 @@ public:
|
|||
|
||||
[[nodiscard]] WebIDL::ExceptionOr<Body> clone() const;
|
||||
|
||||
[[nodiscard]] JS::NonnullGCPtr<JS::PromiseCapability> fully_read_as_promise() const;
|
||||
[[nodiscard]] JS::NonnullGCPtr<WebIDL::Promise> fully_read_as_promise() const;
|
||||
|
||||
private:
|
||||
// https://fetch.spec.whatwg.org/#concept-body-stream
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue