瀏覽代碼

LibWeb: Make TemporaryExecutionContext take a Realm&

Shannon Booth 8 月之前
父節點
當前提交
cc91473f4d
共有 34 個文件被更改,包括 106 次插入107 次删除
  1. 6 6
      Userland/Libraries/LibWeb/Animations/Animation.cpp
  2. 1 1
      Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
  3. 1 1
      Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp
  4. 1 1
      Userland/Libraries/LibWeb/CSS/CSSTransition.cpp
  5. 4 4
      Userland/Libraries/LibWeb/CSS/FontFace.cpp
  6. 4 4
      Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp
  7. 3 3
      Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
  8. 2 2
      Userland/Libraries/LibWeb/Clipboard/Clipboard.cpp
  9. 10 10
      Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp
  10. 2 2
      Userland/Libraries/LibWeb/Fetch/Body.cpp
  11. 2 2
      Userland/Libraries/LibWeb/Fetch/BodyInit.cpp
  12. 2 2
      Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp
  13. 1 1
      Userland/Libraries/LibWeb/Fetch/Fetching/FetchedDataReceiver.cpp
  14. 3 3
      Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp
  15. 2 2
      Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp
  16. 1 1
      Userland/Libraries/LibWeb/Fetch/Infrastructure/IncrementalReadLoopReadRequest.cpp
  17. 1 1
      Userland/Libraries/LibWeb/FileAPI/FileReader.cpp
  18. 1 1
      Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
  19. 3 3
      Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp
  20. 3 3
      Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp
  21. 1 1
      Userland/Libraries/LibWeb/HTML/MessagePort.cpp
  22. 5 5
      Userland/Libraries/LibWeb/HTML/Navigation.cpp
  23. 1 1
      Userland/Libraries/LibWeb/HTML/Scripting/ImportMap.cpp
  24. 6 6
      Userland/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.cpp
  25. 2 2
      Userland/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.h
  26. 1 2
      Userland/Libraries/LibWeb/HTML/Window.cpp
  27. 5 5
      Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp
  28. 4 4
      Userland/Libraries/LibWeb/Page/Page.cpp
  29. 6 6
      Userland/Libraries/LibWeb/ServiceWorker/Job.cpp
  30. 3 3
      Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp
  31. 6 6
      Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp
  32. 4 4
      Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp
  33. 6 6
      Userland/Libraries/LibWeb/WebDriver/ExecuteScript.cpp
  34. 3 3
      Userland/Services/WebContent/WebDriverConnection.cpp

+ 6 - 6
Userland/Libraries/LibWeb/Animations/Animation.cpp

@@ -424,7 +424,7 @@ void Animation::cancel(ShouldInvalidate should_invalidate)
 
 
     // 1. If animation’s play state is not idle, perform the following steps:
     // 1. If animation’s play state is not idle, perform the following steps:
     if (play_state() != Bindings::AnimationPlayState::Idle) {
     if (play_state() != Bindings::AnimationPlayState::Idle) {
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+        HTML::TemporaryExecutionContext execution_context { realm };
 
 
         // 1. Run the procedure to reset an animation’s pending tasks on animation.
         // 1. Run the procedure to reset an animation’s pending tasks on animation.
         reset_an_animations_pending_tasks();
         reset_an_animations_pending_tasks();
@@ -537,7 +537,7 @@ WebIDL::ExceptionOr<void> Animation::finish()
     }
     }
 
 
     if (should_resolve_ready_promise) {
     if (should_resolve_ready_promise) {
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm()) };
+        HTML::TemporaryExecutionContext execution_context { realm() };
         WebIDL::resolve_promise(realm(), current_ready_promise(), this);
         WebIDL::resolve_promise(realm(), current_ready_promise(), this);
     }
     }
 
 
@@ -1111,7 +1111,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync
                 return;
                 return;
 
 
             // 2. Resolve animation’s current finished promise object with animation.
             // 2. Resolve animation’s current finished promise object with animation.
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+            HTML::TemporaryExecutionContext execution_context { realm };
             WebIDL::resolve_promise(realm, current_finished_promise(), this);
             WebIDL::resolve_promise(realm, current_finished_promise(), this);
             m_is_finished = true;
             m_is_finished = true;
 
 
@@ -1178,7 +1178,7 @@ void Animation::update_finished_state(DidSeek did_seek, SynchronouslyNotify sync
     // 6. If current finished state is false and animation’s current finished promise is already resolved, set
     // 6. If current finished state is false and animation’s current finished promise is already resolved, set
     //    animation’s current finished promise to a new promise in the relevant Realm of animation.
     //    animation’s current finished promise to a new promise in the relevant Realm of animation.
     if (!current_finished_state && m_is_finished) {
     if (!current_finished_state && m_is_finished) {
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+        HTML::TemporaryExecutionContext execution_context { realm };
         m_current_finished_promise = WebIDL::create_promise(realm);
         m_current_finished_promise = WebIDL::create_promise(realm);
         m_is_finished = false;
         m_is_finished = false;
     }
     }
@@ -1266,7 +1266,7 @@ void Animation::run_pending_play_task()
     }
     }
 
 
     // 4. Resolve animation’s current ready promise with animation.
     // 4. Resolve animation’s current ready promise with animation.
-    HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm()) };
+    HTML::TemporaryExecutionContext execution_context { realm() };
     WebIDL::resolve_promise(realm(), current_ready_promise(), this);
     WebIDL::resolve_promise(realm(), current_ready_promise(), this);
 
 
     // 5. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,
     // 5. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,
@@ -1296,7 +1296,7 @@ void Animation::run_pending_pause_task()
     m_start_time = {};
     m_start_time = {};
 
 
     // 5. Resolve animation’s current ready promise with animation.
     // 5. Resolve animation’s current ready promise with animation.
-    HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm()) };
+    HTML::TemporaryExecutionContext execution_context { realm() };
     WebIDL::resolve_promise(realm(), current_ready_promise(), this);
     WebIDL::resolve_promise(realm(), current_ready_promise(), this);
 
 
     // 6. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,
     // 6. Run the procedure to update an animation’s finished state for animation with the did seek flag set to false,

+ 1 - 1
Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp

@@ -464,7 +464,7 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
             auto completion = dom_exception_to_throw_completion(main_thread_vm(), url.exception());
             auto completion = dom_exception_to_throw_completion(main_thread_vm(), url.exception());
 
 
             // 2. Perform FinishLoadingImportedModule(referrer, moduleRequest, payload, completion).
             // 2. Perform FinishLoadingImportedModule(referrer, moduleRequest, payload, completion).
-            HTML::TemporaryExecutionContext context { host_defined_environment_settings_object(realm) };
+            HTML::TemporaryExecutionContext context { realm };
             JS::finish_loading_imported_module(referrer, module_request, payload, completion);
             JS::finish_loading_imported_module(referrer, module_request, payload, completion);
 
 
             // 3. Return.
             // 3. Return.

+ 1 - 1
Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp

