Closed Bug 1038631 Opened 5 years ago Closed 5 years ago

Promises should run before setTimeout

Categories

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

33 Branch
x86_64
Linux
defect
Not set

Tracking

()

RESOLVED DUPLICATE of bug 1013625

People

(Reporter: floitsch, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.3 Safari/537.36

Steps to reproduce:

var p = Promise.resolve();
// Give promise time to resolve.
window.setTimeout(function() {
  // Schedule 
  window.setTimeout(function() {console.log("foo"); }, 0);
  // Delay current function.
  var str = ""; for(var i = 0; i < 1000000; i++) { str += i; } glob = str;
  // Schedule on promise.
  p.then(function() {console.log("bar"); });
}, 10);


Actual results:

Prints:
"foo"
"bar"


Expected results:

Prints:
"bar"
"foo"

Functions scheduled through a resolved promise should be executed before setTimeouts.

Potentially related: issue 1013625
Blocks: 1013625
Component: Untriaged → DOM
Product: Firefox → Core
Confirmed in 33.0a1 (2014-07-20), Win 7
Status: UNCONFIRMED → NEW
Ever confirmed: true
Dependency is wrong way around.  I think this is exactly a duplicate of bug 1013625, in fact; it's caused by promise resolutions running off the same event queue as timeout handlers.
No longer blocks: 1013625
Depends on: 1013625
If there's a good way for me to help with this, please, let me know.  I assumed that promises running alongside timeouts was the intended procedure, and wrote a fair bit of code to work around that.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1013625
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.