Closed Bug 1833402 Opened 2 years ago Closed 1 year ago

Returning promise from C++ automatically blocks microtasks on Gecko but not on Blink?

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

RESOLVED FIXED

People

(Reporter: saschanaz, Unassigned)

References

Details

(Keywords: parity-chrome, parity-safari, Whiteboard: webcompat:risk-moderate )

Attachments

(1 file)

Attached file repro.html

During investigation in bug 1819086 I found that somehow returning Promises from C++ can automatically trigger nsAutoMicroTask via PromiseBinding (then again via CallbackObject::CallSetup). Is this a Gecko quirk or is it in any spec?

Both Blink and WebKit does run microtask in the above code (logs "shouldn't have run microtasks yet" ... because the code is copied from bug 1612308), while Gecko logs "Did not run microtask".

Hi Peter, is this something you can answer? Thanks!

Flags: needinfo?(peterv)

(For now I marked it as defect as it's a web-visible difference, but not sure it really is a defect)

What does "blocks" mean in this context?

"Prevents microtask runs (but let it run later, of course)" it means.

The testcase talks about fetch., but I don't see any fetch usage.
Anyhow, JS shouldn't be able to trigger microtask checkpoint in middle of JS execution.
Microtasks run at the end of the outermost JS execution or at the end of the innermost task (if there is no JS running)

That's my fault and those are just copied from the testcase in bug 1612308. 😬

Anyhow, JS shouldn't be able to trigger microtask checkpoint in middle of JS execution.

Practically yes but I don't think that's what others do here, what spec actually forces it?

That's supposed to be called when running script, but in the repro code permissions.query() does not call any script, right?

It does call a script, the then callback, no? So there is script on the stack and microtask checkpoint shouldn't happen.

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #9)

It does call a script, the then callback, no?

Not sure I understand, yes it does call a script but that's because of .then quirk of promise resolution, isn't it? Is there anything left for the IDL to do at that point?

Whiteboard: webcompat:risk-moderate
Status: NEW → RESOLVED
Closed: 1 year ago
Flags: needinfo?(peterv)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: