From 34b8a9ab759286f0a50b5f6b028595c5872088a4 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Fri, 3 Jan 2025 12:10:53 +1300 Subject: [PATCH] LibWeb/HTML: Assert microtasks invoked on empty execution context stack This a requirement from the ECMA-262 spec. --- Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp index af711d4c831..8ce8c2936d4 100644 --- a/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp +++ b/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp @@ -473,6 +473,10 @@ void perform_a_microtask_checkpoint() // https://html.spec.whatwg.org/#perform-a-microtask-checkpoint void EventLoop::perform_a_microtask_checkpoint() { + // NOTE: This assertion is per requirement 9.5 of the ECMA-262 spec, see: https://tc39.es/ecma262/#sec-jobs + // > At some future point in time, when there is no running context in the agent for which the job is scheduled and that agent's execution context stack is empty... + VERIFY(vm().execution_context_stack().is_empty()); + // 1. If the event loop's performing a microtask checkpoint is true, then return. if (m_performing_a_microtask_checkpoint) return;