Index: LayoutTests/fast/js/Promise-reject.html |
diff --git a/LayoutTests/fast/js/Promise-reject.html b/LayoutTests/fast/js/Promise-reject.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f95ca423d48645e5e53e580bdcc9cb04db12cc97 |
--- /dev/null |
+++ b/LayoutTests/fast/js/Promise-reject.html |
@@ -0,0 +1,60 @@ |
+<!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 resolverSync; |
+var promiseSync = new Promise(function(r) { resolverSync = r; }); |
+var promiseSyncState = 'pending'; |
+var promiseSyncResult = undefined; |
+promiseSync.then(function(result) { |
+ promiseSyncState = 'fulfilled'; |
+ promiseSyncResult = result; |
+}, function(result) { |
+ promiseSyncState = 'rejected'; |
+ promiseSyncResult = result; |
+}); |
+ |
+var resolverAsync; |
+var promiseAsync = new Promise(function(r) { resolverAsync = r; }); |
+var promiseAsyncState = 'pending'; |
+var promiseAsyncResult = undefined; |
+promiseAsync.then(function(result) { |
+ promiseAsyncState = 'fulfilled'; |
+ promiseAsyncResult = result; |
+}, function(result) { |
+ promiseAsyncState = 'rejected'; |
+ promiseAsyncResult = result; |
+}); |
+ |
+shouldBeEqualToString('promiseSyncState', 'pending'); |
+shouldBeEqualToString('promiseAsyncState', 'pending'); |
+ |
+resolverSync.reject('hello', true); |
+resolverAsync.reject('hello'); |
+ |
+shouldBeEqualToString('promiseSyncState', 'rejected'); |
+shouldBeEqualToString('promiseSyncResult', 'hello'); |
+shouldBeEqualToString('promiseAsyncState', 'pending'); |
+ |
+promiseAsync.then(function() { |
+ debug('FAIL promiseAsync is fulfilled.'); |
+ finishJSTest(); |
+}, function() { |
+ shouldBeEqualToString('promiseAsyncState', 'rejected'); |
+ shouldBeEqualToString('promiseAsyncResult', 'hello'); |
+ finishJSTest(); |
+}); |
+ |
+</script> |
+<script src="resources/js-test-post.js"></script> |
+</body> |
+</html> |