Bug 140043 - js/dom/Promise.html is flaky
Summary: js/dom/Promise.html is flaky
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 147933
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-02 10:20 PST by Alexey Proskuryakov
Modified: 2017-01-18 16:34 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2015-01-02 10:20:28 PST
js/dom/Promise.html is flaky, frequently failing in debug builds. Not sure if it's a test deficiency, or a legitimate bug.

About to run test - promiseAsync
PASS foo is foo
PASS foo is foo
PASS foo is foo
FAIL foo should be bar
Comment 1 Alexey Proskuryakov 2015-01-02 10:32:51 PST
Marked as flaky in <http://trac.webkit.org/r177865>.
Comment 2 Alexey Proskuryakov 2015-01-02 10:36:29 PST
Are promise and setTimeout timers on different event queues?

function promiseAsync() {
  var global = "foo";
  var f = new Promise(function(r1, r2) {
    is(global, "foo", "Global should be foo");
    r1(42);
    is(global, "foo", "Global should still be foo");
    setTimeout(function() {
      is(global, "bar", "Global should still be bar!");
      runTest();
    }, 0);
  }).then(function() {
    global = "bar";
  });
  is(global, "foo", "Global should still be foo (2)");
}
Comment 3 Sam Weinig 2015-01-02 17:34:01 PST
(In reply to comment #2)
> Are promise and setTimeout timers on different event queues?

They are...kind of.
Comment 4 Sam Weinig 2015-01-02 17:39:47 PST
(In reply to comment #3)
> (In reply to comment #2)
> > Are promise and setTimeout timers on different event queues?
> 
> They are...kind of.

I don't think anything in our implementation ensures this ordering, but it really should. This is a great example of why it would be great if we have a unified event loop mechanism.

In this case, the bug is that the .then() should run at the next microtask checkpoint, which is defined as being before the next chance for a timer to fire. Our implementation of Promises does not use the microtask checkpoint, but rather uses ScriptExecutionContext::postTask() mechanism, which is not quite the same thing.