Index: LayoutTests/fast/js/Promise-then.html |
diff --git a/LayoutTests/fast/js/Promise-then.html b/LayoutTests/fast/js/Promise-then.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3908afc06e4dd52947ee591be2c7ae0333ed3323 |
--- /dev/null |
+++ b/LayoutTests/fast/js/Promise-then.html |
@@ -0,0 +1,43 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<script src="resources/js-test-pre.js"></script> |
+</head> |
+<body> |
+<div id="description"></div> |
+<div id="console"></div> |
+<script> |
+description('Test Promise.'); |
+ |
+window.jsTestIsAsync = true; |
+ |
+var resolver; |
+ |
+var firstPromise = new Promise(function(newResolver) { |
+ window.thisInInit = this; |
+ resolver = newResolver; |
+}); |
+ |
+var secondPromise = firstPromise.then(function(result) { |
+ window.thisInFulfillCallback = this; |
+ shouldBeFalse('thisInFulfillCallback === firstPromise'); |
+ shouldBeTrue('thisInFulfillCallback === secondPromise'); |
+ window.result = result; |
+ shouldBeEqualToString('result', 'hello'); |
+ finishJSTest(); |
+}); |
+ |
+shouldBeTrue('thisInInit === firstPromise'); |
+shouldBeTrue('firstPromise instanceof Promise'); |
+shouldBeTrue('secondPromise instanceof Promise'); |
+ |
+shouldThrow('firstPromise.then(null)', '"TypeError: fulfillCallback must be a function or undefined"'); |
+shouldThrow('firstPromise.then(undefined, null)', '"TypeError: rejectCallback must be a function or undefined"'); |
+shouldThrow('firstPromise.then(37)', '"TypeError: fulfillCallback must be a function or undefined"'); |
+ |
+resolver.fulfill('hello'); |
+ |
+</script> |
+<script src="resources/js-test-post.js"></script> |
+</body> |
+</html> |