OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="resources/js-test-pre.js"></script> | |
5 </head> | |
6 <body> | |
7 <div id="description"></div> | |
8 <div id="console"></div> | |
9 <script> | |
10 if (window.testRunner) | |
11 testRunner.dumpAsText(); | |
12 | |
13 description('Test Promise.'); | |
14 | |
15 var thisInInit; | |
16 var resolver; | |
17 var promise = new Promise(function(r) { | |
18 thisInInit = this; | |
19 resolver = r; | |
20 }); | |
21 | |
22 shouldBeTrue('promise instanceof Promise'); | |
23 shouldBe('promise.constructor', 'Promise'); | |
24 shouldBe('thisInInit', 'promise'); | |
25 shouldBeTrue('resolver instanceof PromiseResolver'); | |
26 shouldBe('resolver.constructor', 'PromiseResolver'); | |
27 | |
28 try { | |
29 new Promise(); | |
30 debug('FAIL A TypeError should be thrown for "new Promise()"'); | |
31 } catch (e) { | |
do-not-use
2013/06/21 15:04:58
Any reason we are now using shouldThrow()?
yhirano
2013/06/24 03:33:34
Done.
| |
32 window.errorNoInitArgument = e; | |
33 shouldBeTrue('errorNoInitArgument instanceof TypeError'); | |
34 } | |
35 | |
36 try { | |
37 new Promise(37); | |
38 debug('FAIL A TypeError should be thrown for "new Promise(37)'); | |
39 } catch (e) { | |
40 window.errorNumberInitArgument = e; | |
41 shouldBeTrue('errorNumberInitArgument instanceof TypeError'); | |
42 } | |
43 | |
44 try { | |
45 new Promise(function() { | |
46 throw Error('foo'); | |
47 }); | |
48 // We can't test if the promise is rejected now. | |
49 debug('PASS If an error is thrown from init callback, Promise should return an rejected promise'); | |
50 } catch (e) { | |
do-not-use
2013/06/21 15:04:58
Ditto.
yhirano
2013/06/24 03:33:34
Done.
| |
51 debug('FAIL If an error is thrown from init callback, Promise should return an rejected promise'); | |
52 } | |
53 | |
54 </script> | |
55 <script src="resources/js-test-post.js"></script> | |
56 </body> | |
57 </html> | |
OLD | NEW |