From b2a257f9ffb63a1e1bd0d89a6ef297a1f595f5cc Mon Sep 17 00:00:00 2001 From: littledan Date: Mon, 22 Aug 2016 14:34:44 -0700 Subject: [PATCH] Remove --promise-extra flag This flag was shipped on in 52, so it's due for removal. The patch includes removing the deprecated and unused-in-Blink API Promise::Chain, and many test updates. R=adamk@chromium.org BUG=v8:4633 Review-Url: https://codereview.chromium.org/2267033002 Cr-Commit-Position: refs/heads/master@{#38804} --- BUILD.gn | 1 - include/v8.h | 6 - src/api.cc | 30 - src/bootstrapper.cc | 6 - src/contexts.h | 1 - src/flag-definitions.h | 4 - src/js/prologue.js | 3 - src/js/promise-extra.js | 26 - src/js/promise.js | 28 - src/v8.gyp | 1 - test/mjsunit/es6/debug-promises/reentry.js | 4 +- .../debug-promises/reject-after-resolve.js | 4 +- .../es6/debug-promises/reject-caught-all.js | 4 +- .../es6/debug-promises/reject-caught-late.js | 4 +- .../debug-promises/reject-caught-uncaught.js | 4 +- .../es6/debug-promises/reject-uncaught-all.js | 4 +- .../reject-uncaught-uncaught.js | 4 +- .../reject-with-invalid-reject.js | 4 +- .../reject-with-throw-in-reject.js | 4 +- .../reject-with-undefined-reject.js | 4 +- .../es6/debug-promises/throw-caught-all.js | 4 +- .../es6/debug-promises/throw-caught-late.js | 4 +- .../debug-promises/throw-caught-uncaught.js | 4 +- .../throw-finally-caught-all.js | 4 +- .../es6/debug-promises/throw-uncaught-all.js | 4 +- .../debug-promises/throw-uncaught-uncaught.js | 4 +- .../throw-with-throw-in-reject.js | 4 +- test/mjsunit/es6/promise-internal-setter.js | 3 - test/mjsunit/es6/promises.js | 566 +++++++----------- test/mjsunit/es6/regress/regress-cr372788.js | 4 +- test/mjsunit/mjsunit.status | 2 +- 31 files changed, 268 insertions(+), 481 deletions(-) delete mode 100644 src/js/promise-extra.js diff --git a/BUILD.gn b/BUILD.gn index de1b11334e..94eb389748 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -431,7 +431,6 @@ action("js2c_experimental") { "src/js/harmony-atomics.js", "src/js/harmony-simd.js", "src/js/harmony-string-padding.js", - "src/js/promise-extra.js", ] outputs = [ diff --git a/include/v8.h b/include/v8.h index c93ee23858..35822e53d8 100644 --- a/include/v8.h +++ b/include/v8.h @@ -3408,12 +3408,6 @@ class V8_EXPORT Promise : public Object { * an argument. If the promise is already resolved/rejected, the handler is * invoked at the end of turn. */ - V8_DEPRECATED("Use maybe version of Then", - Local Chain(Local handler)); - V8_DEPRECATED("Use Then", - V8_WARN_UNUSED_RESULT MaybeLocal Chain( - Local context, Local handler)); - V8_DEPRECATED("Use maybe version", Local Catch(Local handler)); V8_WARN_UNUSED_RESULT MaybeLocal Catch(Local context, diff --git a/src/api.cc b/src/api.cc index 241824a38d..6858a325c4 100644 --- a/src/api.cc +++ b/src/api.cc @@ -6707,36 +6707,6 @@ void Promise::Resolver::Reject(Local value) { } -namespace { - -MaybeLocal DoChain(Value* value, Local context, - Local handler) { - PREPARE_FOR_EXECUTION(context, Promise, Chain, Promise); - auto self = Utils::OpenHandle(value); - i::Handle argv[] = {Utils::OpenHandle(*handler)}; - i::Handle result; - has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(), - self, arraysize(argv), argv) - .ToHandle(&result); - RETURN_ON_FAILED_EXECUTION(Promise); - RETURN_ESCAPED(Local::Cast(Utils::ToLocal(result))); -} - -} // namespace - - -MaybeLocal Promise::Chain(Local context, - Local handler) { - return DoChain(this, context, handler); -} - - -Local Promise::Chain(Local handler) { - auto context = ContextFromHeapObject(Utils::OpenHandle(this)); - RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise); -} - - MaybeLocal Promise::Catch(Local context, Local handler) { PREPARE_FOR_EXECUTION(context, Promise, Catch, Promise); diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 7a5a4cb9a9..c9118cdbfd 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -209,7 +209,6 @@ class Genesis BASE_EMBEDDED { HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) - DECLARE_FEATURE_INITIALIZATION(promise_extra, "") DECLARE_FEATURE_INITIALIZATION(intl_extra, "") #undef DECLARE_FEATURE_INITIALIZATION @@ -2177,7 +2176,6 @@ void Genesis::InitializeExperimentalGlobal() { HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) - FEATURE_INITIALIZE_GLOBAL(promise_extra, "") FEATURE_INITIALIZE_GLOBAL(intl_extra, "") #undef FEATURE_INITIALIZE_GLOBAL } @@ -2763,7 +2761,6 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent) -EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(promise_extra) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(intl_extra) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_explicit_tailcalls) EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls) @@ -3351,8 +3348,6 @@ bool Genesis::InstallExperimentalNatives() { static const char* harmony_regexp_named_captures_natives[] = {nullptr}; static const char* harmony_regexp_property_natives[] = {nullptr}; static const char* harmony_function_sent_natives[] = {nullptr}; - static const char* promise_extra_natives[] = {"native promise-extra.js", - nullptr}; static const char* intl_extra_natives[] = {"native intl-extra.js", nullptr}; static const char* harmony_object_values_entries_natives[] = {nullptr}; static const char* harmony_object_own_property_descriptors_natives[] = { @@ -3387,7 +3382,6 @@ bool Genesis::InstallExperimentalNatives() { HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); INSTALL_EXPERIMENTAL_NATIVES(intl_extra, ""); - INSTALL_EXPERIMENTAL_NATIVES(promise_extra, ""); #undef INSTALL_EXPERIMENTAL_NATIVES } diff --git a/src/contexts.h b/src/contexts.h index 14cde4982a..d73135f7a4 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -81,7 +81,6 @@ enum ContextLookupFlags { V(OBJECT_VALUE_OF, JSFunction, object_value_of) \ V(OBJECT_TO_STRING, JSFunction, object_to_string) \ V(PROMISE_CATCH_INDEX, JSFunction, promise_catch) \ - V(PROMISE_CHAIN_INDEX, JSFunction, promise_chain) \ V(PROMISE_CREATE_INDEX, JSFunction, promise_create) \ V(PROMISE_FUNCTION_INDEX, JSFunction, promise_function) \ V(PROMISE_HAS_USER_DEFINED_REJECT_HANDLER_INDEX, JSFunction, \ diff --git a/src/flag-definitions.h b/src/flag-definitions.h index b661e18e34..e5ddbadd2c 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -184,10 +184,6 @@ DEFINE_BOOL(harmony, false, "enable all completed harmony features") DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features") DEFINE_IMPLICATION(es_staging, harmony) -DEFINE_BOOL(promise_extra, false, "additional V8 Promise functions") -// Removing extra Promise functions is shipped -DEFINE_NEG_VALUE_IMPLICATION(harmony_shipping, promise_extra, true) - DEFINE_BOOL(intl_extra, false, "additional V8 Intl functions") // Removing extra Intl functions is shipped DEFINE_NEG_VALUE_IMPLICATION(harmony_shipping, intl_extra, true) diff --git a/src/js/prologue.js b/src/js/prologue.js index 94a514aecb..bb818791a0 100644 --- a/src/js/prologue.js +++ b/src/js/prologue.js @@ -199,9 +199,6 @@ function PostNatives(utils) { "NewPromiseCapability", "NumberIsInteger", "PerformPromiseThen", - "PromiseChain", - "PromiseDefer", - "PromiseAccept", "PromiseCastResolved", "PromiseThen", "RegExpSubclassExecJS", diff --git a/src/js/promise-extra.js b/src/js/promise-extra.js deleted file mode 100644 index 34d7323604..0000000000 --- a/src/js/promise-extra.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -(function(global, utils) { - -"use strict"; - -%CheckIsBootstrapping(); - -var GlobalPromise = global.Promise; - -var PromiseChain = utils.ImportNow("PromiseChain"); -var PromiseDefer = utils.ImportNow("PromiseDefer"); -var PromiseAccept = utils.ImportNow("PromiseAccept"); - -utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ - "chain", PromiseChain, -]); - -utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ - "defer", PromiseDefer, - "accept", PromiseAccept, -]); - -}) diff --git a/src/js/promise.js b/src/js/promise.js index a666080e78..b50fc80b30 100644 --- a/src/js/promise.js +++ b/src/js/promise.js @@ -346,18 +346,6 @@ function NewPromiseCapability(C) { return result; } -// Unspecified V8-specific legacy function -function PromiseDefer() { - %IncrementUseCounter(kPromiseDefer); - return NewPromiseCapability(this); -} - -// Unspecified V8-specific legacy function -function PromiseAccept(x) { - %IncrementUseCounter(kPromiseAccept); - return %_Call(PromiseResolve, this, x); -} - // ES#sec-promise.reject // Promise.reject ( x ) function PromiseReject(r) { @@ -443,13 +431,6 @@ function PromiseThen(onResolve, onReject) { return PerformPromiseThen(this, onResolve, onReject, resultCapability); } -// Unspecified V8-specific legacy function -// Chain is left around for now as an alias for then -function PromiseChain(onResolve, onReject) { - %IncrementUseCounter(kPromiseChain); - return %_Call(PromiseThen, this, onResolve, onReject); -} - // ES#sec-promise.prototype.catch // Promise.prototype.catch ( onRejected ) function PromiseCatch(onReject) { @@ -615,7 +596,6 @@ utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ %InstallToContext([ "promise_catch", PromiseCatch, - "promise_chain", PromiseChain, "promise_create", PromiseCreate, "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, "promise_reject", RejectPromise, @@ -634,15 +614,7 @@ utils.InstallFunctions(extrasUtils, 0, [ "rejectPromise", RejectPromise ]); -// TODO(v8:4567): Allow experimental natives to remove function prototype -[PromiseChain, PromiseDefer, PromiseAccept].forEach( - fn => %FunctionRemovePrototype(fn)); - utils.Export(function(to) { - to.PromiseChain = PromiseChain; - to.PromiseDefer = PromiseDefer; - to.PromiseAccept = PromiseAccept; - to.PromiseCastResolved = PromiseCastResolved; to.PromiseThen = PromiseThen; diff --git a/src/v8.gyp b/src/v8.gyp index 702e095beb..08f3bd8f2f 100644 --- a/src/v8.gyp +++ b/src/v8.gyp @@ -2195,7 +2195,6 @@ 'js/harmony-atomics.js', 'js/harmony-simd.js', 'js/harmony-string-padding.js', - 'js/promise-extra.js', 'js/harmony-async-await.js' ], 'libraries_bin_file': '<(SHARED_INTERMEDIATE_DIR)/libraries.bin', diff --git a/test/mjsunit/es6/debug-promises/reentry.js b/test/mjsunit/es6/debug-promises/reentry.js index a97ce81012..cc98ed9efd 100644 --- a/test/mjsunit/es6/debug-promises/reentry.js +++ b/test/mjsunit/es6/debug-promises/reentry.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --promise-extra +// Flags: --expose-debug-as debug // Test reentry of special try catch for Promises. @@ -12,6 +12,6 @@ Debug.setBreakOnUncaughtException(); Debug.setListener(function(event, exec_state, event_data, data) { }); var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain(function() { +var q = p.then(function() { new Promise(function(resolve, reject) { resolve(); }); }); diff --git a/test/mjsunit/es6/debug-promises/reject-after-resolve.js b/test/mjsunit/es6/debug-promises/reject-after-resolve.js index ed4b2c435e..5ec2da50e9 100644 --- a/test/mjsunit/es6/debug-promises/reject-after-resolve.js +++ b/test/mjsunit/es6/debug-promises/reject-after-resolve.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we listen to uncaught exceptions and // the Promise is rejected in a chained closure after it has been resolved. @@ -17,7 +17,7 @@ var p = new Promise(function(resolve, reject) { resolve(reject); }); -var q = p.chain( +var q = p.then( function(value) { assertEquals(["resolve", "end main"], log); value(new Error("reject")); diff --git a/test/mjsunit/es6/debug-promises/reject-caught-all.js b/test/mjsunit/es6/debug-promises/reject-caught-all.js index e1a653889d..8d348ce6b6 100644 --- a/test/mjsunit/es6/debug-promises/reject-caught-all.js +++ b/test/mjsunit/es6/debug-promises/reject-caught-all.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we listen to all exceptions and // there is a catch handler for the to-be-rejected Promise. @@ -18,7 +18,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function(value) { log.push("reject"); return Promise.reject(new Error("reject")); diff --git a/test/mjsunit/es6/debug-promises/reject-caught-late.js b/test/mjsunit/es6/debug-promises/reject-caught-late.js index 922449261b..44eb76728f 100644 --- a/test/mjsunit/es6/debug-promises/reject-caught-late.js +++ b/test/mjsunit/es6/debug-promises/reject-caught-late.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we only listen to uncaught exceptions, the Promise // is rejected, and a catch handler is installed right before the rejection. @@ -14,7 +14,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { q.catch(function(e) { assertEquals("caught", e.message); diff --git a/test/mjsunit/es6/debug-promises/reject-caught-uncaught.js b/test/mjsunit/es6/debug-promises/reject-caught-uncaught.js index afb46fea8f..b2fe8b0a45 100644 --- a/test/mjsunit/es6/debug-promises/reject-caught-uncaught.js +++ b/test/mjsunit/es6/debug-promises/reject-caught-uncaught.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we only listen to uncaught exceptions and // there is a catch handler for the to-be-rejected Promise. @@ -14,7 +14,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { return Promise.reject(Error("caught reject")); }); diff --git a/test/mjsunit/es6/debug-promises/reject-uncaught-all.js b/test/mjsunit/es6/debug-promises/reject-uncaught-all.js index 63e3b8678d..0c5ecc5f3a 100644 --- a/test/mjsunit/es6/debug-promises/reject-uncaught-all.js +++ b/test/mjsunit/es6/debug-promises/reject-uncaught-all.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we listen to all exceptions and // there is a catch handler for the to-be-rejected Promise. @@ -18,7 +18,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { log.push("reject"); return Promise.reject(new Error("uncaught reject")); diff --git a/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js b/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js index b542bc69dd..e5e560b3db 100644 --- a/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js +++ b/test/mjsunit/es6/debug-promises/reject-uncaught-uncaught.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we only listen to uncaught exceptions and // there is no catch handler for the to-be-rejected Promise. @@ -18,7 +18,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { log.push("reject"); return Promise.reject(Error("uncaught reject")); // event diff --git a/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js b/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js index 8775df687d..6aaf882ce8 100644 --- a/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js +++ b/test/mjsunit/es6/debug-promises/reject-with-invalid-reject.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when a Promise is rejected, which is caught by a custom // promise, which has a number for reject closure. We expect an Exception debug @@ -28,7 +28,7 @@ function MyPromise(resolver) { MyPromise.prototype = new Promise(function() {}); p.constructor = MyPromise; -var q = p.chain( +var q = p.then( function() { log.push("reject caught"); return Promise.reject(new Error("caught")); diff --git a/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js b/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js index b6c06df49e..47e335d968 100644 --- a/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js +++ b/test/mjsunit/es6/debug-promises/reject-with-throw-in-reject.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when a Promise is rejected, which is caught by a // custom promise, which throws a new exception in its reject handler. @@ -33,7 +33,7 @@ function MyPromise(resolver) { MyPromise.prototype = new Promise(function() {}); p.constructor = MyPromise; -var q = p.chain( +var q = p.then( function() { log.push("reject caught"); return Promise.reject(new Error("caught")); diff --git a/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js b/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js index d058d41b96..1595372396 100644 --- a/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js +++ b/test/mjsunit/es6/debug-promises/reject-with-undefined-reject.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when a Promise is rejected, which is caught by a custom // promise, which has undefined for reject closure. We expect an Exception @@ -28,7 +28,7 @@ function MyPromise(resolver) { MyPromise.prototype = new Promise(function() {}); p.constructor = MyPromise; -var q = p.chain( +var q = p.then( function() { log.push("reject caught"); return Promise.reject(new Error("caught")); diff --git a/test/mjsunit/es6/debug-promises/throw-caught-all.js b/test/mjsunit/es6/debug-promises/throw-caught-all.js index 3b7c48c1cf..8b932490b2 100644 --- a/test/mjsunit/es6/debug-promises/throw-caught-all.js +++ b/test/mjsunit/es6/debug-promises/throw-caught-all.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we listen to all exceptions and // there is a catch handler for the exception thrown in a Promise. @@ -18,7 +18,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { log.push("throw"); throw new Error("caught"); diff --git a/test/mjsunit/es6/debug-promises/throw-caught-late.js b/test/mjsunit/es6/debug-promises/throw-caught-late.js index aa7e584320..0399e5cc34 100644 --- a/test/mjsunit/es6/debug-promises/throw-caught-late.js +++ b/test/mjsunit/es6/debug-promises/throw-caught-late.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we only listen to uncaught exceptions, the Promise // throws, and a catch handler is installed right before throwing. @@ -14,7 +14,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { q.catch(function(e) { assertEquals("caught", e.message); diff --git a/test/mjsunit/es6/debug-promises/throw-caught-uncaught.js b/test/mjsunit/es6/debug-promises/throw-caught-uncaught.js index a424ccc9f7..8e1524d519 100644 --- a/test/mjsunit/es6/debug-promises/throw-caught-uncaught.js +++ b/test/mjsunit/es6/debug-promises/throw-caught-uncaught.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we only listen to uncaught exceptions and // there is a catch handler for the exception thrown in a Promise. @@ -14,7 +14,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { throw new Error("caught throw"); }); diff --git a/test/mjsunit/es6/debug-promises/throw-finally-caught-all.js b/test/mjsunit/es6/debug-promises/throw-finally-caught-all.js index a3d45dce77..eb823f518f 100644 --- a/test/mjsunit/es6/debug-promises/throw-finally-caught-all.js +++ b/test/mjsunit/es6/debug-promises/throw-finally-caught-all.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we listen to all exceptions and // there is a catch handler for the exception thrown in a Promise, first @@ -19,7 +19,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { log.push("throw"); try { diff --git a/test/mjsunit/es6/debug-promises/throw-uncaught-all.js b/test/mjsunit/es6/debug-promises/throw-uncaught-all.js index bfe0bedbac..3a73ac9fff 100644 --- a/test/mjsunit/es6/debug-promises/throw-uncaught-all.js +++ b/test/mjsunit/es6/debug-promises/throw-uncaught-all.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we listen to all exceptions and // there is no catch handler for the exception thrown in a Promise. @@ -18,7 +18,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { log.push("throw"); throw new Error("uncaught"); // event diff --git a/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js b/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js index 8dff592f33..24239f26f3 100644 --- a/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js +++ b/test/mjsunit/es6/debug-promises/throw-uncaught-uncaught.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when we only listen to uncaught exceptions and // there is a catch handler for the exception thrown in a Promise. @@ -18,7 +18,7 @@ var p = new Promise(function(resolve, reject) { resolve(); }); -var q = p.chain( +var q = p.then( function() { log.push("throw"); throw new Error("uncaught"); // event diff --git a/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js b/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js index e884045f10..622dd2573e 100644 --- a/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js +++ b/test/mjsunit/es6/debug-promises/throw-with-throw-in-reject.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --allow-natives-syntax --promise-extra +// Flags: --expose-debug-as debug --allow-natives-syntax // Test debug events when an exception is thrown inside a Promise, which is // caught by a custom promise, which throws a new exception in its reject @@ -34,7 +34,7 @@ MyPromise.prototype = new Promise(function() {}); MyPromise.__proto__ = Promise; p.constructor = MyPromise; -var q = p.chain( +var q = p.then( function() { log.push("throw caught"); throw new Error("caught"); // event diff --git a/test/mjsunit/es6/promise-internal-setter.js b/test/mjsunit/es6/promise-internal-setter.js index 20d361f623..bf0045a98b 100644 --- a/test/mjsunit/es6/promise-internal-setter.js +++ b/test/mjsunit/es6/promise-internal-setter.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --promise-extra - 'use strict'; Object.defineProperties(Object.prototype, { @@ -16,4 +14,3 @@ class P extends Promise {} P.all([Promise.resolve('ok')]); P.race([Promise.resolve('ok')]); -P.defer(); diff --git a/test/mjsunit/es6/promises.js b/test/mjsunit/es6/promises.js index 4eb539cbd5..0af7a882e7 100644 --- a/test/mjsunit/es6/promises.js +++ b/test/mjsunit/es6/promises.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --promise-extra +// Flags: --allow-natives-syntax // Make sure we don't rely on functions patchable by monkeys. var call = Function.prototype.call.call.bind(Function.prototype.call) @@ -82,6 +82,12 @@ for (var i in globals) { } +function defer(constructor) { + var resolve, reject; + var promise = new constructor((res, rej) => { resolve = res; reject = rej }); + return { promise, resolve, reject }; +} + var asyncAssertsExpected = 0; function assertAsyncRan() { ++asyncAssertsExpected } @@ -141,7 +147,7 @@ function assertAsyncDone(iteration) { })(); (function() { - (new Promise(function() { throw 5 })).chain( + (new Promise(function() { throw 5 })).then( assertUnreachable, function(r) { assertAsync(r === 5, "new-throw") } ) @@ -149,29 +155,21 @@ function assertAsyncDone(iteration) { })(); (function() { - Promise.accept(5); - Promise.accept(5).chain(undefined, assertUnreachable).chain( - function(x) { assertAsync(x === 5, "resolved/chain-nohandler") }, + Promise.resolve(5); + Promise.resolve(5).then(undefined, assertUnreachable).then( + function(x) { assertAsync(x === 5, "resolved/then-nohandler") }, assertUnreachable ) assertAsyncRan() })(); (function() { - Promise.reject(5).chain(assertUnreachable, undefined).chain( - assertUnreachable, - function(r) { assertAsync(r === 5, "rejected/chain-nohandler") } - ) - assertAsyncRan() -})(); - -(function() { - Promise.accept(5).then(undefined, assertUnreachable).chain( + Promise.resolve(5).then(undefined, assertUnreachable).then( function(x) { assertAsync(x === 5, "resolved/then-nohandler-undefined") }, assertUnreachable ) assertAsyncRan() - Promise.accept(6).then(null, assertUnreachable).chain( + Promise.resolve(6).then(null, assertUnreachable).then( function(x) { assertAsync(x === 6, "resolved/then-nohandler-null") }, assertUnreachable ) @@ -179,34 +177,9 @@ function assertAsyncDone(iteration) { })(); (function() { - Promise.reject(5).then(assertUnreachable, undefined).chain( - assertUnreachable, - function(r) { assertAsync(r === 5, "rejected/then-nohandler-undefined") } - ) - assertAsyncRan() - Promise.reject(6).then(assertUnreachable, null).chain( - assertUnreachable, - function(r) { assertAsync(r === 6, "rejected/then-nohandler-null") } - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - // Note: Chain now has then-style semantics, here and in future tests. - p3.chain( - function(x) { assertAsync(x === 5, "resolved/chain") }, - assertUnreachable - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) p3.then( function(x) { assertAsync(x === 5, "resolved/then") }, assertUnreachable @@ -216,19 +189,8 @@ function assertAsyncDone(iteration) { (function() { var p1 = Promise.reject(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain( - assertUnreachable, - function(x) { assertAsync(x === 5, "rejected/chain") } - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.reject(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) p3.then( assertUnreachable, function(x) { assertAsync(x === 5, "rejected/then") } @@ -237,87 +199,21 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain(function(x) { return x }, assertUnreachable).chain( - function(x) { assertAsync(x === 5, "resolved/chain/chain") }, + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) + p3.then(function(x) { return x }, assertUnreachable).then( + function(x) { assertAsync(x === 5, "resolved/then/then") }, assertUnreachable ) assertAsyncRan() })(); (function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain(function(x) { return x }, assertUnreachable).then( - function(x) { assertAsync(x === 5, "resolved/chain/then") }, - assertUnreachable - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain(function(x) { return 6 }, assertUnreachable).chain( - function(x) { assertAsync(x === 6, "resolved/chain/chain2") }, - assertUnreachable - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain(function(x) { return 6 }, assertUnreachable).then( - function(x) { assertAsync(x === 6, "resolved/chain/then2") }, - assertUnreachable - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.then(function(x) { return x + 1 }, assertUnreachable).chain( - function(x) { assertAsync(x === 6, "resolved/then/chain") }, - assertUnreachable - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.then(function(x) { return x + 1 }, assertUnreachable).then( - function(x) { assertAsync(x === 6, "resolved/then/then") }, - assertUnreachable - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.then(function(x){ return Promise.accept(x+1) }, assertUnreachable).chain( - function(x) { assertAsync(x === 6, "resolved/then/chain2") }, - assertUnreachable - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.then(function(x) { return Promise.accept(x+1) }, assertUnreachable).then( + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) + p3.then(function(x){ return Promise.resolve(x+1) }, assertUnreachable).then( function(x) { assertAsync(x === 6, "resolved/then/then2") }, assertUnreachable ) @@ -325,42 +221,9 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain(function(x) { throw 6 }, assertUnreachable).chain( - assertUnreachable, - function(x) { assertAsync(x === 6, "resolved/chain-throw/chain") } - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain(function(x) { throw 6 }, assertUnreachable).then( - assertUnreachable, - function(x) { assertAsync(x === 6, "resolved/chain-throw/then") } - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.then(function(x) { throw 6 }, assertUnreachable).chain( - assertUnreachable, - function(x) { assertAsync(x === 6, "resolved/then-throw/chain") } - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) p3.then(function(x) { throw 6 }, assertUnreachable).then( assertUnreachable, function(x) { assertAsync(x === 6, "resolved/then-throw/then") } @@ -369,20 +232,53 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(5) + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) + p3.then(function(x) { throw 6 }, assertUnreachable).then( + assertUnreachable, + function(x) { assertAsync(x === 6, "resolved/then-throw/then") } + ) + assertAsyncRan() +})(); + +(function() { + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) + p3.then(function(x) { throw 6 }, assertUnreachable).then( + assertUnreachable, + function(x) { assertAsync(x === 6, "resolved/then-throw/then") } + ) + assertAsyncRan() +})(); + +(function() { + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) + p3.then(function(x) { throw 6 }, assertUnreachable).then( + assertUnreachable, + function(x) { assertAsync(x === 6, "resolved/then-throw/then") } + ) + assertAsyncRan() +})(); + +(function() { + var p1 = Promise.resolve(5) var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) - p3.chain( - function(x) { assertAsync(x === 5, "resolved/thenable/chain") }, + var p3 = Promise.resolve(p2) + p3.then( + function(x) { assertAsync(x === 5, "resolved/thenable/then") }, assertUnreachable ) assertAsyncRan() })(); (function() { - var p1 = Promise.accept(5) + var p1 = Promise.resolve(5) var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) + var p3 = Promise.resolve(p2) p3.then( function(x) { assertAsync(x === 5, "resolved/thenable/then") }, assertUnreachable @@ -393,18 +289,7 @@ function assertAsyncDone(iteration) { (function() { var p1 = Promise.reject(5) var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) - p3.chain( - assertUnreachable, - function(x) { assertAsync(x === 5, "rejected/thenable/chain") } - ) - assertAsyncRan() -})(); - -(function() { - var p1 = Promise.reject(5) - var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) + var p3 = Promise.resolve(p2) p3.then( assertUnreachable, function(x) { assertAsync(x === 5, "rejected/thenable/then") } @@ -413,20 +298,18 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() - var p1 = deferred.promise - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain( - function(x) { assertAsync(x === 5, "chain/resolve") }, - assertUnreachable + var p1 = Promise.reject(5) + var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} + var p3 = Promise.resolve(p2) + p3.then( + assertUnreachable, + function(x) { assertAsync(x === 5, "rejected/thenable/then") } ) - deferred.resolve(5) assertAsyncRan() })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise var p2 = Promise.resolve(p1) var p3 = Promise.resolve(p2) @@ -439,23 +322,23 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) - p3.chain( - assertUnreachable, - function(x) { assertAsync(x === 5, "chain/reject") } + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) + p3.then( + function(x) { assertAsync(x === 5, "then/resolve") }, + assertUnreachable ) - deferred.reject(5) + deferred.resolve(5) assertAsyncRan() })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise - var p2 = Promise.accept(p1) - var p3 = Promise.accept(p2) + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) p3.then( assertUnreachable, function(x) { assertAsync(x === 5, "then/reject") } @@ -465,7 +348,20 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) + var p1 = deferred.promise + var p2 = Promise.resolve(p1) + var p3 = Promise.resolve(p2) + p3.then( + assertUnreachable, + function(x) { assertAsync(x === 5, "then/reject") } + ) + deferred.reject(5) + assertAsyncRan() +})(); + +(function() { + var deferred = defer(Promise) var p1 = deferred.promise var p2 = p1.then(1, 2) p2.then( @@ -477,7 +373,7 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise var p2 = p1.then(1, 2) p2.then( @@ -489,23 +385,10 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) - p3.chain( - function(x) { assertAsync(x === 5, "chain/resolve/thenable") }, - assertUnreachable - ) - deferred.resolve(5) - assertAsyncRan() -})(); - -(function() { - var deferred = Promise.defer() - var p1 = deferred.promise - var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) + var p3 = Promise.resolve(p2) p3.then( function(x) { assertAsync(x === 5, "then/resolve/thenable") }, assertUnreachable @@ -515,23 +398,23 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) - p3.chain( - assertUnreachable, - function(x) { assertAsync(x === 5, "chain/reject/thenable") } + var p3 = Promise.resolve(p2) + p3.then( + function(x) { assertAsync(x === 5, "then/resolve/thenable") }, + assertUnreachable ) - deferred.reject(5) + deferred.resolve(5) assertAsyncRan() })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var p3 = Promise.accept(p2) + var p3 = Promise.resolve(p2) p3.then( assertUnreachable, function(x) { assertAsync(x === 5, "then/reject/thenable") } @@ -541,22 +424,22 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var deferred = Promise.defer() - var p3 = deferred.promise - p3.chain( - function(x) { assertAsync(x === 5, "chain/resolve2") }, - assertUnreachable + var deferred = defer(Promise) + var p1 = deferred.promise + var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} + var p3 = Promise.resolve(p2) + p3.then( + assertUnreachable, + function(x) { assertAsync(x === 5, "then/reject/thenable") } ) - deferred.resolve(p2) + deferred.reject(5) assertAsyncRan() })(); (function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var deferred = Promise.defer() + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var deferred = defer(Promise) var p3 = deferred.promise p3.then( function(x) { assertAsync(x === 5, "then/resolve2") }, @@ -567,22 +450,22 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var deferred = Promise.defer() + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var deferred = defer(Promise) var p3 = deferred.promise - p3.chain( - assertUnreachable, - function(x) { assertAsync(x === 5, "chain/reject2") } + p3.then( + function(x) { assertAsync(x === 5, "then/resolve2") }, + assertUnreachable ) - deferred.reject(5) + deferred.resolve(p2) assertAsyncRan() })(); (function() { - var p1 = Promise.accept(5) - var p2 = Promise.accept(p1) - var deferred = Promise.defer() + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var deferred = defer(Promise) var p3 = deferred.promise p3.then( assertUnreachable, @@ -593,22 +476,22 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(5) - var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var deferred = Promise.defer() + var p1 = Promise.resolve(5) + var p2 = Promise.resolve(p1) + var deferred = defer(Promise) var p3 = deferred.promise - p3.chain( - function(x) { assertAsync(x === 5, "chain/resolve/thenable2") }, - assertUnreachable + p3.then( + assertUnreachable, + function(x) { assertAsync(x === 5, "then/reject2") } ) - deferred.resolve(p2) + deferred.reject(5) assertAsyncRan() })(); (function() { - var p1 = Promise.accept(5) + var p1 = Promise.resolve(5) var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} - var deferred = Promise.defer() + var deferred = defer(Promise) var p3 = deferred.promise p3.then( function(x) { assertAsync(x === 5, "then/resolve/thenable2") }, @@ -619,19 +502,22 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(0) - var p2 = p1.chain(function(x) { return p2 }, assertUnreachable) - p2.chain( - assertUnreachable, - function(r) { assertAsync(r instanceof TypeError, "cyclic/chain") } + var p1 = Promise.resolve(5) + var p2 = {then: function(onResolve, onReject) { onResolve(p1) }} + var deferred = defer(Promise) + var p3 = deferred.promise + p3.then( + function(x) { assertAsync(x === 5, "then/resolve/thenable2") }, + assertUnreachable ) + deferred.resolve(p2) assertAsyncRan() })(); (function() { - var p1 = Promise.accept(0) + var p1 = Promise.resolve(0) var p2 = p1.then(function(x) { return p2 }, assertUnreachable) - p2.chain( + p2.then( assertUnreachable, function(r) { assertAsync(r instanceof TypeError, "cyclic/then") } ) @@ -639,18 +525,17 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() - var p = deferred.promise - deferred.resolve(p) - p.chain( + var p1 = Promise.resolve(0) + var p2 = p1.then(function(x) { return p2 }, assertUnreachable) + p2.then( assertUnreachable, - function(r) { assertAsync(r instanceof TypeError, "cyclic/deferred/then") } + function(r) { assertAsync(r instanceof TypeError, "cyclic/then") } ) assertAsyncRan() })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p = deferred.promise deferred.resolve(p) p.then( @@ -661,7 +546,18 @@ function assertAsyncDone(iteration) { })(); (function() { - Promise.all([]).chain( + var deferred = defer(Promise) + var p = deferred.promise + deferred.resolve(p) + p.then( + assertUnreachable, + function(r) { assertAsync(r instanceof TypeError, "cyclic/deferred/then") } + ) + assertAsyncRan() +})(); + +(function() { + Promise.all([]).then( function(x) { assertAsync(x.length === 0, "all/resolve/empty") }, assertUnreachable ) @@ -670,7 +566,7 @@ function assertAsyncDone(iteration) { (function() { function testPromiseAllNonIterable(value) { - Promise.all(value).chain( + Promise.all(value).then( assertUnreachable, function(r) { assertAsync(r instanceof TypeError, 'all/non iterable'); @@ -684,14 +580,14 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer(); + var deferred = defer(Promise); var p = deferred.promise; function* f() { yield 1; yield p; yield 3; } - Promise.all(f()).chain( + Promise.all(f()).then( function(x) { assertAsync(x.length === 3, "all/resolve/iterable"); assertAsync(x[0] === 1, "all/resolve/iterable/0"); @@ -708,13 +604,13 @@ function assertAsyncDone(iteration) { (function() { - var deferred1 = Promise.defer() + var deferred1 = defer(Promise) var p1 = deferred1.promise - var deferred2 = Promise.defer() + var deferred2 = defer(Promise) var p2 = deferred2.promise - var deferred3 = Promise.defer() + var deferred3 = defer(Promise) var p3 = deferred3.promise - Promise.all([p1, p2, p3]).chain( + Promise.all([p1, p2, p3]).then( function(x) { assertAsync(x.length === 3, "all/resolve") assertAsync(x[0] === 1, "all/resolve/0") @@ -733,11 +629,11 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise - var p2 = Promise.accept(2) - var p3 = Promise.defer().promise - Promise.all([p1, p2, p3]).chain( + var p2 = Promise.resolve(2) + var p3 = defer(Promise).promise + Promise.all([p1, p2, p3]).then( assertUnreachable, assertUnreachable ) @@ -745,13 +641,13 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred1 = Promise.defer() + var deferred1 = defer(Promise) var p1 = deferred1.promise - var deferred2 = Promise.defer() + var deferred2 = defer(Promise) var p2 = deferred2.promise - var deferred3 = Promise.defer() + var deferred3 = defer(Promise) var p3 = deferred3.promise - Promise.all([p1, p2, p3]).chain( + Promise.all([p1, p2, p3]).then( assertUnreachable, function(x) { assertAsync(x === 2, "all/reject") } ) @@ -786,7 +682,7 @@ function assertAsyncDone(iteration) { configurable: true }); - Promise.all(3).chain( + Promise.all(3).then( function(x) { assertAsync(x.length === 3, "all/iterable/number/length"); assertAsync(x[0] === 0, "all/iterable/number/0"); @@ -807,17 +703,17 @@ function assertAsyncDone(iteration) { (function() { - Promise.race([]).chain( + Promise.race([]).then( assertUnreachable, assertUnreachable ) })(); (function() { - var p1 = Promise.accept(1) - var p2 = Promise.accept(2) - var p3 = Promise.accept(3) - Promise.race([p1, p2, p3]).chain( + var p1 = Promise.resolve(1) + var p2 = Promise.resolve(2) + var p3 = Promise.resolve(3) + Promise.race([p1, p2, p3]).then( function(x) { assertAsync(x === 1, "resolved/one") }, assertUnreachable ) @@ -825,10 +721,10 @@ function assertAsyncDone(iteration) { })(); (function() { - var p1 = Promise.accept(1) - var p2 = Promise.accept(2) - var p3 = Promise.accept(3) - Promise.race([0, p1, p2, p3]).chain( + var p1 = Promise.resolve(1) + var p2 = Promise.resolve(2) + var p3 = Promise.resolve(3) + Promise.race([0, p1, p2, p3]).then( function(x) { assertAsync(x === 0, "resolved-const/one") }, assertUnreachable ) @@ -836,13 +732,13 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred1 = Promise.defer() + var deferred1 = defer(Promise) var p1 = deferred1.promise - var deferred2 = Promise.defer() + var deferred2 = defer(Promise) var p2 = deferred2.promise - var deferred3 = Promise.defer() + var deferred3 = defer(Promise) var p3 = deferred3.promise - Promise.race([p1, p2, p3]).chain( + Promise.race([p1, p2, p3]).then( function(x) { assertAsync(x === 3, "one/resolve") }, assertUnreachable ) @@ -852,11 +748,11 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred = Promise.defer() + var deferred = defer(Promise) var p1 = deferred.promise - var p2 = Promise.accept(2) - var p3 = Promise.defer().promise - Promise.race([p1, p2, p3]).chain( + var p2 = Promise.resolve(2) + var p3 = defer(Promise).promise + Promise.race([p1, p2, p3]).then( function(x) { assertAsync(x === 2, "resolved/one") }, assertUnreachable ) @@ -865,13 +761,13 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred1 = Promise.defer() + var deferred1 = defer(Promise) var p1 = deferred1.promise - var deferred2 = Promise.defer() + var deferred2 = defer(Promise) var p2 = deferred2.promise - var deferred3 = Promise.defer() + var deferred3 = defer(Promise) var p3 = deferred3.promise - Promise.race([p1, p2, p3]).chain( + Promise.race([p1, p2, p3]).then( function(x) { assertAsync(x === 3, "one/resolve/reject") }, assertUnreachable ) @@ -881,13 +777,13 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred1 = Promise.defer() + var deferred1 = defer(Promise) var p1 = deferred1.promise - var deferred2 = Promise.defer() + var deferred2 = defer(Promise) var p2 = deferred2.promise - var deferred3 = Promise.defer() + var deferred3 = defer(Promise) var p3 = deferred3.promise - Promise.race([p1, p2, p3]).chain( + Promise.race([p1, p2, p3]).then( assertUnreachable, function(x) { assertAsync(x === 3, "one/reject/resolve") } ) @@ -899,7 +795,7 @@ function assertAsyncDone(iteration) { (function() { function testPromiseRaceNonIterable(value) { - Promise.race(value).chain( + Promise.race(value).then( assertUnreachable, function(r) { assertAsync(r instanceof TypeError, 'race/non iterable'); @@ -914,18 +810,18 @@ function assertAsyncDone(iteration) { (function() { - var deferred1 = Promise.defer() + var deferred1 = defer(Promise) var p1 = deferred1.promise - var deferred2 = Promise.defer() + var deferred2 = defer(Promise) var p2 = deferred2.promise - var deferred3 = Promise.defer() + var deferred3 = defer(Promise) var p3 = deferred3.promise function* f() { yield p1; yield p2; yield p3; } - Promise.race(f()).chain( + Promise.race(f()).then( function(x) { assertAsync(x === 3, "race/iterable/resolve/reject") }, assertUnreachable ) @@ -935,18 +831,18 @@ function assertAsyncDone(iteration) { })(); (function() { - var deferred1 = Promise.defer() + var deferred1 = defer(Promise) var p1 = deferred1.promise - var deferred2 = Promise.defer() + var deferred2 = defer(Promise) var p2 = deferred2.promise - var deferred3 = Promise.defer() + var deferred3 = defer(Promise) var p3 = deferred3.promise function* f() { yield p1; yield p2; yield p3; } - Promise.race(f()).chain( + Promise.race(f()).then( assertUnreachable, function(x) { assertAsync(x === 3, "race/iterable/reject/resolve") } ) @@ -980,7 +876,7 @@ function assertAsyncDone(iteration) { configurable: true }); - Promise.race(3).chain( + Promise.race(3).then( function(x) { assertAsync(x === 0, "race/iterable/number"); }, @@ -1014,18 +910,18 @@ function assertAsyncDone(iteration) { } MyPromise.prototype.__proto__ = Promise.prototype - MyPromise.prototype.chain = function(resolve, reject) { + MyPromise.prototype.then = function(resolve, reject) { log += "c" - return call(this.__proto__.__proto__.chain, this, resolve, reject) + return call(this.__proto__.__proto__.then, this, resolve, reject) } log = "" var p1 = new MyPromise(function(resolve, reject) { resolve(1) }) var p2 = new MyPromise(function(resolve, reject) { reject(2) }) - var d3 = MyPromise.defer() + var d3 = defer(MyPromise) assertTrue(d3.promise instanceof Promise, "subclass/instance") assertTrue(d3.promise instanceof MyPromise, "subclass/instance-my3") - assertTrue(log === "nx1nr2dn", "subclass/create") + assertTrue(log === "nx1nr2n", "subclass/create") log = "" var p4 = MyPromise.resolve(4) @@ -1038,21 +934,21 @@ function assertAsyncDone(iteration) { assertTrue(log === "nx4nr5x3", "subclass/resolve") log = "" - var d6 = MyPromise.defer() - d6.promise.chain(function(x) { + var d6 = defer(MyPromise) + d6.promise.then(function(x) { return new Promise(function(resolve) { resolve(x) }) - }).chain(function() {}) + }).then(function() {}) d6.resolve(6) - assertTrue(log === "dncncnx6", "subclass/chain") + assertTrue(log === "ncncnx6", "subclass/then") log = "" - Promise.all([11, Promise.accept(12), 13, MyPromise.accept(14), 15, 16]) + Promise.all([11, Promise.resolve(12), 13, MyPromise.resolve(14), 15, 16]) assertTrue(log === "nx14", "subclass/all/arg") log = "" - MyPromise.all([21, Promise.accept(22), 23, MyPromise.accept(24), 25, 26]) - assertTrue(log === "nx24nnx21nnx[object Promise]nnx23nnnx25nnx26n", + MyPromise.all([21, Promise.resolve(22), 23, MyPromise.resolve(24), 25, 26]) + assertTrue(log === "nx24nnx21cnnx[object Promise]cnnx23cncnnx25cnnx26cn", "subclass/all/self") })(); diff --git a/test/mjsunit/es6/regress/regress-cr372788.js b/test/mjsunit/es6/regress/regress-cr372788.js index 3144b39830..c157a7e79f 100644 --- a/test/mjsunit/es6/regress/regress-cr372788.js +++ b/test/mjsunit/es6/regress/regress-cr372788.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax --promise-extra +// Flags: --allow-natives-syntax var x = 0; var y = 0; @@ -38,7 +38,7 @@ for (var i = 0; i < 3; ++i) { assertEquals(0, x); (function check() { - Promise.resolve().chain(function() { + Promise.resolve().then(function() { // Delay check until all handlers have run. if (y < 3) check(); else assertEquals(6, x); }).catch(function(e) { %AbortJS("FAILURE: " + e) }); diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index cfc4a16b5d..62f720a974 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -518,7 +518,7 @@ ############################################################################## ['system == windows', { # TODO(mstarzinger): Too slow with turbo fan. - 'big-object-literal': [PASS, ['mode == debug', SKIP]], + 'big-object-literal': [SKIP], 'math-floor-of-div': [PASS, ['mode == debug', SKIP]], 'math-floor-of-div-nosudiv': [PASS, ['mode == debug', SKIP]], 'unicodelctest': [PASS, ['mode == debug', SKIP]],