Bug 1023547 - Fix intermittent dom/workers/test/test_promise.html failure. r=bz
authorNikhil Marathe <nsm.nikhil@gmail.com>
Fri, 18 Jul 2014 18:13:47 -0700
changeset 217130 b00c22ac9b230810123a0d99bc1f3447465a8b7b
parent 217129 131e77486177c869068704e77fde5c139ce2b4a2
child 217131 f5f3d2f7bc4e146228fc822bac3293cffe8588da
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1023547
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1023547 - Fix intermittent dom/workers/test/test_promise.html failure. r=bz
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,