@@ -210,7 +210,7 @@ JS::NonnullGCPtr<WebIDL::Promise> CSSStyleSheet::replace(String text)
 
 
     // 4. In parallel, do these steps:
     // 4. In parallel, do these steps:
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, this, text = move(text), promise = JS::Handle(promise)] {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, this, text = move(text), promise = JS::Handle(promise)] {
-        HTML::TemporaryExecutionContext execution_context { HTML::relevant_settings_object(*this), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+        HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
         // 1. Let rules be the result of running parse a stylesheet’s contents from text.
         // 1. Let rules be the result of running parse a stylesheet’s contents from text.
         auto context = m_style_sheet_list ? CSS::Parser::ParsingContext { m_style_sheet_list->document() } : CSS::Parser::ParsingContext { realm };
         auto context = m_style_sheet_list ? CSS::Parser::ParsingContext { m_style_sheet_list->document() } : CSS::Parser::ParsingContext { realm };

+ 1 - 1
Userland/Libraries/LibWeb/CSS/CSSTransition.cpp

@@ -120,7 +120,7 @@ CSSTransition::CSSTransition(JS::Realm& realm, DOM::Element& element, PropertyID
     element.associate_with_animation(*this);
     element.associate_with_animation(*this);
     element.set_transition(m_transition_property, *this);
     element.set_transition(m_transition_property, *this);
 
 
-    HTML::TemporaryExecutionContext context(element.document().relevant_settings_object());
+    HTML::TemporaryExecutionContext context(realm);
     play().release_value_but_fixme_should_propagate_errors();
     play().release_value_but_fixme_should_propagate_errors();
 }
 }
 
 

+ 4 - 4
Userland/Libraries/LibWeb/CSS/FontFace.cpp

@@ -130,7 +130,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
 
 
         font->m_font_load_promise->when_resolved([font = JS::make_handle(font)](auto const& vector_font) -> ErrorOr<void> {
         font->m_font_load_promise->when_resolved([font = JS::make_handle(font)](auto const& vector_font) -> ErrorOr<void> {
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), vector_font] {
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), vector_font] {
-                HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+                HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
                 // 1. If the load was successful, font face now represents the parsed font;
                 // 1. If the load was successful, font face now represents the parsed font;
                 //    fulfill font face’s [[FontStatusPromise]] with font face, and set its status attribute to "loaded".
                 //    fulfill font face’s [[FontStatusPromise]] with font face, and set its status attribute to "loaded".
 
 
@@ -147,7 +147,7 @@ JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String fam
         });
         });
         font->m_font_load_promise->when_rejected([font = JS::make_handle(font)](auto const& error) {
         font->m_font_load_promise->when_rejected([font = JS::make_handle(font)](auto const& error) {
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), error = Error::copy(error)] {
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), error = Error::copy(error)] {
-                HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+                HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
                 // 2. Otherwise, reject font face’s [[FontStatusPromise]] with a DOMException named "SyntaxError"
                 // 2. Otherwise, reject font face’s [[FontStatusPromise]] with a DOMException named "SyntaxError"
                 //    and set font face’s status attribute to "error".
                 //    and set font face’s status attribute to "error".
                 font->m_status = Bindings::FontFaceLoadStatus::Error;
                 font->m_status = Bindings::FontFaceLoadStatus::Error;
@@ -356,7 +356,7 @@ void FontFace::load_font_source()
         // 5. When the load operation completes, successfully or not, queue a task to run the following steps synchronously:
         // 5. When the load operation completes, successfully or not, queue a task to run the following steps synchronously:
         auto on_error = [font] {
         auto on_error = [font] {
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font)] {
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font)] {
-                HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+                HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
 
 
                 //     1. If the attempt to load fails, reject font face’s [[FontStatusPromise]] with a DOMException whose name
                 //     1. If the attempt to load fails, reject font face’s [[FontStatusPromise]] with a DOMException whose name
                 //        is "NetworkError" and set font face’s status attribute to "error".
                 //        is "NetworkError" and set font face’s status attribute to "error".
@@ -370,7 +370,7 @@ void FontFace::load_font_source()
         auto on_load = [font](FontLoader const& loader) {
         auto on_load = [font](FontLoader const& loader) {
             // FIXME: We are assuming that the font loader will live as long as the document! This is an unsafe capture
             // FIXME: We are assuming that the font loader will live as long as the document! This is an unsafe capture
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), &loader] {
             HTML::queue_global_task(HTML::Task::Source::FontLoading, HTML::relevant_global_object(*font), JS::create_heap_function(font->heap(), [font = JS::NonnullGCPtr(*font), &loader] {
-                HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*font), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+                HTML::TemporaryExecutionContext context(font->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
 
 
                 // 2. Otherwise, font face now represents the loaded font; fulfill font face’s [[FontStatusPromise]] with font face
                 // 2. Otherwise, font face now represents the loaded font; fulfill font face’s [[FontStatusPromise]] with font face
                 //    and set font face’s status attribute to "loaded".
                 //    and set font face’s status attribute to "loaded".

+ 4 - 4
Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp

@@ -241,7 +241,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(Strin
         //    reject promise with a SyntaxError exception and terminate these steps.
         //    reject promise with a SyntaxError exception and terminate these steps.
         auto result = find_matching_font_faces(realm, font_face_set, font, text);
         auto result = find_matching_font_faces(realm, font_face_set, font, text);
         if (result.is_error()) {
         if (result.is_error()) {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
             WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
             WebIDL::reject_promise(realm, promise, Bindings::dom_exception_to_throw_completion(realm.vm(), result.release_error()).release_value().value());
             return;
             return;
         }
         }
@@ -262,16 +262,16 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> FontFaceSet::load(Strin
 
 
             // 2. Resolve promise with the result of waiting for all of the [[FontStatusPromise]]s of each font face in
             // 2. Resolve promise with the result of waiting for all of the [[FontStatusPromise]]s of each font face in
             //    the font face list, in order.
             //    the font face list, in order.
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
             WebIDL::wait_for_all(
             WebIDL::wait_for_all(
                 realm, promises,
                 realm, promises,
                 [&realm, promise](auto const&) {
                 [&realm, promise](auto const&) {
-                    HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+                    HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
                     WebIDL::resolve_promise(realm, promise);
                     WebIDL::resolve_promise(realm, promise);
                 },
                 },
                 [&realm, promise](auto error) {
                 [&realm, promise](auto error) {
-                    HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+                    HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
                     WebIDL::reject_promise(realm, promise, error);
                     WebIDL::reject_promise(realm, promise, error);
                 });
                 });
         }));
         }));

+ 3 - 3
Userland/Libraries/LibWeb/CSS/StyleComputer.cpp

@@ -1140,10 +1140,10 @@ static void apply_animation_properties(DOM::Document& document, StyleProperties&
 
 
     if (play_state != effect.last_css_animation_play_state()) {
     if (play_state != effect.last_css_animation_play_state()) {
         if (play_state == CSS::AnimationPlayState::Running && animation.play_state() == Bindings::AnimationPlayState::Paused) {
         if (play_state == CSS::AnimationPlayState::Running && animation.play_state() == Bindings::AnimationPlayState::Paused) {
-            HTML::TemporaryExecutionContext context(document.relevant_settings_object());
+            HTML::TemporaryExecutionContext context(document.realm());
             animation.play().release_value_but_fixme_should_propagate_errors();
             animation.play().release_value_but_fixme_should_propagate_errors();
         } else if (play_state == CSS::AnimationPlayState::Paused && animation.play_state() != Bindings::AnimationPlayState::Paused) {
         } else if (play_state == CSS::AnimationPlayState::Paused && animation.play_state() != Bindings::AnimationPlayState::Paused) {
-            HTML::TemporaryExecutionContext context(document.relevant_settings_object());
+            HTML::TemporaryExecutionContext context(document.realm());
             animation.pause().release_value_but_fixme_should_propagate_errors();
             animation.pause().release_value_but_fixme_should_propagate_errors();
         }
         }
 
 
@@ -1561,7 +1561,7 @@ void StyleComputer::compute_cascaded_values(StyleProperties& style, DOM::Element
                 effect->set_target(&element);
                 effect->set_target(&element);
                 element.set_cached_animation_name_animation(animation, pseudo_element);
                 element.set_cached_animation_name_animation(animation, pseudo_element);
 
 
-                HTML::TemporaryExecutionContext context(m_document->relevant_settings_object());
+                HTML::TemporaryExecutionContext context(realm);
                 animation->play().release_value_but_fixme_should_propagate_errors();
                 animation->play().release_value_but_fixme_should_propagate_errors();
             } else {
             } else {
                 // The animation hasn't changed, but some properties of the animation may have
                 // The animation hasn't changed, but some properties of the animation may have

+ 2 - 2
Userland/Libraries/LibWeb/Clipboard/Clipboard.cpp

@@ -160,7 +160,7 @@ JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
             // 1. Queue a global task on the permission task source, given realm’s global object, to reject p with
             // 1. Queue a global task on the permission task source, given realm’s global object, to reject p with
             //    "NotAllowedError" DOMException in realm.
             //    "NotAllowedError" DOMException in realm.
             queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), JS::create_heap_function(realm.heap(), [&realm, promise]() mutable {
             queue_global_task(HTML::Task::Source::Permissions, realm.global_object(), JS::create_heap_function(realm.heap(), [&realm, promise]() mutable {
-                HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+                HTML::TemporaryExecutionContext execution_context { realm };
                 WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_string));
                 WebIDL::reject_promise(realm, promise, WebIDL::NotAllowedError::create(realm, "Clipboard writing is only allowed through user activation"_string));
             }));
             }));
 
 
@@ -188,7 +188,7 @@ JS::NonnullGCPtr<WebIDL::Promise> Clipboard::write_text(String data)
             write_blobs_and_option_to_clipboard(realm, item_list, move(option));
             write_blobs_and_option_to_clipboard(realm, item_list, move(option));
 
 
             // 6. Resolve p.
             // 6. Resolve p.
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+            HTML::TemporaryExecutionContext execution_context { realm };
             WebIDL::resolve_promise(realm, promise, JS::js_undefined());
             WebIDL::resolve_promise(realm, promise, JS::js_undefined());
         }));
         }));
     }));
     }));

+ 10 - 10
Userland/Libraries/LibWeb/Crypto/SubtleCrypto.cpp

@@ -148,7 +148,7 @@ JS::NonnullGCPtr<WebIDL::Promise> SubtleCrypto::encrypt(AlgorithmIdentifier cons
     // 6. Return promise and perform the remaining steps in parallel.
     // 6. Return promise and perform the remaining steps in parallel.
 
 
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, data = move(data)]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, data = move(data)]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
         // 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
         // 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
@@ -205,7 +205,7 @@ JS::NonnullGCPtr<WebIDL::Promise> SubtleCrypto::decrypt(AlgorithmIdentifier cons
     // 6. Return promise and perform the remaining steps in parallel.
     // 6. Return promise and perform the remaining steps in parallel.
 
 
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, data = move(data)]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, data = move(data)]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
         // 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
         // 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
@@ -263,7 +263,7 @@ JS::NonnullGCPtr<WebIDL::Promise> SubtleCrypto::digest(AlgorithmIdentifier const
 
 
     // 6. Return promise and perform the remaining steps in parallel.
     // 6. Return promise and perform the remaining steps in parallel.
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, algorithm_object = normalized_algorithm.release_value(), promise, data_buffer = move(data_buffer)]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, algorithm_object = normalized_algorithm.release_value(), promise, data_buffer = move(data_buffer)]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // FIXME: Need spec reference to https://webidl.spec.whatwg.org/#reject
         // FIXME: Need spec reference to https://webidl.spec.whatwg.org/#reject
 
 
@@ -303,7 +303,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::generate_
 
 
     // 5. Return promise and perform the remaining steps in parallel.
     // 5. Return promise and perform the remaining steps in parallel.
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, extractable, key_usages = move(key_usages)]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, extractable, key_usages = move(key_usages)]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 6. If the following steps or referenced procedures say to throw an error, reject promise with
         // 6. If the following steps or referenced procedures say to throw an error, reject promise with
         //    the returned error and then terminate the algorithm.
         //    the returned error and then terminate the algorithm.
 
 
