Bug 1023547 - Fix intermittent dom/workers/test/test_promise.html failure. r=bz, a=test-only
authorNikhil Marathe <nsm.nikhil@gmail.com>
Fri, 18 Jul 2014 18:13:47 -0700
changeset 209225 4bd4b0ae7bbe709089afd8b4eded0ab74a9aec81
parent 209224 d0bb536942e27651a83d43cf2b251d39107815fe
child 209226 77a61c7d8e80d5b620834b84b62302de4f671e7e
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, test-only
bugs1023547
milestone32.0a2
Bug 1023547 - Fix intermittent dom/workers/test/test_promise.html failure. r=bz, a=test-only
dom/promise/tests/test_promise.html
dom/workers/test/promise_worker.js
--- a/dom/promise/tests/test_promise.html
+++ b/dom/promise/tests/test_promise.html
@@ -625,27 +625,30 @@ function promiseResolvePromise() {
 function promiseResolveThenableCleanStack() {
   function immed(s) { x++; s(); }
   function incX(){ x++; }
 
   var x = 0;
   var thenable = { then: immed };
   var results = [];
 
-  Promise.resolve(thenable).then(incX);
+  var p = Promise.resolve(thenable).then(incX);
   results.push(x);
 
   // check what happens after all "next cycle" steps
   // have had a chance to complete
   setTimeout(function(){
-    results.push(x);
     // Result should be [0, 2] since `thenable` will be called async.
     is(results[0], 0, "Expected thenable to be called asynchronously");
-    is(results[1], 2, "Expected thenable to be called asynchronously");
-    runTest();
+    // See Bug 1023547 comment 13 for why this check has to be gated on p.
+    p.then(function() {
+      results.push(x);
+      is(results[1], 2, "Expected thenable to be called asynchronously");
+      runTest();
+    });
   },1000);
 }
 
 // Bug 1008467 - Promise fails with "too much recursion".
 // The bug was that the callbacks passed to a thenable would resolve the
 // promise synchronously when the fulfill handler returned a non-thenable.
 //
 // For example:
--- a/dom/workers/test/promise_worker.js
+++ b/dom/workers/test/promise_worker.js
@@ -667,21 +667,21 @@ function promiseResolveThenableCleanStac
   var results = [];
 
   var p = Promise.resolve(thenable).then(incX);
   results.push(x);
 
   // check what happens after all "next cycle" steps
   // have had a chance to complete
   setTimeout(function(){
-    results.push(x);
     // Result should be [0, 2] since `thenable` will be called async.
     is(results[0], 0, "Expected thenable to be called asynchronously");
     // See Bug 1023547 comment 13 for why this check has to be gated on p.
     p.then(function() {
+      results.push(x);
       is(results[1], 2, "Expected thenable to be called asynchronously");
       runTest();
     });
   },1000);
 }
 
 var tests = [
     promiseResolve,