Reviewers: rossberg,
Message:
PTAL
https://codereview.chromium.org/214663009/diff/1/src/promise.js
File src/promise.js (right):
https://codereview.chromium.org/214663009/diff/1/src/promise.js#newcode203
src/promise.js:203: if (typeof onResolve !== 'function') onResolve =
PromiseIdResolveHandler;
Maybe we should add an IsCallable macro?
Description:
ES6: Promise.prototyp.then should use callable for its arguments
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise.prototype.then
We used to use the default id handlers if the argument was null or
undefined. The spec says that we should use IsCallable instead.
BUG=None
LOG=Y
[email protected]
Please review this at https://codereview.chromium.org/214663009/
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+32, -4 lines):
M src/promise.js
M test/mjsunit/es6/promises.js
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index
50f91ae0ba3443f4b9113b6395e68af396bb71a8..29f641d55d6a8ff3343d38e33b348d05607f4640
100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -200,10 +200,8 @@ function PromiseHandle(value, handler, deferred) {
// Multi-unwrapped chaining with thenable coercion.
function PromiseThen(onResolve, onReject) {
- onResolve =
- IS_NULL_OR_UNDEFINED(onResolve) ? PromiseIdResolveHandler : onResolve;
- onReject =
- IS_NULL_OR_UNDEFINED(onReject) ? PromiseIdRejectHandler : onReject;
+ if (typeof onResolve !== 'function') onResolve = PromiseIdResolveHandler;
+ if (typeof onReject !== 'function') onReject = PromiseIdRejectHandler;
var that = this;
var constructor = this.constructor;
return %_CallFunction(
Index: test/mjsunit/es6/promises.js
diff --git a/test/mjsunit/es6/promises.js b/test/mjsunit/es6/promises.js
index
96a7bbbf3f6e5c5fca86732464aae33567f33a92..280e4b39d7be5bc5398f78622aa848e278555f38
100644
--- a/test/mjsunit/es6/promises.js
+++ b/test/mjsunit/es6/promises.js
@@ -109,6 +109,21 @@ function assertAsyncDone(iteration) {
assertUnreachable
)
assertAsyncRan()
+ Promise.accept(7).then(false, assertUnreachable).chain(
+ function(x) { assertAsync(x === 7, "resolved/then-nohandler-false") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+ Promise.accept(8).then(42, assertUnreachable).chain(
+ function(x) { assertAsync(x === 8, "resolved/then-nohandler-42") },
+ assertUnreachable
+ )
+ assertAsyncRan()
+ Promise.accept(9).then({}, assertUnreachable).chain(
+ function(x) { assertAsync(x === 9, "resolved/then-nohandler-object") },
+ assertUnreachable
+ )
+ assertAsyncRan()
})();
(function() {
@@ -122,6 +137,21 @@ function assertAsyncDone(iteration) {
function(r) { assertAsync(r === 6, "rejected/then-nohandler-null") }
)
assertAsyncRan()
+ Promise.reject(7).then(assertUnreachable, false).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r === 7, "rejected/then-nohandler-false") }
+ )
+ assertAsyncRan()
+ Promise.reject(8).then(assertUnreachable, 42).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r === 8, "rejected/then-nohandler-42") }
+ )
+ assertAsyncRan()
+ Promise.reject(9).then(assertUnreachable, {}).chain(
+ assertUnreachable,
+ function(r) { assertAsync(r === 9, "rejected/then-nohandler-object") }
+ )
+ assertAsyncRan()
})();
(function() {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.