@@ -385,7 +385,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::import_ke
 
 
     // 8. Return promise and perform the remaining steps in parallel.
     // 8. Return promise and perform the remaining steps in parallel.
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [&realm, real_key_data = move(real_key_data), normalized_algorithm = normalized_algorithm.release_value(), promise, format, extractable, key_usages = move(key_usages), algorithm = move(algorithm)]() mutable -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [&realm, real_key_data = move(real_key_data), normalized_algorithm = normalized_algorithm.release_value(), promise, format, extractable, key_usages = move(key_usages), algorithm = move(algorithm)]() mutable -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
 
 
         // 9. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 9. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
@@ -429,7 +429,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::export_ke
 
 
     // 3. Return promise and perform the remaining steps in parallel.
     // 3. Return promise and perform the remaining steps in parallel.
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [&realm, key, promise, format]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [&realm, key, promise, format]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 4.  If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 4.  If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
         // 5. If the name member of the [[algorithm]] internal slot of key does not identify a registered algorithm that supports the export key operation,
         // 5. If the name member of the [[algorithm]] internal slot of key does not identify a registered algorithm that supports the export key operation,
@@ -492,7 +492,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::sign(Algo
     // 6. Return promise and perform the remaining steps in parallel.
     // 6. Return promise and perform the remaining steps in parallel.
 
 
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, data = move(data)]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, data = move(data)]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 7. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
         // 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
         // 8. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
@@ -556,7 +556,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::verify(Al
 
 
     // 7. Return promise and perform the remaining steps in parallel.
     // 7. Return promise and perform the remaining steps in parallel.
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, signature = move(signature), data = move(data)]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, key, signature = move(signature), data = move(data)]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 8. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 8. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
         // 9. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
         // 9. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of key then throw an InvalidAccessError.
@@ -603,7 +603,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::derive_bi
 
 
     // 5. Return promise and perform the remaining steps in parallel.
     // 5. Return promise and perform the remaining steps in parallel.
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, base_key, length]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, normalized_algorithm = normalized_algorithm.release_value(), promise, base_key, length]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 6. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 6. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
         // 7. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of baseKey then throw an InvalidAccessError.
         // 7. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of baseKey then throw an InvalidAccessError.
