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

Unified Diff: test/webkit/fast/js/Promise-then.js

Issue 182713002: Import Blink layout tests for Promises. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 10 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: test/webkit/fast/js/Promise-then.js
diff --git a/test/webkit/fast/regex/constructor.js b/test/webkit/fast/js/Promise-then.js
similarity index 55%
copy from test/webkit/fast/regex/constructor.js
copy to test/webkit/fast/js/Promise-then.js
index 552d82e3ac2b8b1e6133ae44a64bf6de1192402e..b9cc9887b1f5b5407584b42cba165cf6a9453336 100644
--- a/test/webkit/fast/regex/constructor.js
+++ b/test/webkit/fast/js/Promise-then.js
@@ -1,4 +1,4 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
+// Copyright 2014 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -21,11 +21,48 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-description("This test checks use of the regexp constructor.");
+// Flags: --harmony
+'use strict';
+description('Test Promise.prototype.then');
-var re = /abc/;
+var resolve;
+var result;
+var thisInOnFulfilled;
+var thisInInit;
-shouldBeTrue("re === RegExp(re)");
-shouldBeTrue("re !== new RegExp(re)");
-shouldThrow("re === RegExp(re,'i')");
-shouldThrow("re !== new RegExp(re,'i')");
+var firstPromise = new Promise(function(newResolve) {
+ thisInInit = this;
+ resolve = newResolve;
+});
+
+var secondPromise = firstPromise.then(function(localResult) {
+ thisInOnFulfilled = this;
+ shouldBe('thisInOnFulfilled', 'undefined');
+ result = localResult;
+ shouldBeEqualToString('result', 'hello');
+ return 'world';
+});
+
+shouldBe('thisInInit', 'undefined');
+shouldBeTrue('firstPromise instanceof Promise');
+shouldBeTrue('secondPromise instanceof Promise');
+
+secondPromise.then(undefined, 37).then(function(localResult) {
+ result = localResult;
+ shouldBeEqualToString('result', 'world');
+ throw 'exception'
+}).then(1, 2).then(function() {
+ testFailed('resolved');
+}, function(localResult) {
+ testPassed('rejected');
+ result = localResult;
+ shouldBeEqualToString('result', 'exception');
+}).then(function() {
+ testPassed('resolved');
+ finishJSTest();
+}, function() {
+ testFailed('rejected');
+ finishJSTest();
+});
+
+resolve('hello');
« no previous file with comments | « test/webkit/fast/js/Promise-static-resolve-expected.txt ('k') | test/webkit/fast/js/Promise-then-callback-receiver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698