BackwardsGraph needs to consider back edges as the backward's root successor
[WebKit-https.git] / JSTests / es6 / Promise_is_subclassable_Promise.race.js
1 function test() {
2 var passed = false;
3 function asyncTestPassed() {
4     passed = true;
5 }
6
7 class P extends Promise {}
8 var fulfills = P.race([
9   new Promise(function(resolve)   { setTimeout(resolve,200,"foo"); }),
10   new Promise(function(_, reject) { setTimeout(reject, 300,"bar"); }),
11 ]);
12 var rejects = P.race([
13   new Promise(function(_, reject) { setTimeout(reject, 200,"baz"); }),
14   new Promise(function(resolve)   { setTimeout(resolve,300,"qux"); }),
15 ]);
16 var score = +(fulfills instanceof P);
17 fulfills.then(function(result) { score += (result === "foo"); check(); });
18 rejects.catch(function(result) { score += (result === "baz"); check(); });
19
20 function check() {
21   if (score === 3) asyncTestPassed();
22 }
23       
24 drainMicrotasks();
25 return passed;
26 }
27
28 if (!test())
29     throw new Error("Test failed");
30