diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index fc6dc43007..2327bdad7c 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -543,8 +543,12 @@ Color Document::visited_link_color() const JS::Interpreter& Document::interpreter() { - if (!m_interpreter) - m_interpreter = JS::Interpreter::create(Bindings::main_thread_vm(), *m_window); + if (!m_interpreter) { + auto& vm = Bindings::main_thread_vm(); + // 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 + m_interpreter = JS::Interpreter::create(vm, *m_window); + } return *m_interpreter; } diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp index 1ec7f8b96b..0c896be51c 100644 --- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -114,6 +114,8 @@ bool EventDispatcher::inner_invoke(Event& event, Vector(global)) { diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp index 52607e2ab8..aa76a90c81 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.cpp +++ b/Userland/Libraries/LibWeb/DOM/Window.cpp @@ -109,6 +109,8 @@ void Window::timer_did_fire(Badge, Timer& timer) [[maybe_unused]] auto rc = vm.call(timer.callback(), wrapper()); if (vm.exception()) vm.clear_exception(); + vm.run_queued_promise_jobs(); + VERIFY(!vm.exception()); } i32 Window::allocate_timer_id(Badge) @@ -143,6 +145,8 @@ i32 Window::request_animation_frame(JS::Function& callback) [[maybe_unused]] auto rc = vm.call(function, JS::js_undefined(), JS::Value(fake_timestamp)); if (vm.exception()) vm.clear_exception(); + vm.run_queued_promise_jobs(); + VERIFY(!vm.exception()); GUI::DisplayLink::unregister_callback(link_id); });