@@ -664,7 +664,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<WebIDL::Promise>> SubtleCrypto::derive_ke
 
 
     // 9. Return promise and perform the remaining steps in parallel.
     // 9. Return promise and perform the remaining steps in parallel.
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, &vm, normalized_algorithm = normalized_algorithm.release_value(), promise, normalized_derived_key_algorithm_import = normalized_derived_key_algorithm_import.release_value(), normalized_derived_key_algorithm_length = normalized_derived_key_algorithm_length.release_value(), base_key = move(base_key), extractable, key_usages = move(key_usages)]() -> void {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, &vm, normalized_algorithm = normalized_algorithm.release_value(), promise, normalized_derived_key_algorithm_import = normalized_derived_key_algorithm_import.release_value(), normalized_derived_key_algorithm_length = normalized_derived_key_algorithm_length.release_value(), base_key = move(base_key), extractable, key_usages = move(key_usages)]() -> void {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 10. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
         // 10. If the following steps or referenced procedures say to throw an error, reject promise with the returned error and then terminate the algorithm.
 
 
         // 11. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of baseKey then throw an InvalidAccessError.
         // 11. If the name member of normalizedAlgorithm is not equal to the name attribute of the [[algorithm]] internal slot of baseKey then throw an InvalidAccessError.

+ 2 - 2
Userland/Libraries/LibWeb/Fetch/Body.cpp

@@ -190,7 +190,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> consume_body(JS::Realm& r
     // NOTE: `promise` and `realm` is protected by JS::HeapFunction.
     // NOTE: `promise` and `realm` is protected by JS::HeapFunction.
     auto error_steps = JS::create_heap_function(realm.heap(), [promise, &realm](JS::Value error) {
     auto error_steps = JS::create_heap_function(realm.heap(), [promise, &realm](JS::Value error) {
         // AD-HOC: An execution context is required for Promise's reject function.
         // AD-HOC: An execution context is required for Promise's reject function.
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+        HTML::TemporaryExecutionContext execution_context { realm };
         WebIDL::reject_promise(realm, promise, error);
         WebIDL::reject_promise(realm, promise, error);
     });
     });
 
 
@@ -202,7 +202,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> consume_body(JS::Realm& r
         auto& vm = realm.vm();
         auto& vm = realm.vm();
 
 
         // AD-HOC: An execution context is required for Promise's reject function and JSON.parse.
         // AD-HOC: An execution context is required for Promise's reject function and JSON.parse.
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+        HTML::TemporaryExecutionContext execution_context { realm };
 
 
         auto value_or_error = Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr<JS::Value> {
         auto value_or_error = Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr<JS::Value> {
             return package_data(realm, data, type, object.mime_type_impl());
             return package_data(realm, data, type, object.mime_type_impl());

+ 2 - 2
Userland/Libraries/LibWeb/Fetch/BodyInit.cpp

@@ -38,7 +38,7 @@ WebIDL::ExceptionOr<Infrastructure::BodyWithType> safely_extract_body(JS::Realm&
 // https://fetch.spec.whatwg.org/#concept-bodyinit-extract
 // https://fetch.spec.whatwg.org/#concept-bodyinit-extract
 WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInitOrReadableBytes const& object, bool keepalive)
 WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInitOrReadableBytes const& object, bool keepalive)
 {
 {
-    HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+    HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
     auto& vm = realm.vm();
     auto& vm = realm.vm();
 
 
@@ -146,7 +146,7 @@ WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm,
     // 12. If action is non-null, then run these steps in parallel:
     // 12. If action is non-null, then run these steps in parallel:
     if (action) {
     if (action) {
         Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, stream, action = move(action)] {
         Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, stream, action = move(action)] {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
             // 1. Run action.
             // 1. Run action.
             auto bytes = action();
             auto bytes = action();

+ 2 - 2
Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp

@@ -87,7 +87,7 @@ JS::NonnullGCPtr<WebIDL::Promise> fetch(JS::VM& vm, RequestInfo const& input, Re
             return;
             return;
 
 
         // AD-HOC: An execution context is required for Promise functions.
         // AD-HOC: An execution context is required for Promise functions.
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(relevant_realm) };
+        HTML::TemporaryExecutionContext execution_context { relevant_realm };
 
 
         // 2. If response’s aborted flag is set, then:
         // 2. If response’s aborted flag is set, then:
         if (response->aborted()) {
         if (response->aborted()) {
@@ -143,7 +143,7 @@ JS::NonnullGCPtr<WebIDL::Promise> fetch(JS::VM& vm, RequestInfo const& input, Re
         controller->abort(relevant_realm, request_object->signal()->reason());
         controller->abort(relevant_realm, request_object->signal()->reason());
 
 
         // AD-HOC: An execution context is required for Promise functions.
         // AD-HOC: An execution context is required for Promise functions.
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(relevant_realm) };
+        HTML::TemporaryExecutionContext execution_context { relevant_realm };
 
 
         // 4. Abort the fetch() call with p, request, responseObject, and requestObject’s signal’s abort reason.
         // 4. Abort the fetch() call with p, request, responseObject, and requestObject’s signal’s abort reason.
         abort_fetch(relevant_realm, *promise_capability, request, response_object, request_object->signal()->reason());
         abort_fetch(relevant_realm, *promise_capability, request, response_object, request_object->signal()->reason());

+ 1 - 1
Userland/Libraries/LibWeb/Fetch/Fetching/FetchedDataReceiver.cpp

@@ -66,7 +66,7 @@ void FetchedDataReceiver::on_data_received(ReadonlyBytes bytes)
         m_fetch_params->controller(),
         m_fetch_params->controller(),
         m_fetch_params->task_destination().get<JS::NonnullGCPtr<JS::Object>>(),
         m_fetch_params->task_destination().get<JS::NonnullGCPtr<JS::Object>>(),
         JS::create_heap_function(heap(), [this, bytes = MUST(ByteBuffer::copy(bytes))]() mutable {
         JS::create_heap_function(heap(), [this, bytes = MUST(ByteBuffer::copy(bytes))]() mutable {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(m_stream->realm()), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { m_stream->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
             // 1. Pull from bytes buffer into stream.
             // 1. Pull from bytes buffer into stream.
             if (auto result = Streams::readable_stream_pull_from_bytes(m_stream, move(bytes)); result.is_error()) {
             if (auto result = Streams::readable_stream_pull_from_bytes(m_stream, move(bytes)); result.is_error()) {

+ 3 - 3
Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp

@@ -723,7 +723,7 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const
     }
     }
     // 7. Otherwise:
     // 7. Otherwise:
     else {
     else {
-        HTML::TemporaryExecutionContext const execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+        HTML::TemporaryExecutionContext const execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
         // 1. Let transformStream be a new TransformStream.
         // 1. Let transformStream be a new TransformStream.
         auto transform_stream = realm.heap().allocate<Streams::TransformStream>(realm, realm);
         auto transform_stream = realm.heap().allocate<Streams::TransformStream>(realm, realm);
@@ -2232,7 +2232,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_load
     //        user-agent-defined limit (or not). However, we will need to fully use stream operations throughout the
     //        user-agent-defined limit (or not). However, we will need to fully use stream operations throughout the
     //        fetch process to enable this (e.g. Body::fully_read must use streams for this to work).
     //        fetch process to enable this (e.g. Body::fully_read must use streams for this to work).
     if (request->buffer_policy() == Infrastructure::Request::BufferPolicy::DoNotBufferResponse) {
     if (request->buffer_policy() == Infrastructure::Request::BufferPolicy::DoNotBufferResponse) {
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+        HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
         // 12. Let stream be a new ReadableStream.
         // 12. Let stream be a new ReadableStream.
         auto stream = realm.heap().allocate<Streams::ReadableStream>(realm, realm);
         auto stream = realm.heap().allocate<Streams::ReadableStream>(realm, realm);
@@ -2315,7 +2315,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_load
         });
         });
 
 
         auto on_complete = JS::create_heap_function(vm.heap(), [&vm, &realm, pending_response, stream](bool success, Optional<StringView> error_message) {
         auto on_complete = JS::create_heap_function(vm.heap(), [&vm, &realm, pending_response, stream](bool success, Optional<StringView> error_message) {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
             // 16.1.1.2. Otherwise, if the bytes transmission for response’s message body is done normally and stream is readable,
             // 16.1.1.2. Otherwise, if the bytes transmission for response’s message body is done normally and stream is readable,
             //           then close stream, and abort these in-parallel steps.
             //           then close stream, and abort these in-parallel steps.

+ 2 - 2
Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Bodies.cpp

@@ -49,7 +49,7 @@ void Body::visit_edges(Cell::Visitor& visitor)
 // https://fetch.spec.whatwg.org/#concept-body-clone
 // https://fetch.spec.whatwg.org/#concept-body-clone
 JS::NonnullGCPtr<Body> Body::clone(JS::Realm& realm)
 JS::NonnullGCPtr<Body> Body::clone(JS::Realm& realm)
 {
 {
-    HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+    HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
     // To clone a body body, run these steps:
     // To clone a body body, run these steps:
     // 1. Let « out1, out2 » be the result of teeing body’s stream.
     // 1. Let « out1, out2 » be the result of teeing body’s stream.
@@ -107,7 +107,7 @@ void Body::fully_read(JS::Realm& realm, Web::Fetch::Infrastructure::Body::Proces
 // https://fetch.spec.whatwg.org/#body-incrementally-read
 // https://fetch.spec.whatwg.org/#body-incrementally-read
 void Body::incrementally_read(ProcessBodyChunkCallback process_body_chunk, ProcessEndOfBodyCallback process_end_of_body, ProcessBodyErrorCallback process_body_error, TaskDestination task_destination)
 void Body::incrementally_read(ProcessBodyChunkCallback process_body_chunk, ProcessEndOfBodyCallback process_end_of_body, ProcessBodyErrorCallback process_body_error, TaskDestination task_destination)
 {
 {
-    HTML::TemporaryExecutionContext const execution_context { Bindings::host_defined_environment_settings_object(m_stream->realm()), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+    HTML::TemporaryExecutionContext const execution_context { m_stream->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
     VERIFY(task_destination.has<JS::NonnullGCPtr<JS::Object>>());
     VERIFY(task_destination.has<JS::NonnullGCPtr<JS::Object>>());
     // FIXME: 1. If taskDestination is null, then set taskDestination to the result of starting a new parallel queue.
     // FIXME: 1. If taskDestination is null, then set taskDestination to the result of starting a new parallel queue.

+ 1 - 1
Userland/Libraries/LibWeb/Fetch/Infrastructure/IncrementalReadLoopReadRequest.cpp

@@ -33,7 +33,7 @@ void IncrementalReadLoopReadRequest::on_chunk(JS::Value chunk)
         auto bytes = MUST(ByteBuffer::copy(uint8_array.data()));
         auto bytes = MUST(ByteBuffer::copy(uint8_array.data()));
         // 2. Set continueAlgorithm to these steps:
         // 2. Set continueAlgorithm to these steps:
         continue_algorithm = JS::create_heap_function(realm.heap(), [bytes = move(bytes), body = m_body, reader = m_reader, task_destination = m_task_destination, process_body_chunk = m_process_body_chunk, process_end_of_body = m_process_end_of_body, process_body_error = m_process_body_error] {
         continue_algorithm = JS::create_heap_function(realm.heap(), [bytes = move(bytes), body = m_body, reader = m_reader, task_destination = m_task_destination, process_body_chunk = m_process_body_chunk, process_end_of_body = m_process_end_of_body, process_body_error = m_process_body_error] {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(reader->realm()), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { reader->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
             // 1. Run processBodyChunk given bytes.
             // 1. Run processBodyChunk given bytes.
             process_body_chunk->function()(move(bytes));
             process_body_chunk->function()(move(bytes));
 
 

+ 1 - 1
Userland/Libraries/LibWeb/FileAPI/FileReader.cpp

@@ -147,7 +147,7 @@ WebIDL::ExceptionOr<void> FileReader::read_operation(Blob& blob, Type type, Opti
 
 
     // 10. In parallel, while true:
     // 10. In parallel, while true:
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [this, chunk_promise, reader, bytes, is_first_chunk, &realm, type, encoding_name, blobs_type]() mutable {
     Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(heap(), [this, chunk_promise, reader, bytes, is_first_chunk, &realm, type, encoding_name, blobs_type]() mutable {
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+        HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
         Optional<MonotonicTime> progress_timer;
         Optional<MonotonicTime> progress_timer;
 
 
         while (true) {
         while (true) {

+ 1 - 1
Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp

@@ -397,7 +397,7 @@ void EventLoop::update_the_rendering()
 
 
     for (auto& document : docs) {
     for (auto& document : docs) {
         if (document->readiness() == HTML::DocumentReadyState::Complete && document->style_computer().number_of_css_font_faces_with_loading_in_progress() == 0) {
         if (document->readiness() == HTML::DocumentReadyState::Complete && document->style_computer().number_of_css_font_faces_with_loading_in_progress() == 0) {
-            HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*document), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+            HTML::TemporaryExecutionContext context(document->realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             document->fonts()->resolve_ready_promise();
             document->fonts()->resolve_ready_promise();
         }
         }
     }
     }

+ 3 - 3
Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp

@@ -296,7 +296,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> HTMLImageElement::decode(
                 return false;
                 return false;
 
 
             auto exception = WebIDL::EncodingError::create(realm, "Node document not fully active"_string);
             auto exception = WebIDL::EncodingError::create(realm, "Node document not fully active"_string);
-            HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*this));
+            HTML::TemporaryExecutionContext context(realm);
             WebIDL::reject_promise(realm, promise, exception);
             WebIDL::reject_promise(realm, promise, exception);
             return true;
             return true;
         };
         };
@@ -306,7 +306,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> HTMLImageElement::decode(
                 return false;
                 return false;
 
 
             auto exception = WebIDL::EncodingError::create(realm, "Current request state is broken"_string);
             auto exception = WebIDL::EncodingError::create(realm, "Current request state is broken"_string);
-            HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*this));
+            HTML::TemporaryExecutionContext context(realm);
             WebIDL::reject_promise(realm, promise, exception);
             WebIDL::reject_promise(realm, promise, exception);
             return true;
             return true;
         };
         };
@@ -354,7 +354,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> HTMLImageElement::decode(
                 // (Typically, this would only be violated in low-memory situations that require evicting decoded image data, or when the image is too large
                 // (Typically, this would only be violated in low-memory situations that require evicting decoded image data, or when the image is too large
                 // to keep in decoded form for this period of time.)
                 // to keep in decoded form for this period of time.)
 
 
-                HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*this));
+                HTML::TemporaryExecutionContext context(realm);
                 WebIDL::resolve_promise(realm, promise, JS::js_undefined());
                 WebIDL::resolve_promise(realm, promise, JS::js_undefined());
             }
             }
         }));
         }));

+ 3 - 3
Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp

@@ -375,7 +375,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::pause()
 WebIDL::ExceptionOr<void> HTMLMediaElement::toggle_playback()
 WebIDL::ExceptionOr<void> HTMLMediaElement::toggle_playback()
 {
 {
     // AD-HOC: An execution context is required for Promise creation hooks.
     // AD-HOC: An execution context is required for Promise creation hooks.
-    TemporaryExecutionContext execution_context { document().relevant_settings_object() };
+    TemporaryExecutionContext execution_context { realm() };
 
 
     if (potentially_playing())
     if (potentially_playing())
         TRY(pause());
         TRY(pause());
@@ -1886,7 +1886,7 @@ void HTMLMediaElement::resolve_pending_play_promises(ReadonlySpan<JS::NonnullGCP
     auto& realm = this->realm();
     auto& realm = this->realm();
 
 
     // AD-HOC: An execution context is required for Promise resolving hooks.
     // AD-HOC: An execution context is required for Promise resolving hooks.
-    TemporaryExecutionContext execution_context { document().relevant_settings_object() };
+    TemporaryExecutionContext execution_context { realm };
 
 
     // To resolve pending play promises for a media element with a list of promises promises, the user agent
     // To resolve pending play promises for a media element with a list of promises promises, the user agent
     // must resolve each promise in promises with undefined.
     // must resolve each promise in promises with undefined.
@@ -1900,7 +1900,7 @@ void HTMLMediaElement::reject_pending_play_promises(ReadonlySpan<JS::NonnullGCPt
     auto& realm = this->realm();
     auto& realm = this->realm();
 
 
     // AD-HOC: An execution context is required for Promise rejection hooks.
     // AD-HOC: An execution context is required for Promise rejection hooks.
-    TemporaryExecutionContext execution_context { document().relevant_settings_object() };
+    TemporaryExecutionContext execution_context { realm };
 
 
     // To reject pending play promises for a media element with a list of promise promises and an exception name
     // To reject pending play promises for a media element with a list of promise promises and an exception name
     // error, the user agent must reject each promise in promises with error.
     // error, the user agent must reject each promise in promises with error.

+ 1 - 1
Userland/Libraries/LibWeb/HTML/MessagePort.cpp

@@ -380,7 +380,7 @@ void MessagePort::post_message_task_steps(SerializedTransferRecord& serialize_wi
     auto& target_vm = target_realm.vm();
     auto& target_vm = target_realm.vm();
 
 
     // 3. Let deserializeRecord be StructuredDeserializeWithTransfer(serializeWithTransferResult, targetRealm).
     // 3. Let deserializeRecord be StructuredDeserializeWithTransfer(serializeWithTransferResult, targetRealm).
-    TemporaryExecutionContext context { relevant_settings_object(*final_target_port) };
+    TemporaryExecutionContext context { relevant_realm(*final_target_port) };
     auto deserialize_record_or_error = structured_deserialize_with_transfer(target_vm, serialize_with_transfer_result);
     auto deserialize_record_or_error = structured_deserialize_with_transfer(target_vm, serialize_with_transfer_result);
     if (deserialize_record_or_error.is_error()) {
     if (deserialize_record_or_error.is_error()) {
         // If this throws an exception, catch it, fire an event named messageerror at finalTargetPort, using MessageEvent, and then return.
         // If this throws an exception, catch it, fire an event named messageerror at finalTargetPort, using MessageEvent, and then return.

+ 5 - 5
Userland/Libraries/LibWeb/HTML/Navigation.cpp

@@ -680,7 +680,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
             //    to reject the finished promise for apiMethodTracker with an "InvalidStateError" DOMException.
             //    to reject the finished promise for apiMethodTracker with an "InvalidStateError" DOMException.
             queue_global_task(HTML::Task::Source::NavigationAndTraversal, relevant_global_object(*this), JS::create_heap_function(heap(), [this, api_method_tracker] {
             queue_global_task(HTML::Task::Source::NavigationAndTraversal, relevant_global_object(*this), JS::create_heap_function(heap(), [this, api_method_tracker] {
                 auto& reject_realm = relevant_realm(*this);
                 auto& reject_realm = relevant_realm(*this);
-                TemporaryExecutionContext execution_context { relevant_settings_object(*this) };
+                TemporaryExecutionContext execution_context { reject_realm };
                 WebIDL::reject_promise(reject_realm, api_method_tracker->finished_promise,
                 WebIDL::reject_promise(reject_realm, api_method_tracker->finished_promise,
                     WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry"_string));
                     WebIDL::InvalidStateError::create(reject_realm, "Cannot traverse with stale session history entry"_string));
             }));
             }));
@@ -712,7 +712,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
         auto& global = relevant_global_object(*this);
         auto& global = relevant_global_object(*this);
         if (result == TraversableNavigable::HistoryStepResult::CanceledByBeforeUnload) {
         if (result == TraversableNavigable::HistoryStepResult::CanceledByBeforeUnload) {
             queue_global_task(Task::Source::NavigationAndTraversal, global, JS::create_heap_function(heap(), [this, api_method_tracker, &realm] {
             queue_global_task(Task::Source::NavigationAndTraversal, global, JS::create_heap_function(heap(), [this, api_method_tracker, &realm] {
-                TemporaryExecutionContext execution_context { relevant_settings_object(*this) };
+                TemporaryExecutionContext execution_context { realm };
                 reject_the_finished_promise(api_method_tracker, WebIDL::AbortError::create(realm, "Navigation cancelled by beforeunload"_string));
                 reject_the_finished_promise(api_method_tracker, WebIDL::AbortError::create(realm, "Navigation cancelled by beforeunload"_string));
             }));
             }));
         }
         }
@@ -722,7 +722,7 @@ WebIDL::ExceptionOr<NavigationResult> Navigation::perform_a_navigation_api_trave
         //    new "SecurityError" DOMException created in navigation's relevant realm.
         //    new "SecurityError" DOMException created in navigation's relevant realm.
         if (result == TraversableNavigable::HistoryStepResult::InitiatorDisallowed) {
         if (result == TraversableNavigable::HistoryStepResult::InitiatorDisallowed) {
             queue_global_task(Task::Source::NavigationAndTraversal, global, JS::create_heap_function(heap(), [this, api_method_tracker, &realm] {
             queue_global_task(Task::Source::NavigationAndTraversal, global, JS::create_heap_function(heap(), [this, api_method_tracker, &realm] {
-                TemporaryExecutionContext execution_context { relevant_settings_object(*this) };
+                TemporaryExecutionContext execution_context { realm };
                 reject_the_finished_promise(api_method_tracker, WebIDL::SecurityError::create(realm, "Navigation disallowed from this origin"_string));
                 reject_the_finished_promise(api_method_tracker, WebIDL::SecurityError::create(realm, "Navigation disallowed from this origin"_string));
             }));
             }));
         }
         }
@@ -904,7 +904,7 @@ void Navigation::notify_about_the_committed_to_entry(JS::NonnullGCPtr<Navigation
     }
     }
 
 
     // 3. Resolve apiMethodTracker's committed promise with nhe.
     // 3. Resolve apiMethodTracker's committed promise with nhe.
-    TemporaryExecutionContext execution_context { relevant_settings_object(*this) };
+    TemporaryExecutionContext execution_context { realm };
     WebIDL::resolve_promise(realm, api_method_tracker->committed_promise, nhe);
     WebIDL::resolve_promise(realm, api_method_tracker->committed_promise, nhe);
 }
 }
 
 
@@ -1088,7 +1088,7 @@ bool Navigation::inner_navigate_event_firing_algorithm(
 
 
     // 31. Prepare to run script given navigation's relevant settings object.
     // 31. Prepare to run script given navigation's relevant settings object.
     // NOTE: There's a massive spec note here
     // NOTE: There's a massive spec note here
-    TemporaryExecutionContext execution_context { relevant_settings_object(*this), TemporaryExecutionContext::CallbacksEnabled::Yes };
+    TemporaryExecutionContext execution_context { realm, TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
     // 32. If event's interception state is not "none":
     // 32. If event's interception state is not "none":
     if (event->interception_state() != NavigateEvent::InterceptionState::None) {
     if (event->interception_state() != NavigateEvent::InterceptionState::None) {

+ 1 - 1
Userland/Libraries/LibWeb/HTML/Scripting/ImportMap.cpp

@@ -18,7 +18,7 @@ namespace Web::HTML {
 // https://html.spec.whatwg.org/multipage/webappapis.html#parse-an-import-map-string
 // https://html.spec.whatwg.org/multipage/webappapis.html#parse-an-import-map-string
 WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteString const& input, URL::URL base_url)
 WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteString const& input, URL::URL base_url)
 {
 {
-    HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
+    HTML::TemporaryExecutionContext execution_context { realm };
 
 
     // 1. Let parsed be the result of parsing a JSON string to an Infra value given input.
     // 1. Let parsed be the result of parsing a JSON string to an Infra value given input.
     auto parsed = TRY(Infra::parse_json_string_to_javascript_value(realm, input));
     auto parsed = TRY(Infra::parse_json_string_to_javascript_value(realm, input));

+ 6 - 6
Userland/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.cpp

@@ -9,20 +9,20 @@
 
 
 namespace Web::HTML {
 namespace Web::HTML {
 
 
-TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject& environment_settings, CallbacksEnabled callbacks_enabled)
-    : m_environment_settings(environment_settings)
+TemporaryExecutionContext::TemporaryExecutionContext(JS::Realm& realm, CallbacksEnabled callbacks_enabled)
+    : m_realm(realm)
     , m_callbacks_enabled(callbacks_enabled)
     , m_callbacks_enabled(callbacks_enabled)
 {
 {
-    prepare_to_run_script(m_environment_settings->realm());
+    prepare_to_run_script(m_realm);
     if (m_callbacks_enabled == CallbacksEnabled::Yes)
     if (m_callbacks_enabled == CallbacksEnabled::Yes)
-        prepare_to_run_callback(m_environment_settings->realm());
+        prepare_to_run_callback(m_realm);
 }
 }
 
 
 TemporaryExecutionContext::~TemporaryExecutionContext()
 TemporaryExecutionContext::~TemporaryExecutionContext()
 {
 {
-    clean_up_after_running_script(m_environment_settings->realm());
+    clean_up_after_running_script(m_realm);
     if (m_callbacks_enabled == CallbacksEnabled::Yes)
     if (m_callbacks_enabled == CallbacksEnabled::Yes)
-        clean_up_after_running_callback(m_environment_settings->realm());
+        clean_up_after_running_callback(m_realm);
 }
 }
 
 
 }
 }

+ 2 - 2
Userland/Libraries/LibWeb/HTML/Scripting/TemporaryExecutionContext.h

@@ -21,11 +21,11 @@ public:
         Yes,
         Yes,
     };
     };
 
 
-    explicit TemporaryExecutionContext(EnvironmentSettingsObject&, CallbacksEnabled = CallbacksEnabled::No);
+    explicit TemporaryExecutionContext(JS::Realm&, CallbacksEnabled = CallbacksEnabled::No);
     ~TemporaryExecutionContext();
     ~TemporaryExecutionContext();
 
 
 private:
 private:
-    JS::NonnullGCPtr<EnvironmentSettingsObject> m_environment_settings;
+    JS::NonnullGCPtr<JS::Realm> m_realm;
     CallbacksEnabled m_callbacks_enabled { CallbacksEnabled::No };
     CallbacksEnabled m_callbacks_enabled { CallbacksEnabled::No };
 };
 };
 
 

+ 1 - 2
Userland/Libraries/LibWeb/HTML/Window.cpp

@@ -1126,8 +1126,7 @@ WebIDL::ExceptionOr<void> Window::window_post_message_steps(JS::Value message, W
         auto& source = verify_cast<WindowProxy>(incumbent_settings.realm().global_environment().global_this_value());
         auto& source = verify_cast<WindowProxy>(incumbent_settings.realm().global_environment().global_this_value());
 
 
         // 4. Let deserializeRecord be StructuredDeserializeWithTransfer(serializeWithTransferResult, targetRealm).
         // 4. Let deserializeRecord be StructuredDeserializeWithTransfer(serializeWithTransferResult, targetRealm).
-        auto& settings_object = Bindings::host_defined_environment_settings_object(target_realm);
-        auto temporary_execution_context = TemporaryExecutionContext { settings_object };
+        auto temporary_execution_context = TemporaryExecutionContext { target_realm };
         auto deserialize_record_or_error = structured_deserialize_with_transfer(vm(), serialize_with_transfer_result);
         auto deserialize_record_or_error = structured_deserialize_with_transfer(vm(), serialize_with_transfer_result);
 
 
         // If this throws an exception, catch it, fire an event named messageerror at targetWindow, using MessageEvent,
         // If this throws an exception, catch it, fire an event named messageerror at targetWindow, using MessageEvent,

+ 5 - 5
Userland/Libraries/LibWeb/HTML/WindowOrWorkerGlobalScope.cpp

@@ -226,7 +226,7 @@ JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::create_image_b
                     // (e.g., a vector graphic with no natural size), then reject p with an "InvalidStateError" DOMException
                     // (e.g., a vector graphic with no natural size), then reject p with an "InvalidStateError" DOMException
                     // and abort these steps.
                     // and abort these steps.
                     auto& realm = relevant_realm(p->promise());
                     auto& realm = relevant_realm(p->promise());
-                    TemporaryExecutionContext context { relevant_settings_object(p->promise()), TemporaryExecutionContext::CallbacksEnabled::Yes };
+                    TemporaryExecutionContext context { relevant_realm(p->promise()), TemporaryExecutionContext::CallbacksEnabled::Yes };
                     WebIDL::reject_promise(realm, *p, WebIDL::InvalidStateError::create(realm, "image does not contain a supported image format"_string));
                     WebIDL::reject_promise(realm, *p, WebIDL::InvalidStateError::create(realm, "image does not contain a supported image format"_string));
                 };
                 };
 
 
@@ -240,7 +240,7 @@ JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::create_image_b
                     auto& realm = relevant_realm(p->promise());
                     auto& realm = relevant_realm(p->promise());
 
 
                     // 5. Resolve p with imageBitmap.
                     // 5. Resolve p with imageBitmap.
-                    TemporaryExecutionContext context { relevant_settings_object(*image_bitmap), TemporaryExecutionContext::CallbacksEnabled::Yes };
+                    TemporaryExecutionContext context { relevant_realm(*image_bitmap), TemporaryExecutionContext::CallbacksEnabled::Yes };
                     WebIDL::resolve_promise(realm, *p, image_bitmap);
                     WebIDL::resolve_promise(realm, *p, image_bitmap);
                     return {};
                     return {};
                 };
                 };
@@ -253,7 +253,7 @@ JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::create_image_b
             (void)sx;
             (void)sx;
             (void)sy;
             (void)sy;
             auto error = JS::Error::create(realm, "Not Implemented: createImageBitmap() for non-blob types"sv);
             auto error = JS::Error::create(realm, "Not Implemented: createImageBitmap() for non-blob types"sv);
-            TemporaryExecutionContext context { relevant_settings_object(p->promise()), TemporaryExecutionContext::CallbacksEnabled::Yes };
+            TemporaryExecutionContext context { relevant_realm(p->promise()), TemporaryExecutionContext::CallbacksEnabled::Yes };
             WebIDL::reject_promise(realm, *p, error);
             WebIDL::reject_promise(realm, *p, error);
         });
         });
 
 
@@ -416,7 +416,7 @@ i32 WindowOrWorkerGlobalScopeMixin::run_timer_initialization_steps(TimerHandler
     // 11. Let completionStep be an algorithm step which queues a global task on the timer task source given global to run task.
     // 11. Let completionStep be an algorithm step which queues a global task on the timer task source given global to run task.
     Function<void()> completion_step = [this, task = move(task)]() mutable {
     Function<void()> completion_step = [this, task = move(task)]() mutable {
         queue_global_task(Task::Source::TimerTask, this_impl(), JS::create_heap_function(this_impl().heap(), [this, task] {
         queue_global_task(Task::Source::TimerTask, this_impl(), JS::create_heap_function(this_impl().heap(), [this, task] {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(this_impl().realm()), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { this_impl().realm(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
             task->function()();
             task->function()();
         }));
         }));
     };
     };
@@ -587,7 +587,7 @@ void WindowOrWorkerGlobalScopeMixin::queue_the_performance_observer_task()
     //    timeline task source.
     //    timeline task source.
     queue_global_task(Task::Source::PerformanceTimeline, this_impl(), JS::create_heap_function(this_impl().heap(), [this]() {
     queue_global_task(Task::Source::PerformanceTimeline, this_impl(), JS::create_heap_function(this_impl().heap(), [this]() {
         auto& realm = this_impl().realm();
         auto& realm = this_impl().realm();
-        HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+        HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
         // 1. Unset performance observer task queued flag of relevantGlobal.
         // 1. Unset performance observer task queued flag of relevantGlobal.
         m_performance_observer_task_queued = false;
         m_performance_observer_task_queued = false;

+ 4 - 4
Userland/Libraries/LibWeb/Page/Page.cpp

@@ -477,7 +477,7 @@ WebIDL::ExceptionOr<void> Page::toggle_media_play_state()
         return {};
         return {};
 
 
     // AD-HOC: An execution context is required for Promise creation hooks.
     // AD-HOC: An execution context is required for Promise creation hooks.
-    HTML::TemporaryExecutionContext execution_context { media_element->document().relevant_settings_object() };
+    HTML::TemporaryExecutionContext execution_context { media_element->realm() };
 
 
     if (media_element->potentially_playing())
     if (media_element->potentially_playing())
         TRY(media_element->pause());
         TRY(media_element->pause());
@@ -494,7 +494,7 @@ void Page::toggle_media_mute_state()
         return;
         return;
 
 
     // AD-HOC: An execution context is required for Promise creation hooks.
     // AD-HOC: An execution context is required for Promise creation hooks.
-    HTML::TemporaryExecutionContext execution_context { media_element->document().relevant_settings_object() };
+    HTML::TemporaryExecutionContext execution_context { media_element->realm() };
 
 
     media_element->set_muted(!media_element->muted());
     media_element->set_muted(!media_element->muted());
 }
 }
@@ -506,7 +506,7 @@ WebIDL::ExceptionOr<void> Page::toggle_media_loop_state()
         return {};
         return {};
 
 
     // AD-HOC: An execution context is required for Promise creation hooks.
     // AD-HOC: An execution context is required for Promise creation hooks.
-    HTML::TemporaryExecutionContext execution_context { media_element->document().relevant_settings_object() };
+    HTML::TemporaryExecutionContext execution_context { media_element->realm() };
 
 
     if (media_element->has_attribute(HTML::AttributeNames::loop))
     if (media_element->has_attribute(HTML::AttributeNames::loop))
         media_element->remove_attribute(HTML::AttributeNames::loop);
         media_element->remove_attribute(HTML::AttributeNames::loop);
@@ -522,7 +522,7 @@ WebIDL::ExceptionOr<void> Page::toggle_media_controls_state()
     if (!media_element)
     if (!media_element)
         return {};
         return {};
 
 
-    HTML::TemporaryExecutionContext execution_context { media_element->document().relevant_settings_object() };
+    HTML::TemporaryExecutionContext execution_context { media_element->realm() };
 
 
     if (media_element->has_attribute(HTML::AttributeNames::controls))
     if (media_element->has_attribute(HTML::AttributeNames::controls))
         media_element->remove_attribute(HTML::AttributeNames::controls);
         media_element->remove_attribute(HTML::AttributeNames::controls);

+ 6 - 6
Userland/Libraries/LibWeb/ServiceWorker/Job.cpp

@@ -401,8 +401,8 @@ static void update(JS::VM& vm, JS::NonnullGCPtr<Job> job)
         // 16. If runResult is failure or an abrupt completion, then:
         // 16. If runResult is failure or an abrupt completion, then:
         // 17. Else, invoke Install algorithm with job, worker, and registration as its arguments.
         // 17. Else, invoke Install algorithm with job, worker, and registration as its arguments.
         if (job->client) {
         if (job->client) {
-            auto context = HTML::TemporaryExecutionContext(*job->client, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             auto& realm = *vm.current_realm();
             auto& realm = *vm.current_realm();
+            auto context = HTML::TemporaryExecutionContext(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             WebIDL::reject_promise(realm, *job->job_promise, *vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Run Service Worker"sv).value());
             WebIDL::reject_promise(realm, *job->job_promise, *vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Run Service Worker"sv).value());
             finish_job(vm, job);
             finish_job(vm, job);
         }
         }
@@ -428,8 +428,8 @@ static void unregister(JS::VM& vm, JS::NonnullGCPtr<Job> job)
 {
 {
     // If there's no client, there won't be any promises to resolve
     // If there's no client, there won't be any promises to resolve
     if (job->client) {
     if (job->client) {
-        auto context = HTML::TemporaryExecutionContext(*job->client, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         auto& realm = *vm.current_realm();
         auto& realm = *vm.current_realm();
+        auto context = HTML::TemporaryExecutionContext(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         WebIDL::reject_promise(realm, *job->job_promise, *vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Service Worker unregistration"sv).value());
         WebIDL::reject_promise(realm, *job->job_promise, *vm.throw_completion<JS::InternalError>(JS::ErrorType::NotImplemented, "Service Worker unregistration"sv).value());
         finish_job(vm, job);
         finish_job(vm, job);
     }
     }
@@ -497,7 +497,7 @@ static void resolve_job_promise(JS::NonnullGCPtr<Job> job, Optional<Registration
     if (job->client) {
     if (job->client) {
         auto& realm = job->client->realm();
         auto& realm = job->client->realm();
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, job, value] {
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, job, value] {
-            HTML::TemporaryExecutionContext const context(*job->client, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+            HTML::TemporaryExecutionContext const context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             // FIXME: Resolve to a ServiceWorkerRegistration platform object
             // FIXME: Resolve to a ServiceWorkerRegistration platform object
             // 1. Let convertedValue be null.
             // 1. Let convertedValue be null.
             // 2. If job’s job type is either register or update, set convertedValue to the result of
             // 2. If job’s job type is either register or update, set convertedValue to the result of
@@ -518,7 +518,7 @@ static void resolve_job_promise(JS::NonnullGCPtr<Job> job, Optional<Registration
         //    to run the following substeps:
         //    to run the following substeps:
         auto& realm = equivalent_job->client->realm();
         auto& realm = equivalent_job->client->realm();
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, equivalent_job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, equivalent_job, value] {
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, equivalent_job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, equivalent_job, value] {
-            HTML::TemporaryExecutionContext const context(*equivalent_job->client, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+            HTML::TemporaryExecutionContext const context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             // FIXME: Resolve to a ServiceWorkerRegistration platform object
             // FIXME: Resolve to a ServiceWorkerRegistration platform object
             // 1. Let convertedValue be null.
             // 1. Let convertedValue be null.
             // 2. If equivalentJob’s job type is either register or update, set convertedValue to the result of
             // 2. If equivalentJob’s job type is either register or update, set convertedValue to the result of
@@ -539,7 +539,7 @@ static void reject_job_promise(JS::NonnullGCPtr<Job> job, String message)
     if (job->client) {
     if (job->client) {
         auto& realm = job->client->realm();
         auto& realm = job->client->realm();
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, job, message] {
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, job, message] {
-            HTML::TemporaryExecutionContext const context(*job->client, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+            HTML::TemporaryExecutionContext const context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             WebIDL::reject_promise(realm, *job->job_promise, Error::create(realm, message));
             WebIDL::reject_promise(realm, *job->job_promise, Error::create(realm, message));
         }));
         }));
     }
     }
@@ -555,7 +555,7 @@ static void reject_job_promise(JS::NonnullGCPtr<Job> job, String message)
         //    in equivalentJob’s client's Realm.
         //    in equivalentJob’s client's Realm.
         auto& realm = equivalent_job->client->realm();
         auto& realm = equivalent_job->client->realm();
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, equivalent_job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, equivalent_job, message] {
         HTML::queue_a_task(HTML::Task::Source::DOMManipulation, equivalent_job->client->responsible_event_loop(), nullptr, JS::create_heap_function(realm.heap(), [&realm, equivalent_job, message] {
-            HTML::TemporaryExecutionContext const context(*equivalent_job->client, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+            HTML::TemporaryExecutionContext const context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             WebIDL::reject_promise(realm, *equivalent_job->job_promise, Error::create(realm, message));
             WebIDL::reject_promise(realm, *equivalent_job->job_promise, Error::create(realm, message));
         }));
         }));
     }
     }

+ 3 - 3
Userland/Libraries/LibWeb/Streams/AbstractOperations.cpp

@@ -402,7 +402,7 @@ public:
     {
     {
         // 1. Queue a microtask to perform the following steps:
         // 1. Queue a microtask to perform the following steps:
         HTML::queue_a_microtask(nullptr, JS::create_heap_function(m_realm->heap(), [this, chunk]() {
         HTML::queue_a_microtask(nullptr, JS::create_heap_function(m_realm->heap(), [this, chunk]() {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(m_realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+            HTML::TemporaryExecutionContext execution_context { m_realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
             auto controller1 = m_params->branch1->controller()->get<JS::NonnullGCPtr<ReadableStreamDefaultController>>();
             auto controller1 = m_params->branch1->controller()->get<JS::NonnullGCPtr<ReadableStreamDefaultController>>();
             auto controller2 = m_params->branch2->controller()->get<JS::NonnullGCPtr<ReadableStreamDefaultController>>();
             auto controller2 = m_params->branch2->controller()->get<JS::NonnullGCPtr<ReadableStreamDefaultController>>();
@@ -709,7 +709,7 @@ public:
     {
     {
         // 1. Queue a microtask to perform the following steps:
         // 1. Queue a microtask to perform the following steps:
         HTML::queue_a_microtask(nullptr, JS::create_heap_function(m_realm->heap(), [this, chunk]() mutable {
         HTML::queue_a_microtask(nullptr, JS::create_heap_function(m_realm->heap(), [this, chunk]() mutable {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(m_realm) };
+            HTML::TemporaryExecutionContext execution_context { m_realm };
 
 
             auto controller1 = m_params->branch1->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();
             auto controller1 = m_params->branch1->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();
             auto controller2 = m_params->branch2->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();
             auto controller2 = m_params->branch2->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();
@@ -872,7 +872,7 @@ public:
 
 
         // 1. Queue a microtask to perform the following steps:
         // 1. Queue a microtask to perform the following steps:
         HTML::queue_a_microtask(nullptr, JS::create_heap_function(m_realm->heap(), [this, chunk = chunk_view]() {
         HTML::queue_a_microtask(nullptr, JS::create_heap_function(m_realm->heap(), [this, chunk = chunk_view]() {
-            HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(m_realm) };
+            HTML::TemporaryExecutionContext execution_context { m_realm };
 
 
             auto byob_controller = m_byob_branch->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();
             auto byob_controller = m_byob_branch->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();
             auto other_controller = m_other_branch->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();
             auto other_controller = m_other_branch->controller()->get<JS::NonnullGCPtr<ReadableByteStreamController>>();

+ 6 - 6
Userland/Libraries/LibWeb/WebAssembly/WebAssembly.cpp

@@ -506,14 +506,14 @@ JS::NonnullGCPtr<WebIDL::Promise> asynchronously_compile_webassembly_module(JS::
     auto promise = WebIDL::create_promise(realm);
     auto promise = WebIDL::create_promise(realm);
 
 
     // 2. Run the following steps in parallel:
     // 2. Run the following steps in parallel:
-    Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(vm.heap(), [&vm, bytes = move(bytes), promise, task_source]() mutable {
-        HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*promise->promise()), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+    Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(vm.heap(), [&vm, &realm, bytes = move(bytes), promise, task_source]() mutable {
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         // 1. Compile the WebAssembly module bytes and store the result as module.
         // 1. Compile the WebAssembly module bytes and store the result as module.
         auto module_or_error = Detail::compile_a_webassembly_module(vm, move(bytes));
         auto module_or_error = Detail::compile_a_webassembly_module(vm, move(bytes));
 
 
         // 2. Queue a task to perform the following steps. If taskSource was provided, queue the task on that task source.
         // 2. Queue a task to perform the following steps. If taskSource was provided, queue the task on that task source.
-        HTML::queue_a_task(task_source, nullptr, nullptr, JS::create_heap_function(vm.heap(), [&vm, promise, module_or_error = move(module_or_error)]() mutable {
-            HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*promise->promise()), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::queue_a_task(task_source, nullptr, nullptr, JS::create_heap_function(vm.heap(), [&vm, &realm, promise, module_or_error = move(module_or_error)]() mutable {
+            HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
             auto& realm = HTML::relevant_realm(*promise->promise());
             auto& realm = HTML::relevant_realm(*promise->promise());
 
 
             // 1. If module is error, reject promise with a CompileError exception.
             // 1. If module is error, reject promise with a CompileError exception.
@@ -554,8 +554,8 @@ JS::NonnullGCPtr<WebIDL::Promise> asynchronously_instantiate_webassembly_module(
 
 
     // 4. Run the following steps in parallel:
     // 4. Run the following steps in parallel:
     //   1. Queue a task to perform the following steps: Note: Implementation-specific work may be performed here.
     //   1. Queue a task to perform the following steps: Note: Implementation-specific work may be performed here.
-    HTML::queue_a_task(HTML::Task::Source::Unspecified, nullptr, nullptr, JS::create_heap_function(vm.heap(), [&vm, promise, module, import_object]() {
-        HTML::TemporaryExecutionContext context(HTML::relevant_settings_object(*promise->promise()), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+    HTML::queue_a_task(HTML::Task::Source::Unspecified, nullptr, nullptr, JS::create_heap_function(vm.heap(), [&vm, &realm, promise, module, import_object]() {
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
         auto& realm = HTML::relevant_realm(*promise->promise());
         auto& realm = HTML::relevant_realm(*promise->promise());
 
 
         // 1. Instantiate the core of a WebAssembly module module with imports, and let instance be the result.
         // 1. Instantiate the core of a WebAssembly module module with imports, and let instance be the result.

+ 4 - 4
Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp

@@ -146,7 +146,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> AudioContext::resume()
     if (!start_rendering_audio_graph()) {
     if (!start_rendering_audio_graph()) {
         // 7.4: In case of failure, queue a media element task to execute the following steps:
         // 7.4: In case of failure, queue a media element task to execute the following steps:
         queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, this]() {
         queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, this]() {
-            HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+            HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
 
 
             // 7.4.1: Reject all promises from [[pending resume promises]] in order, then clear [[pending resume promises]].
             // 7.4.1: Reject all promises from [[pending resume promises]] in order, then clear [[pending resume promises]].
             for (auto const& promise : m_pending_resume_promises) {
             for (auto const& promise : m_pending_resume_promises) {
@@ -163,7 +163,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> AudioContext::resume()
 
 
     // 7.5: queue a media element task to execute the following steps:
     // 7.5: queue a media element task to execute the following steps:
     queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, promise, this]() {
     queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, promise, this]() {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
 
 
         // 7.5.1: Resolve all promises from [[pending resume promises]] in order.
         // 7.5.1: Resolve all promises from [[pending resume promises]] in order.
         // 7.5.2: Clear [[pending resume promises]]. Additionally, remove those promises from
         // 7.5.2: Clear [[pending resume promises]]. Additionally, remove those promises from
@@ -233,7 +233,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> AudioContext::suspend()
 
 
     // 7.3: queue a media element task to execute the following steps:
     // 7.3: queue a media element task to execute the following steps:
     queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, promise, this]() {
     queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, promise, this]() {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
 
 
         // 7.3.1: Resolve promise.
         // 7.3.1: Resolve promise.
         WebIDL::resolve_promise(realm, promise, JS::js_undefined());
         WebIDL::resolve_promise(realm, promise, JS::js_undefined());
@@ -288,7 +288,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<WebIDL::Promise>> AudioContext::close()
 
 
     // 5.4: queue a media element task to execute the following steps:
     // 5.4: queue a media element task to execute the following steps:
     queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, promise, this]() {
     queue_a_media_element_task(JS::create_heap_function(heap(), [&realm, promise, this]() {
-        HTML::TemporaryExecutionContext context(Bindings::host_defined_environment_settings_object(realm), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
+        HTML::TemporaryExecutionContext context(realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes);
 
 
         // 5.4.1: Resolve promise.
         // 5.4.1: Resolve promise.
         WebIDL::resolve_promise(realm, promise, JS::js_undefined());
         WebIDL::resolve_promise(realm, promise, JS::js_undefined());

+ 6 - 6
Userland/Libraries/LibWeb/WebDriver/ExecuteScript.cpp

@@ -340,14 +340,14 @@ void execute_script(HTML::BrowsingContext const& browsing_context, ByteString bo
     }
     }
 
 
     // AD-HOC: An execution context is required for Promise creation hooks.
     // AD-HOC: An execution context is required for Promise creation hooks.
-    HTML::TemporaryExecutionContext execution_context { document->relevant_settings_object(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+    HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
     // 7. Let promise be a new Promise.
     // 7. Let promise be a new Promise.
     auto promise = WebIDL::create_promise(realm);
     auto promise = WebIDL::create_promise(realm);
 
 
     // 8. Run the following substeps in parallel:
     // 8. Run the following substeps in parallel:
-    Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, &browsing_context, promise, document, body = move(body), arguments = move(arguments)]() mutable {
-        HTML::TemporaryExecutionContext execution_context { document->relevant_settings_object() };
+    Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&realm, &browsing_context, promise, body = move(body), arguments = move(arguments)]() mutable {
+        HTML::TemporaryExecutionContext execution_context { realm };
 
 
         // 1. Let scriptPromise be the result of promise-calling execute a function body, with arguments body and arguments.
         // 1. Let scriptPromise be the result of promise-calling execute a function body, with arguments body and arguments.
         auto script_result = execute_a_function_body(browsing_context, body, move(arguments));
         auto script_result = execute_a_function_body(browsing_context, body, move(arguments));
@@ -418,15 +418,15 @@ void execute_async_script(HTML::BrowsingContext const& browsing_context, ByteStr
     }
     }
 
 
     // AD-HOC: An execution context is required for Promise creation hooks.
     // AD-HOC: An execution context is required for Promise creation hooks.
-    HTML::TemporaryExecutionContext execution_context { document->relevant_settings_object(), HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
+    HTML::TemporaryExecutionContext execution_context { realm, HTML::TemporaryExecutionContext::CallbacksEnabled::Yes };
 
 
     // 7. Let promise be a new Promise.
     // 7. Let promise be a new Promise.
     auto promise_capability = WebIDL::create_promise(realm);
     auto promise_capability = WebIDL::create_promise(realm);
     JS::NonnullGCPtr promise { verify_cast<JS::Promise>(*promise_capability->promise()) };
     JS::NonnullGCPtr promise { verify_cast<JS::Promise>(*promise_capability->promise()) };
 
 
     // 8. Run the following substeps in parallel:
     // 8. Run the following substeps in parallel:
-    Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&vm, &realm, &browsing_context, timer, document, promise_capability, promise, body = move(body), arguments = move(arguments)]() mutable {
-        HTML::TemporaryExecutionContext execution_context { document->relevant_settings_object() };
+    Platform::EventLoopPlugin::the().deferred_invoke(JS::create_heap_function(realm.heap(), [&vm, &realm, &browsing_context, timer, promise_capability, promise, body = move(body), arguments = move(arguments)]() mutable {
+        HTML::TemporaryExecutionContext execution_context { realm };
 
 
         // 1. Let resolvingFunctions be CreateResolvingFunctions(promise).
         // 1. Let resolvingFunctions be CreateResolvingFunctions(promise).
         auto resolving_functions = promise->create_resolving_functions();
         auto resolving_functions = promise->create_resolving_functions();

+ 3 - 3
Userland/Services/WebContent/WebDriverConnection.cpp

@@ -504,7 +504,7 @@ Messages::WebDriverClient::NewWindowResponse WebDriverConnection::new_window(Jso
     auto* active_window = current_browsing_context().active_window();
     auto* active_window = current_browsing_context().active_window();
     VERIFY(active_window);
     VERIFY(active_window);
 
 
-    Web::HTML::TemporaryExecutionContext execution_context { active_window->document()->relevant_settings_object() };
+    Web::HTML::TemporaryExecutionContext execution_context { active_window->document()->realm() };
     auto [target_navigable, no_opener, window_type] = MUST(active_window->window_open_steps_internal("about:blank"sv, ""sv, "noopener"sv));
     auto [target_navigable, no_opener, window_type] = MUST(active_window->window_open_steps_internal("about:blank"sv, ""sv, "noopener"sv));
 
 
     // 6. Let handle be the associated window handle of the newly created window.
     // 6. Let handle be the associated window handle of the newly created window.
@@ -1175,7 +1175,7 @@ Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_e
     Optional<ByteString> result;
     Optional<ByteString> result;
 
 
     // 4. Let property be the result of calling the Object.[[GetProperty]](name) on element.
     // 4. Let property be the result of calling the Object.[[GetProperty]](name) on element.
-    Web::HTML::TemporaryExecutionContext execution_context { current_browsing_context().active_document()->relevant_settings_object() };
+    Web::HTML::TemporaryExecutionContext execution_context { current_browsing_context().active_document()->realm() };
 
 
     if (auto property_or_error = element->get(name.to_byte_string()); !property_or_error.is_throw_completion()) {
     if (auto property_or_error = element->get(name.to_byte_string()); !property_or_error.is_throw_completion()) {
         auto property = property_or_error.release_value();
         auto property = property_or_error.release_value();
@@ -2787,7 +2787,7 @@ static ErrorOr<JS::Value, Web::WebDriver::Error> json_deserialize(JS::VM& vm, We
 ErrorOr<WebDriverConnection::ScriptArguments, Web::WebDriver::Error> WebDriverConnection::extract_the_script_arguments_from_a_request(JS::VM& vm, JsonValue const& payload)
 ErrorOr<WebDriverConnection::ScriptArguments, Web::WebDriver::Error> WebDriverConnection::extract_the_script_arguments_from_a_request(JS::VM& vm, JsonValue const& payload)
 {
 {
     // Creating JSON objects below requires an execution context.
     // Creating JSON objects below requires an execution context.
-    Web::HTML::TemporaryExecutionContext execution_context { current_browsing_context().active_document()->relevant_settings_object() };
+    Web::HTML::TemporaryExecutionContext execution_context { current_browsing_context().active_document()->realm() };
 
 
     // 1. Let script be the result of getting a property named script from the parameters.
     // 1. Let script be the result of getting a property named script from the parameters.
     // 2. If script is not a String, return error with error code invalid argument.
     // 2. If script is not a String, return error with error code invalid argument.