From 4dcf4ef07acef181046e4fc4861a12dc324e6dfa Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Tue, 2 Sep 2025 23:05:35 -0700 Subject: [PATCH] Fix step ordering for MicrotaskQueue checkpoint (#39099) The steps were incorrectly numbered, this PR fixes that and copies over the description of each step. Testing: None, just expanding on the comments/fixing the step numbering --------- Signed-off-by: Ashwin Naren Co-authored-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> --- components/script/microtask.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/components/script/microtask.rs b/components/script/microtask.rs index b0608baf7c5..f1c49f7ba18 100644 --- a/components/script/microtask.rs +++ b/components/script/microtask.rs @@ -93,16 +93,17 @@ impl MicrotaskQueue { ) where F: Fn(PipelineId) -> Option>, { + // Step 1. If the event loop's performing a microtask checkpoint is true, then return. if self.performing_a_microtask_checkpoint.get() { return; } - // Step 1 + // Step 2. Set the event loop's performing a microtask checkpoint to true. self.performing_a_microtask_checkpoint.set(true); debug!("Now performing a microtask checkpoint"); - // Steps 2 + // Step 3. While the event loop's microtask queue is not empty: while !self.microtask_queue.borrow().is_empty() { rooted_vec!(let mut pending_queue); mem::swap(&mut *pending_queue, &mut *self.microtask_queue.borrow_mut()); @@ -154,15 +155,20 @@ impl MicrotaskQueue { } } - // Step 3 + // Step 4. For each environment settings object settingsObject whose responsible + // event loop is this event loop, notify about rejected promises given + // settingsObject's global object. for global in globalscopes.into_iter() { notify_about_rejected_promises(&global); } - // TODO: Step 4 - Cleanup Indexed Database transactions. + // TODO: Step 5. Cleanup Indexed Database transactions. - // Step 5 + // TODO: Step 6. Perform ClearKeptObjects(). + + // Step 7. Set the event loop's performing a microtask checkpoint to false. self.performing_a_microtask_checkpoint.set(false); + // TODO: Step 8. Record timing info for microtask checkpoint. } pub(crate) fn empty(&self) -> bool {