diff options
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 69c07deaae..2d6ade6c5d 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -625,6 +625,11 @@ JS::Interpreter& Document::interpreter() { if (!m_interpreter) { auto& vm = Bindings::main_thread_vm(); + m_interpreter = JS::Interpreter::create<Bindings::WindowObject>(vm, *m_window); + + // NOTE: We must hook `on_call_stack_emptied` after the interpreter was created, as the initialization of the + // WindowsObject can invoke some internal calls, which will eventually lead to this hook being called without + // `m_interpreter` being fully initialized yet. // TODO: Hook up vm.on_promise_unhandled_rejection and vm.on_promise_rejection_handled // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#promise_rejection_events vm.on_call_stack_emptied = [this] { @@ -659,7 +664,6 @@ JS::Interpreter& Document::interpreter() vm.finish_execution_generation(); }; - m_interpreter = JS::Interpreter::create<Bindings::WindowObject>(vm, *m_window); } return *m_interpreter; } |