|
1 <!-- |
|
2 Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 --> |
|
5 <html> |
|
6 <head> |
|
7 <title>Promise.resolve(anything) Test</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
10 </head> |
|
11 <body> |
|
12 <p id="display"></p> |
|
13 <div id="content" style="display: none"> |
|
14 |
|
15 </div> |
|
16 <pre id="test"> |
|
17 <script type="application/javascript"><!-- |
|
18 |
|
19 var tests = [ |
|
20 null, |
|
21 42, |
|
22 "hello world", |
|
23 true, |
|
24 false, |
|
25 {}, |
|
26 { a: 42 }, |
|
27 [ 1, 2, 3, 4, null, true, "hello world" ], |
|
28 function() {}, |
|
29 window, |
|
30 undefined, |
|
31 document.createElement('input'), |
|
32 new Date(), |
|
33 ]; |
|
34 |
|
35 function cbError() { |
|
36 ok(false, "Nothing should arrive here!"); |
|
37 } |
|
38 |
|
39 function runTest() { |
|
40 if (!tests.length) { |
|
41 SimpleTest.finish(); |
|
42 return; |
|
43 } |
|
44 |
|
45 var test = tests.pop(); |
|
46 |
|
47 new Promise(function(resolve, reject) { |
|
48 resolve(test); |
|
49 }).then(function(what) { |
|
50 ok(test === what, "What is: " + what); |
|
51 }, cbError).then(function() { |
|
52 new Promise(function(resolve, reject) { |
|
53 reject(test) |
|
54 }).then(cbError, function(what) { |
|
55 ok(test === what, "What is: " + what); |
|
56 }).then(runTest, cbError); |
|
57 }); |
|
58 } |
|
59 |
|
60 SimpleTest.waitForExplicitFinish(); |
|
61 runTest(); |
|
62 // --> |
|
63 </script> |
|
64 </pre> |
|
65 </body> |
|
66 </html> |
|
67 |