Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: LayoutTests/fast/js/Promise-init.html

Issue 17505004: Introduce Promises. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>
« no previous file with comments | « no previous file | LayoutTests/fast/js/Promise-init-expected.txt » ('j') | Source/bindings/v8/custom/V8PromiseResolverCustom.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698