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..6c52a8f902bed4ca1c0fb3fbf2b43db3d3651856 |
--- /dev/null |
+++ b/LayoutTests/fast/js/Promise-init.html |
@@ -0,0 +1,37 @@ |
+<!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'); |
+ |
+shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function argument"'); |
+shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"'); |
+ |
+shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })'); |
+// FIXME: We can't test if the promise is rejected now, but should test it in the future. |
+ |
+</script> |
+<script src="resources/js-test-post.js"></script> |
+</body> |
+</html> |