mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:47:35 +00:00
LibWeb/HTML: Port Window.fetch() to IDL
This commit is contained in:
parent
a2fb3a1653
commit
5cc6b1c4db
12 changed files with 22 additions and 389 deletions
|
@ -21,7 +21,6 @@
|
|||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Bindings/CSSNamespace.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/FetchMethod.h>
|
||||
#include <LibWeb/Bindings/Replaceable.h>
|
||||
#include <LibWeb/Bindings/WindowExposedInterfaces.h>
|
||||
#include <LibWeb/Bindings/WindowPrototype.h>
|
||||
|
@ -896,8 +895,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
|||
|
||||
define_native_function(realm, "structuredClone", structured_clone, 1, attr);
|
||||
|
||||
define_native_function(realm, "fetch", Bindings::fetch, 1, attr);
|
||||
|
||||
define_direct_property("CSS", MUST_OR_THROW_OOM(heap().allocate<Bindings::CSSNamespace>(realm, realm)), 0);
|
||||
|
||||
define_native_accessor(realm, "localStorage", local_storage_getter, {}, attr);
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
|
||||
using WindowOrWorkerGlobalScopeMixin::atob;
|
||||
using WindowOrWorkerGlobalScopeMixin::btoa;
|
||||
using WindowOrWorkerGlobalScopeMixin::fetch;
|
||||
|
||||
// ^DOM::EventTarget
|
||||
virtual bool dispatch_event(DOM::Event&) override;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Utf8View.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibTextCodec/Decoder.h>
|
||||
#include <LibWeb/Fetch/FetchMethod.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
|
||||
#include <LibWeb/Infra/Base64.h>
|
||||
|
@ -83,4 +84,10 @@ WebIDL::ExceptionOr<String> WindowOrWorkerGlobalScopeMixin::atob(String const& d
|
|||
return TRY_OR_THROW_OOM(vm, decoder->to_utf8(decoded_data.value()));
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<JS::Promise> WindowOrWorkerGlobalScopeMixin::fetch(Fetch::RequestInfo const& input, Fetch::RequestInit const& init) const
|
||||
{
|
||||
auto& vm = this_impl().vm();
|
||||
return Fetch::fetch(vm, input, init);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/Forward.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Fetch/Request.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -26,6 +27,7 @@ public:
|
|||
bool cross_origin_isolated() const;
|
||||
WebIDL::ExceptionOr<String> btoa(String const& data) const;
|
||||
WebIDL::ExceptionOr<String> atob(String const& data) const;
|
||||
JS::NonnullGCPtr<JS::Promise> fetch(Fetch::RequestInfo const&, Fetch::RequestInit const&) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#import <Fetch/Request.idl>
|
||||
#import <Fetch/Response.idl>
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
|
||||
interface mixin WindowOrWorkerGlobalScope {
|
||||
[Replaceable] readonly attribute USVString origin;
|
||||
|
@ -25,4 +28,7 @@ interface mixin WindowOrWorkerGlobalScope {
|
|||
|
||||
// structured cloning
|
||||
// FIXME: any structuredClone(any value, optional StructuredSerializeOptions options = {});
|
||||
|
||||
// https://fetch.spec.whatwg.org/#fetch-method
|
||||
[NewObject] Promise<Response> fetch(RequestInfo input, optional RequestInit init = {});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue