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

Unified Diff: src/promise.js

Issue 194483002: PromiseCoerce should deal with an error during accessing "then". (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: rebase Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index 8e22c315a3b140bd27afbefbb23bbca775f7e69a..f700be909264cee92f077d60c5f331613ae86aed 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698