Chromium Code Reviews| Index: LayoutTests/fast/js/Promise-init.html |
| diff --git a/LayoutTests/fast/js/Promise-init.html b/LayoutTests/fast/js/Promise-init.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7a00d8f41b8c81a795800eb425da1838219fe451 |
| --- /dev/null |
| +++ b/LayoutTests/fast/js/Promise-init.html |
| @@ -0,0 +1,57 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<script src="resources/js-test-pre.js"></script> |
| +</head> |
| +<body> |
| +<div id="description"></div> |
| +<div id="console"></div> |
| +<script> |
| +if (window.testRunner) |
| + testRunner.dumpAsText(); |
| + |
| +description('Test Promise.'); |
| + |
| +var thisInInit; |
| +var resolver; |
| +var promise = new Promise(function(r) { |
| + thisInInit = this; |
| + resolver = r; |
| +}); |
| + |
| +shouldBeTrue('promise instanceof Promise'); |
| +shouldBe('promise.constructor', 'Promise'); |
| +shouldBe('thisInInit', 'promise'); |
| +shouldBeTrue('resolver instanceof PromiseResolver'); |
| +shouldBe('resolver.constructor', 'PromiseResolver'); |
| + |
| +try { |
| + new Promise(); |
| + debug('FAIL A TypeError should be thrown for "new Promise()"'); |
| +} 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.
|
| + window.errorNoInitArgument = e; |
| + shouldBeTrue('errorNoInitArgument instanceof TypeError'); |
| +} |
| + |
| +try { |
| + new Promise(37); |
| + debug('FAIL A TypeError should be thrown for "new Promise(37)'); |
| +} catch (e) { |
| + window.errorNumberInitArgument = e; |
| + shouldBeTrue('errorNumberInitArgument instanceof TypeError'); |
| +} |
| + |
| +try { |
| + new Promise(function() { |
| + throw Error('foo'); |
| + }); |
| + // We can't test if the promise is rejected now. |
| + debug('PASS If an error is thrown from init callback, Promise should return an rejected promise'); |
| +} catch (e) { |
|
do-not-use
2013/06/21 15:04:58
Ditto.
yhirano
2013/06/24 03:33:34
Done.
|
| + debug('FAIL If an error is thrown from init callback, Promise should return an rejected promise'); |
| +} |
| + |
| +</script> |
| +<script src="resources/js-test-post.js"></script> |
| +</body> |
| +</html> |