Bug 965644 - Fix intermittent oranges on promise tests. r=bz, a=test-only
authorNikhil Marathe <nsm.nikhil@gmail.com>
Tue, 01 Jul 2014 17:33:00 -0700
changeset 200750 acd930a6f1748867791c3cf9a071c742b16e73ae
parent 200749 cc906edb11c0f3c0de3b06fa2167ae65a54bc19b
child 200751 9d671266d0d93edb75e2e35631d29809b023c5b7
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, test-only
bugs965644
milestone31.0
Bug 965644 - Fix intermittent oranges on promise tests. r=bz, a=test-only
dom/promise/tests/test_promise_utils.html
dom/workers/test/promise_worker.js
--- a/dom/promise/tests/test_promise_utils.html
+++ b/dom/promise/tests/test_promise_utils.html
@@ -197,25 +197,33 @@ function promiseRacePromiseArray() {
     return new Promise(function(resolve) {
       setTimeout(function() {
         resolve(n);
       }, n);
     });
   }
 
   var arr = [
-    timeoutPromise(50),
-    timeoutPromise(20),
-    timeoutPromise(30),
-    timeoutPromise(100)
+    new Promise(function(resolve) {
+      resolve("first");
+    }),
+    Promise.resolve("second"),
+    new Promise(function() {}),
+    new Promise(function(resolve) {
+      setTimeout(function() {
+        setTimeout(function() {
+          resolve("fourth");
+        }, 0);
+      }, 0);
+    }),
   ];
 
   var p = Promise.race(arr);
   p.then(function(winner) {
-    is(winner, 20, "Fastest timeout should win.");
+    is(winner, "first", "First queued resolution should win the race.");
     runTest();
   });
 }
 
 function promiseRaceIterable() {
   function* participants() {
     yield new Promise(function(resolve) {
       setTimeout(resolve, 10, 10);
--- a/dom/workers/test/promise_worker.js
+++ b/dom/workers/test/promise_worker.js
@@ -560,25 +560,33 @@ function promiseRacePromiseArray() {
     return new Promise(function(resolve) {
       setTimeout(function() {
         resolve(n);
       }, n);
     });
   }
 
   var arr = [
-    timeoutPromise(50),
-    timeoutPromise(20),
-    timeoutPromise(30),
-    timeoutPromise(100)
+    new Promise(function(resolve) {
+      resolve("first");
+    }),
+    Promise.resolve("second"),
+    new Promise(function() {}),
+    new Promise(function(resolve) {
+      setTimeout(function() {
+        setTimeout(function() {
+          resolve("fourth");
+        }, 0);
+      }, 0);
+    }),
   ];
 
   var p = Promise.race(arr);
   p.then(function(winner) {
-    is(winner, 20, "Fastest timeout should win.");
+    is(winner, "first", "First queued resolution should win the race.");
     runTest();
   });
 }
 
 function promiseRaceReject() {
   var p = Promise.race([
     Promise.reject(new Error("Fail bad!")),
     new Promise(function(resolve) {