1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

LibWeb: Set a TemporaryExecutionContext when finishing module loads

I'm not entirely sure why this is needed, but it's the same ol'
workaround we're using in a bazillion places where we get caught trying
to do JavaScripty things without a running execution context.
This commit is contained in:
Andreas Kling 2023-12-03 15:12:09 +01:00
parent 58294db294
commit 62361e40a1

View file

@ -35,6 +35,7 @@
#include <LibWeb/HTML/Scripting/Fetching.h>
#include <LibWeb/HTML/Scripting/ModuleScript.h>
#include <LibWeb/HTML/Scripting/Script.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
#include <LibWeb/HTML/TagNames.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/HTML/WindowProxy.h>
@ -450,6 +451,7 @@ ErrorOr<void> initialize_main_thread_vm()
auto completion = dom_exception_to_throw_completion(main_thread_vm(), url.exception());
// 2. Perform FinishLoadingImportedModule(referrer, moduleRequest, payload, completion).
HTML::TemporaryExecutionContext context { host_defined_environment_settings_object(realm) };
JS::finish_loading_imported_module(referrer, module_request, payload, completion);
// 3. Return.
@ -508,6 +510,7 @@ ErrorOr<void> initialize_main_thread_vm()
}();
// 5. Perform FinishLoadingImportedModule(referrer, moduleRequest, payload, completion).
HTML::TemporaryExecutionContext context { host_defined_environment_settings_object(realm) };
JS::finish_loading_imported_module(referrer, module_request, payload, completion);
});