Bug 1023547 - Fix intermittent dom/workers/test/test_promise.html failure. r=bz, a=test-only
authorNikhil Marathe <nsm.nikhil@gmail.com>
Fri, 11 Jul 2014 20:21:54 -0700
changeset 207924 2662e7c51839dbd88b357ecf1064b7d75034ac1e
parent 207923 589244aa4a133eadac09b97c351bd5351276506f
child 207925 0e974612773f1b8f287d8cb4b76c69e4cd4336dd
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [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/workers/test/promise_worker.js
--- a/dom/workers/test/promise_worker.js
+++ b/dom/workers/test/promise_worker.js
@@ -551,24 +551,16 @@ function promiseRaceValuesArray() {
     runTest();
   }, function(err) {
     ok(false, "Should not fail " + err + ".");
     runTest();
   });
 }
 
 function promiseRacePromiseArray() {
-  function timeoutPromise(n) {
-    return new Promise(function(resolve) {
-      setTimeout(function() {
-        resolve(n);
-      }, n);
-    });
-  }
-
   var arr = [
     new Promise(function(resolve) {
       resolve("first");
     }),
     Promise.resolve("second"),
     new Promise(function() {}),
     new Promise(function(resolve) {
       setTimeout(function() {
@@ -669,27 +661,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() {
+      is(results[1], 2, "Expected thenable to be called asynchronously");
+      runTest();
+    });
   },1000);
 }
 
 var tests = [
     promiseResolve,
     promiseReject,
     promiseException,
     promiseAsync,