diff --git a/Tests/LibWeb/Text/expected/HTML/shadow-realm-btoa.txt b/Tests/LibWeb/Text/expected/HTML/shadow-realm-btoa.txt
new file mode 100644
index 00000000000..07cab40d3e3
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/shadow-realm-btoa.txt
@@ -0,0 +1 @@
+Shadow realm evaluation returned: SGVsbG8sIHdvcmxkIQ==
diff --git a/Tests/LibWeb/Text/expected/HTML/shadow-realm-url.txt b/Tests/LibWeb/Text/expected/HTML/shadow-realm-url.txt
new file mode 100644
index 00000000000..a5fdec52c41
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/HTML/shadow-realm-url.txt
@@ -0,0 +1 @@
+Shadow realm evaluation returned: example.com
diff --git a/Tests/LibWeb/Text/input/HTML/shadow-realm-btoa.html b/Tests/LibWeb/Text/input/HTML/shadow-realm-btoa.html
new file mode 100644
index 00000000000..0d7375c746b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/shadow-realm-btoa.html
@@ -0,0 +1,8 @@
+
+
diff --git a/Tests/LibWeb/Text/input/HTML/shadow-realm-url.html b/Tests/LibWeb/Text/input/HTML/shadow-realm-url.html
new file mode 100644
index 00000000000..3db5b42ab33
--- /dev/null
+++ b/Tests/LibWeb/Text/input/HTML/shadow-realm-url.html
@@ -0,0 +1,8 @@
+
+
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index 62308100330..dca642f4ef2 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -483,6 +483,7 @@ set(SOURCES
HTML/TokenizedFeatures.cpp
HTML/TrackEvent.cpp
HTML/TraversableNavigable.cpp
+ HTML/UniversalGlobalScope.cpp
HTML/UserActivation.cpp
HTML/VideoTrack.cpp
HTML/VideoTrackList.cpp
diff --git a/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp
index 8101549de33..85ba85fdeaf 100644
--- a/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp
+++ b/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp
@@ -26,14 +26,16 @@ JS::NonnullGCPtr ShadowRealmGlobalScope::create(JS::Real
void ShadowRealmGlobalScope::initialize(JS::Realm&)
{
- // FIXME: This does not work as we do not have any intrinsics in the [HostDefined] of a shadow realm. Figure out how this _should_ work.
- // Base::initialize(realm);
- // WEB_SET_PROTOTYPE_FOR_INTERFACE(ShadowRealmGlobalScope);
}
void ShadowRealmGlobalScope::initialize_web_interfaces()
{
+ auto& realm = this->realm();
+
+ WEB_SET_PROTOTYPE_FOR_INTERFACE(ShadowRealmGlobalScope);
+
add_shadow_realm_exposed_interfaces(*this);
+ Bindings::ShadowRealmGlobalScopeGlobalMixin::initialize(realm, *this);
}
void ShadowRealmGlobalScope::visit_edges(Cell::Visitor& visitor)
diff --git a/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.h b/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.h
index c01485369b1..c18f1fc8d03 100644
--- a/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.h
+++ b/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.h
@@ -7,12 +7,17 @@
#pragma once
#include
+#include
#include
+#include
namespace Web::HTML {
// https://whatpr.org/html/9893/webappapis.html#shadowrealmglobalscope
-class ShadowRealmGlobalScope : public DOM::EventTarget {
+class ShadowRealmGlobalScope
+ : public DOM::EventTarget
+ , public UniversalGlobalScopeMixin
+ , public Bindings::ShadowRealmGlobalScopeGlobalMixin {
WEB_PLATFORM_OBJECT(ShadowRealmGlobalScope, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(ShadowRealmGlobalScope);
@@ -21,6 +26,9 @@ public:
static JS::NonnullGCPtr create(JS::Realm&);
+ virtual Bindings::PlatformObject& this_impl() override { return *this; }
+ virtual Bindings::PlatformObject const& this_impl() const override { return *this; }
+
// https://whatpr.org/html/9893/webappapis.html#dom-shadowrealmglobalscope-self
JS::NonnullGCPtr self()
{
@@ -28,6 +36,11 @@ public:
return *this;
}
+ using UniversalGlobalScopeMixin::atob;
+ using UniversalGlobalScopeMixin::btoa;
+ using UniversalGlobalScopeMixin::queue_microtask;
+ using UniversalGlobalScopeMixin::structured_clone;
+
void initialize_web_interfaces();
protected:
diff --git a/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.idl b/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.idl
index 0c604a4bb9a..d2f74503da5 100644
--- a/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.idl
+++ b/Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.idl
@@ -1,5 +1,9 @@
+#import
+
// https://whatpr.org/html/9893/webappapis.html#shadowrealmglobalscope
[Global, Exposed=ShadowRealm]
interface ShadowRealmGlobalScope : EventTarget {
readonly attribute ShadowRealmGlobalScope self;
};
+
+ShadowRealmGlobalScope includes UniversalGlobalScope;
diff --git a/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.cpp
new file mode 100644
index 00000000000..786bc98c797
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2022, Andrew Kaster
+ * Copyright (c) 2023, Linus Groh
+ * Copyright (c) 2023, Luke Wilde
+ * Copyright (c) 2024, Shannon Booth
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace Web::HTML {
+
+UniversalGlobalScopeMixin::~UniversalGlobalScopeMixin() = default;
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa
+WebIDL::ExceptionOr UniversalGlobalScopeMixin::btoa(String const& data) const
+{
+ auto& vm = this_impl().vm();
+ auto& realm = *vm.current_realm();
+
+ // The btoa(data) method must throw an "InvalidCharacterError" DOMException if data contains any character whose code point is greater than U+00FF.
+ Vector byte_string;
+ byte_string.ensure_capacity(data.bytes().size());
+ for (u32 code_point : Utf8View(data)) {
+ if (code_point > 0xff)
+ return WebIDL::InvalidCharacterError::create(realm, "Data contains characters outside the range U+0000 and U+00FF"_string);
+ byte_string.append(code_point);
+ }
+
+ // Otherwise, the user agent must convert data to a byte sequence whose nth byte is the eight-bit representation of the nth code point of data,
+ // and then must apply forgiving-base64 encode to that byte sequence and return the result.
+ return TRY_OR_THROW_OOM(vm, encode_base64(byte_string.span()));
+}
+
+// https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob
+WebIDL::ExceptionOr UniversalGlobalScopeMixin::atob(String const& data) const
+{
+ auto& vm = this_impl().vm();
+ auto& realm = *vm.current_realm();
+
+ // 1. Let decodedData be the result of running forgiving-base64 decode on data.
+ auto decoded_data = decode_base64(data);
+
+ // 2. If decodedData is failure, then throw an "InvalidCharacterError" DOMException.
+ if (decoded_data.is_error())
+ return WebIDL::InvalidCharacterError::create(realm, "Input string is not valid base64 data"_string);
+
+ // 3. Return decodedData.
+ // decode_base64() returns a byte buffer. LibJS uses UTF-8 for strings. Use isomorphic decoding to convert bytes to UTF-8.
+ return Infra::isomorphic_decode(decoded_data.value());
+}
+
+// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
+void UniversalGlobalScopeMixin::queue_microtask(WebIDL::CallbackType& callback)
+{
+ auto& vm = this_impl().vm();
+ auto& realm = *vm.current_realm();
+
+ JS::GCPtr document;
+ if (is(this_impl()))
+ document = &static_cast(this_impl()).associated_document();
+
+ // The queueMicrotask(callback) method must queue a microtask to invoke callback, and if callback throws an exception, report the exception.
+ HTML::queue_a_microtask(document, JS::create_heap_function(realm.heap(), [&callback, &realm] {
+ auto result = WebIDL::invoke_callback(callback, {});
+ if (result.is_error())
+ HTML::report_exception(result, realm);
+ }));
+}
+
+// https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone
+WebIDL::ExceptionOr UniversalGlobalScopeMixin::structured_clone(JS::Value value, StructuredSerializeOptions const& options) const
+{
+ auto& vm = this_impl().vm();
+ (void)options;
+
+ // 1. Let serialized be ? StructuredSerializeWithTransfer(value, options["transfer"]).
+ // FIXME: Use WithTransfer variant of the AO
+ auto serialized = TRY(structured_serialize(vm, value));
+
+ // 2. Let deserializeRecord be ? StructuredDeserializeWithTransfer(serialized, this's relevant realm).
+ // FIXME: Use WithTransfer variant of the AO
+ auto deserialized = TRY(structured_deserialize(vm, serialized, relevant_realm(this_impl()), {}));
+
+ // 3. Return deserializeRecord.[[Deserialized]].
+ return deserialized;
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.h b/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.h
new file mode 100644
index 00000000000..62c45de89b4
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2023, Linus Groh
+ * Copyright (c) 2023, Luke Wilde
+ * Copyright (c) 2024, Shannon Booth
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+namespace Web::HTML {
+
+// https://whatpr.org/html/9893/webappapis.html#universalglobalscope-mixin
+class UniversalGlobalScopeMixin {
+public:
+ virtual ~UniversalGlobalScopeMixin();
+
+ virtual Bindings::PlatformObject& this_impl() = 0;
+ virtual Bindings::PlatformObject const& this_impl() const = 0;
+
+ WebIDL::ExceptionOr btoa(String const& data) const;
+ WebIDL::ExceptionOr atob(String const& data) const;
+ void queue_microtask(WebIDL::CallbackType&);
+ WebIDL::ExceptionOr structured_clone(JS::Value, StructuredSerializeOptions const&) const;
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.idl b/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.idl
new file mode 100644
index 00000000000..1901feaebab
--- /dev/null
+++ b/Userland/Libraries/LibWeb/HTML/UniversalGlobalScope.idl
@@ -0,0 +1,17 @@
+#import
+
+// FIXME: Support VoidFunction in the IDL parser
+callback VoidFunction = undefined ();
+
+// https://whatpr.org/html/9893/webappapis.html#universalglobalscope-mixin
+interface mixin UniversalGlobalScope {
+ // base64 utility methods
+ DOMString btoa(DOMString data);
+ ByteString atob(DOMString data);
+
+ // microtask queuing
+ undefined queueMicrotask(VoidFunction callback);
+
+ // structured cloning
+ any structuredClone(any value, optional StructuredSerializeOptions options = {});
+};
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index 820c71aec0e..78bc9994452 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -49,6 +50,7 @@ class Window final
, public GlobalEventHandlers
, public WindowEventHandlers
, public WindowOrWorkerGlobalScopeMixin
+ , public UniversalGlobalScopeMixin
, public Bindings::WindowGlobalMixin {
WEB_PLATFORM_OBJECT(Window, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(Window);
@@ -58,17 +60,17 @@ public:
~Window();
- using WindowOrWorkerGlobalScopeMixin::atob;
- using WindowOrWorkerGlobalScopeMixin::btoa;
+ using UniversalGlobalScopeMixin::atob;
+ using UniversalGlobalScopeMixin::btoa;
+ using UniversalGlobalScopeMixin::queue_microtask;
+ using UniversalGlobalScopeMixin::structured_clone;
using WindowOrWorkerGlobalScopeMixin::clear_interval;
using WindowOrWorkerGlobalScopeMixin::clear_timeout;
using WindowOrWorkerGlobalScopeMixin::create_image_bitmap;
using WindowOrWorkerGlobalScopeMixin::fetch;
- using WindowOrWorkerGlobalScopeMixin::queue_microtask;
using WindowOrWorkerGlobalScopeMixin::report_error;
using WindowOrWorkerGlobalScopeMixin::set_interval;
using WindowOrWorkerGlobalScopeMixin::set_timeout;
- using WindowOrWorkerGlobalScopeMixin::structured_clone;
// ^DOM::EventTarget
virtual bool dispatch_event(DOM::Event&) override;
diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl
index c3111850433..d78fbc20a2e 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.idl
+++ b/Userland/Libraries/LibWeb/HTML/Window.idl
@@ -9,6 +9,7 @@
#import
#import
#import
+#import
#import
#import
#import
@@ -115,6 +116,7 @@ interface Window : EventTarget {
};
Window includes AnimationFrameProvider;
Window includes GlobalEventHandlers;
+Window includes UniversalGlobalScope;
Window includes WindowEventHandlers;
Window includes WindowLocalStorage;
Window includes WindowSessionStorage;
diff --git a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
index 887e85a0568..08a1130b6f3 100644
--- a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
+++ b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
@@ -6,7 +6,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include
#include
#include
#include
@@ -27,8 +26,6 @@
#include
#include
#include
-#include
-#include
#include
#include
#include
@@ -108,62 +105,6 @@ bool WindowOrWorkerGlobalScopeMixin::cross_origin_isolated() const
return relevant_settings_object(this_impl()).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes;
}
-// https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa
-WebIDL::ExceptionOr WindowOrWorkerGlobalScopeMixin::btoa(String const& data) const
-{
- auto& vm = this_impl().vm();
- auto& realm = *vm.current_realm();
-
- // The btoa(data) method must throw an "InvalidCharacterError" DOMException if data contains any character whose code point is greater than U+00FF.
- Vector byte_string;
- byte_string.ensure_capacity(data.bytes().size());
- for (u32 code_point : Utf8View(data)) {
- if (code_point > 0xff)
- return WebIDL::InvalidCharacterError::create(realm, "Data contains characters outside the range U+0000 and U+00FF"_string);
- byte_string.append(code_point);
- }
-
- // Otherwise, the user agent must convert data to a byte sequence whose nth byte is the eight-bit representation of the nth code point of data,
- // and then must apply forgiving-base64 encode to that byte sequence and return the result.
- return TRY_OR_THROW_OOM(vm, encode_base64(byte_string.span()));
-}
-
-// https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob
-WebIDL::ExceptionOr WindowOrWorkerGlobalScopeMixin::atob(String const& data) const
-{
- auto& vm = this_impl().vm();
- auto& realm = *vm.current_realm();
-
- // 1. Let decodedData be the result of running forgiving-base64 decode on data.
- auto decoded_data = decode_base64(data);
-
- // 2. If decodedData is failure, then throw an "InvalidCharacterError" DOMException.
- if (decoded_data.is_error())
- return WebIDL::InvalidCharacterError::create(realm, "Input string is not valid base64 data"_string);
-
- // 3. Return decodedData.
- // decode_base64() returns a byte buffer. LibJS uses UTF-8 for strings. Use isomorphic decoding to convert bytes to UTF-8.
- return Infra::isomorphic_decode(decoded_data.value());
-}
-
-// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
-void WindowOrWorkerGlobalScopeMixin::queue_microtask(WebIDL::CallbackType& callback)
-{
- auto& vm = this_impl().vm();
- auto& realm = *vm.current_realm();
-
- JS::GCPtr document;
- if (is(this_impl()))
- document = &static_cast(this_impl()).associated_document();
-
- // The queueMicrotask(callback) method must queue a microtask to invoke callback, and if callback throws an exception, report the exception.
- HTML::queue_a_microtask(document, JS::create_heap_function(realm.heap(), [&callback, &realm] {
- auto result = WebIDL::invoke_callback(callback, {});
- if (result.is_error())
- HTML::report_exception(result, realm);
- }));
-}
-
// https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap
JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin::create_image_bitmap(ImageBitmapSource image, Optional options) const
{
@@ -261,24 +202,6 @@ JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin::create_image_b
return p;
}
-// https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone
-WebIDL::ExceptionOr WindowOrWorkerGlobalScopeMixin::structured_clone(JS::Value value, StructuredSerializeOptions const& options) const
-{
- auto& vm = this_impl().vm();
- (void)options;
-
- // 1. Let serialized be ? StructuredSerializeWithTransfer(value, options["transfer"]).
- // FIXME: Use WithTransfer variant of the AO
- auto serialized = TRY(structured_serialize(vm, value));
-
- // 2. Let deserializeRecord be ? StructuredDeserializeWithTransfer(serialized, this's relevant realm).
- // FIXME: Use WithTransfer variant of the AO
- auto deserialized = TRY(structured_deserialize(vm, serialized, relevant_realm(this_impl()), {}));
-
- // 3. Return deserializeRecord.[[Deserialized]].
- return deserialized;
-}
-
JS::NonnullGCPtr WindowOrWorkerGlobalScopeMixin::fetch(Fetch::RequestInfo const& input, Fetch::RequestInit const& init) const
{
auto& vm = this_impl().vm();
diff --git a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
index ca387655013..0221b742f15 100644
--- a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
+++ b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.h
@@ -36,12 +36,8 @@ public:
WebIDL::ExceptionOr origin() const;
bool is_secure_context() const;
bool cross_origin_isolated() const;
- WebIDL::ExceptionOr btoa(String const& data) const;
- WebIDL::ExceptionOr atob(String const& data) const;
- void queue_microtask(WebIDL::CallbackType&);
JS::NonnullGCPtr create_image_bitmap(ImageBitmapSource image, Optional options = {}) const;
JS::NonnullGCPtr create_image_bitmap(ImageBitmapSource image, WebIDL::Long sx, WebIDL::Long sy, WebIDL::Long sw, WebIDL::Long sh, Optional options = {}) const;
- WebIDL::ExceptionOr structured_clone(JS::Value, StructuredSerializeOptions const&) const;
JS::NonnullGCPtr fetch(Fetch::RequestInfo const&, Fetch::RequestInit const&) const;
i32 set_timeout(TimerHandler, i32 timeout, JS::MarkedVector arguments);
diff --git a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.idl b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.idl
index c0fa1e1a33b..33e54718faa 100644
--- a/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.idl
+++ b/Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.idl
@@ -6,9 +6,6 @@
#import
#import
-// FIXME: Support VoidFunction in the IDL parser
-callback VoidFunction = undefined ();
-
// https://html.spec.whatwg.org/#timerhandler
typedef (DOMString or Function) TimerHandler;
@@ -21,26 +18,16 @@ interface mixin WindowOrWorkerGlobalScope {
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-reporterror
undefined reportError(any e);
- // base64 utility methods
- DOMString btoa(DOMString data);
- ByteString atob(DOMString data);
-
// timers
long setTimeout(TimerHandler handler, optional long timeout = 0, any... arguments);
undefined clearTimeout(optional long id = 0);
long setInterval(TimerHandler handler, optional long timeout = 0, any... arguments);
undefined clearInterval(optional long id = 0);
- // microtask queuing
- undefined queueMicrotask(VoidFunction callback);
-
// ImageBitmap
Promise createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options = {});
Promise createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options = {});
- // structured cloning
- any structuredClone(any value, optional StructuredSerializeOptions options = {});
-
// https://fetch.spec.whatwg.org/#fetch-method
[NewObject] Promise fetch(RequestInfo input, optional RequestInit init = {});
diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h
index 34cbad1356f..0f5350bb3df 100644
--- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h
+++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h
@@ -13,6 +13,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -33,7 +34,8 @@ namespace Web::HTML {
// user agent runs the run a worker algorithm.
class WorkerGlobalScope
: public DOM::EventTarget
- , public WindowOrWorkerGlobalScopeMixin {
+ , public WindowOrWorkerGlobalScopeMixin
+ , public UniversalGlobalScopeMixin {
WEB_PLATFORM_OBJECT(WorkerGlobalScope, DOM::EventTarget);
JS_DECLARE_ALLOCATOR(WorkerGlobalScope);
@@ -44,17 +46,17 @@ public:
virtual Bindings::PlatformObject& this_impl() override { return *this; }
virtual Bindings::PlatformObject const& this_impl() const override { return *this; }
- using WindowOrWorkerGlobalScopeMixin::atob;
- using WindowOrWorkerGlobalScopeMixin::btoa;
+ using UniversalGlobalScopeMixin::atob;
+ using UniversalGlobalScopeMixin::btoa;
+ using UniversalGlobalScopeMixin::queue_microtask;
+ using UniversalGlobalScopeMixin::structured_clone;
using WindowOrWorkerGlobalScopeMixin::clear_interval;
using WindowOrWorkerGlobalScopeMixin::clear_timeout;
using WindowOrWorkerGlobalScopeMixin::create_image_bitmap;
using WindowOrWorkerGlobalScopeMixin::fetch;
using WindowOrWorkerGlobalScopeMixin::performance;
- using WindowOrWorkerGlobalScopeMixin::queue_microtask;
using WindowOrWorkerGlobalScopeMixin::set_interval;
using WindowOrWorkerGlobalScopeMixin::set_timeout;
- using WindowOrWorkerGlobalScopeMixin::structured_clone;
// Following methods are from the WorkerGlobalScope IDL definition
// https://html.spec.whatwg.org/multipage/workers.html#the-workerglobalscope-common-interface
diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl
index b652098e7b1..07c1901deb4 100644
--- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl
+++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.idl
@@ -1,10 +1,11 @@
#import
#import
#import
+#import
+#import
#import
#import
#import
-#import
// https://html.spec.whatwg.org/multipage/workers.html#workerglobalscope
[Exposed=Worker]
@@ -22,5 +23,6 @@ interface WorkerGlobalScope : EventTarget {
attribute EventHandler onunhandledrejection;
};
-WorkerGlobalScope includes WindowOrWorkerGlobalScope;
WorkerGlobalScope includes FontFaceSource;
+WorkerGlobalScope includes UniversalGlobalScope;
+WorkerGlobalScope includes WindowOrWorkerGlobalScope;
diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake
index 01a7539c5ac..7f84bccbdf5 100644
--- a/Userland/Libraries/LibWeb/idl_files.cmake
+++ b/Userland/Libraries/LibWeb/idl_files.cmake
@@ -222,7 +222,7 @@ libweb_js_bindings(HTML/RadioNodeList)
libweb_js_bindings(HTML/ServiceWorker)
libweb_js_bindings(HTML/ServiceWorkerContainer)
libweb_js_bindings(HTML/ServiceWorkerRegistration)
-libweb_js_bindings(HTML/ShadowRealmGlobalScope)
+libweb_js_bindings(HTML/ShadowRealmGlobalScope GLOBAL)
libweb_js_bindings(HTML/Storage)
libweb_js_bindings(HTML/SubmitEvent)
libweb_js_bindings(HTML/TextMetrics)