This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
There's a problem with how we are defining microtasks and callbacks run from a queued task. http://software.hixie.ch/utilities/js/live-dom-viewer/saved/3379 <!DOCTYPE html> .<script> new MutationObserver(function() { w(2) }).observe(document.body, {attributes:true}) document.body.addEventListener("mousemove", function() { w(1) document.body.setAttribute("test", "x") }) document.body.addEventListener("mousemove", function() { w(3) }) document.body.dispatchEvent(new Event("mousemove")) </script> The dispatchEvent() method does not queue a task and therefore the order is 1, 3, 2. However, if you move the mouse around in the document the order is 1, 2, 3. We are not capturing this at all. Ian suggested IDL needs to invoke HTML's "clean up after running a callback" from IDL's "Invoking callback functions" section. However, that will not do the right thing as that would make the order 1, 2, 3 either way. Related bugs: * bug 18242 * bug 24403 * bug 25138
And the problem is?
I would add some hook to webidl spec, which then HTML spec used to explain when to run end-of-microtask callbacks.
(In reply to Anne from comment #0) > Ian suggested IDL needs to invoke HTML's "clean up after running a callback" > from IDL's "Invoking callback functions" section. However, that will not do > the right thing as that would make the order 1, 2, 3 either way. Ian's suggestion seems fine to me. The language of the "clean up" stuff that runs microtasks is: "3. If the stack of script settings objects is now empty, perform a microtask checkpoint." It's the first part of that clause which causes the two different orderings. I don't think there's any new bug here, just the same old one that WebIDL needs to be invoking callbacks via HTML spec methods.
This was fixed in https://github.com/heycam/webidl/pull/113; Web IDL now calls HTML's prepare/cleanup steps for running script in its four callback-invoking algorithms.