diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index e8432f0d5e..57cbd7501e 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -286,6 +286,12 @@ JS::VM& main_thread_vm() vm->host_resolve_imported_module = [&](JS::ScriptOrModule, JS::ModuleRequest const&) -> JS::ThrowCompletionOr> { return vm->throw_completion(vm->current_realm()->global_object(), JS::ErrorType::NotImplemented, "Modules in the browser"); }; + + // NOTE: We push a dummy execution context onto the JS execution context stack, + // just to make sure that it's never empty. + auto& custom_data = *verify_cast(vm->custom_data()); + custom_data.root_execution_context = make(vm->heap()); + vm->push_execution_context(*custom_data.root_execution_context); } return *vm; } diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h index a085543d6e..686ce3ccb1 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h @@ -29,6 +29,8 @@ struct WebEngineCustomData final : public JS::VM::CustomData { // https://dom.spec.whatwg.org/#mutation-observer-list // FIXME: This should be a set. NonnullRefPtrVector mutation_observers; + + OwnPtr root_execution_context; }; struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData {