summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-04 12:10:27 +0300
committerAndreas Kling <kling@serenityos.org>2021-07-04 14:23:25 +0200
commit2f60508ae01ee7ab9aaa5b7c4beb0de9800dda28 (patch)
tree2cfedf932076e4eb2847cedc72fce46154884786 /Userland/Libraries
parentd73f53d1de6aeba2d5c8290c8a1b1b9e5bc9cc99 (diff)
downloadserenity-2f60508ae01ee7ab9aaa5b7c4beb0de9800dda28.zip
LibWeb: Hook on_call_stack_emptied after m_interpreter was initialized
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp6
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;
}