LibWeb/HTML: Assert microtasks invoked on empty execution context stack

This a requirement from the ECMA-262 spec.
This commit is contained in:
Shannon Booth 2025-01-03 12:10:53 +13:00 committed by Andreas Kling
parent ee1b2dced3
commit 34b8a9ab75
Notes: github-actions[bot] 2025-01-03 10:00:13 +00:00

View file

@ -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;