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 <arihant2math@gmail.com>
Co-authored-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
This commit is contained in:
Ashwin Naren 2025-09-02 23:05:35 -07:00 committed by GitHub
parent 9c840b05bc
commit 4dcf4ef07a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -93,16 +93,17 @@ impl MicrotaskQueue {
) where ) where
F: Fn(PipelineId) -> Option<DomRoot<GlobalScope>>, F: Fn(PipelineId) -> Option<DomRoot<GlobalScope>>,
{ {
// Step 1. If the event loop's performing a microtask checkpoint is true, then return.
if self.performing_a_microtask_checkpoint.get() { if self.performing_a_microtask_checkpoint.get() {
return; return;
} }
// Step 1 // Step 2. Set the event loop's performing a microtask checkpoint to true.
self.performing_a_microtask_checkpoint.set(true); self.performing_a_microtask_checkpoint.set(true);
debug!("Now performing a microtask checkpoint"); 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() { while !self.microtask_queue.borrow().is_empty() {
rooted_vec!(let mut pending_queue); rooted_vec!(let mut pending_queue);
mem::swap(&mut *pending_queue, &mut *self.microtask_queue.borrow_mut()); 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() { for global in globalscopes.into_iter() {
notify_about_rejected_promises(&global); 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); self.performing_a_microtask_checkpoint.set(false);
// TODO: Step 8. Record timing info for microtask checkpoint.
} }
pub(crate) fn empty(&self) -> bool { pub(crate) fn empty(&self) -> bool {