Commit 62592f34 authored by rossberg@chromium.org's avatar rossberg@chromium.org

PromiseCoerce should deal with an error during accessing "then".

PromiseCource(x) should return a rejected promise when accessing x.then
leads to an error.

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

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

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19928 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cf43195d
......@@ -227,7 +227,15 @@ PromiseCoerce.table = new $WeakMap;
function PromiseCoerce(constructor, x) {
if (!IsPromise(x) && IS_SPEC_OBJECT(x)) {
var then = x.then;
var then;
try {
then = x.then;
} catch(e) {
var deferred = %_CallFunction(constructor, PromiseDeferred);
PromiseCoerce.table.set(x, deferred.promise);
deferred.reject(e);
return deferred.promise;
}
if (typeof then === 'function') {
if (PromiseCoerce.table.has(x)) {
return PromiseCoerce.table.get(x);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment