summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/Scripting
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-10-02 23:23:30 +0200
committerAndreas Kling <kling@serenityos.org>2022-10-06 16:41:36 +0200
commita182bc98067740e2465827100c1ab5e97762200d (patch)
treeb1b5e991d499bd87375421644c4a252f87a6a786 /Userland/Libraries/LibWeb/HTML/Scripting
parentf92d95224e1b00e4e15f2eb2b10fb4784283b83c (diff)
downloadserenity-a182bc98067740e2465827100c1ab5e97762200d.zip
LibWeb: Push the realm execution context before linking modules
This patch adds a non standard step pushing the realm execution context of fetching client's settings object onto the execution context stack before linking a module script. Without the realm execution context there is no current settings object, leading to a crash in HostResolveImportedModule.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/Scripting')
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp
index 709b5f734a..2e7492729c 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp
@@ -309,7 +309,7 @@ void fetch_descendants_of_and_link_a_module_script(JavaScriptModuleScript const&
// 1. Fetch the descendants of module script, given fetch client settings object, destination, visited set, and onFetchDescendantsComplete as defined below.
// If performFetch was given, pass it along as well.
// FIXME: Pass performFetch if given.
- fetch_descendants_of_a_module_script(module_script, fetch_client_settings_object, destination, visited_set, [on_complete = move(on_complete)](JavaScriptModuleScript const* result) {
+ fetch_descendants_of_a_module_script(module_script, fetch_client_settings_object, destination, visited_set, [&fetch_client_settings_object, on_complete = move(on_complete)](JavaScriptModuleScript const* result) {
// onFetchDescendantsComplete given result is the following algorithm:
// 1. If result is null, then run onComplete given result, and abort these steps.
if (!result) {
@@ -324,9 +324,15 @@ void fetch_descendants_of_and_link_a_module_script(JavaScriptModuleScript const&
// 1. Let record be result's record.
auto const& record = *result->record();
+ // NOTE: Although the spec does not say this we have to have a proper execution context when linking so we modify the stack here.
+ // FIXME: Determine whether we are missing something from the spec or the spec is missing this step.
+ fetch_client_settings_object.realm().vm().push_execution_context(fetch_client_settings_object.realm_execution_context());
+
// 2. Perform record.Link().
auto linking_result = const_cast<JS::SourceTextModule&>(record).link(result->vm());
+ fetch_client_settings_object.realm().vm().pop_execution_context();
+
// TODO: If this throws an exception, set result's error to rethrow to that exception.
if (linking_result.is_error())
TODO();