PromiseCoerce should ignore primitive values.
authorrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 11 Mar 2014 10:41:18 +0000 (10:41 +0000)
committerrossberg@chromium.org <rossberg@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 11 Mar 2014 10:41:18 +0000 (10:41 +0000)
PromiseCource(x) should return "not a thenable" if Type(x) is not Object
even if x.then exists.

BUG=347095
LOG=Y
R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/194403002

Patch from Yutaka Hirano <yhirano@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19788 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/promise.js

index 2c36d4d..fb33beb 100644 (file)
@@ -217,7 +217,7 @@ function PromiseThen(onResolve, onReject) {
 PromiseCoerce.table = new $WeakMap;
 
 function PromiseCoerce(constructor, x) {
-  if (!(IsPromise(x) || IS_NULL_OR_UNDEFINED(x))) {
+  if (!IsPromise(x) && IS_SPEC_OBJECT(x)) {
     var then = x.then;
     if (typeof then === 'function') {
       if (PromiseCoerce.table.has(x)) {