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

Unified Diff: src/js/promise.js

Issue 1411083003: Debugger: correctly report uncaught rejections in Promise.all and Promise.race. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: move deferred from promise to handler Created 5 years, 2 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 | « src/heap/heap.h ('k') | test/mjsunit/es6/debug-promises/promise-all-caught.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/promise.js
diff --git a/src/js/promise.js b/src/js/promise.js
index b4a25846cada38d99e5a3ddadd1cf25f39e2953b..b3ff059cde935c33685d96a9719b3e8331f94ffe 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -12,6 +12,8 @@
// Imports
var InternalArray = utils.InternalArray;
+var promiseCombinedDeferredSymbol =
+ utils.ImportNow("promise_combined_deferred_symbol");
var promiseHasHandlerSymbol =
utils.ImportNow("promise_has_handler_symbol");
var promiseOnRejectSymbol = utils.ImportNow("promise_on_reject_symbol");
@@ -298,6 +300,7 @@ function PromiseAll(iterable) {
var count = 0;
var i = 0;
for (var value of iterable) {
+ var reject = function(r) { deferred.reject(r) };
this.resolve(value).then(
// Nested scope to get closure over current i.
// TODO(arv): Use an inner let binding once available.
@@ -306,8 +309,8 @@ function PromiseAll(iterable) {
resolutions[i] = x;
if (--count === 0) deferred.resolve(resolutions);
}
- })(i),
- function(r) { deferred.reject(r); });
+ })(i), reject);
+ SET_PRIVATE(reject, promiseCombinedDeferredSymbol, deferred);
++i;
++count;
}
@@ -326,9 +329,9 @@ function PromiseRace(iterable) {
var deferred = %_CallFunction(this, PromiseDeferred);
try {
for (var value of iterable) {
- this.resolve(value).then(
- function(x) { deferred.resolve(x) },
- function(r) { deferred.reject(r) });
+ var reject = function(r) { deferred.reject(r) };
+ this.resolve(value).then(function(x) { deferred.resolve(x) }, reject);
Yang 2015/10/20 05:15:49 then() may not even return a Promise, if it's over
+ SET_PRIVATE(reject, promiseCombinedDeferredSymbol, deferred);
}
} catch (e) {
deferred.reject(e)
@@ -343,8 +346,15 @@ function PromiseHasUserDefinedRejectHandlerRecursive(promise) {
var queue = GET_PRIVATE(promise, promiseOnRejectSymbol);
if (IS_UNDEFINED(queue)) return false;
for (var i = 0; i < queue.length; i += 2) {
- if (queue[i] != PromiseIdRejectHandler) return true;
- if (PromiseHasUserDefinedRejectHandlerRecursive(queue[i + 1].promise)) {
+ var handler = queue[i];
+ if (handler !== PromiseIdRejectHandler) {
+ var deferred = GET_PRIVATE(handler, promiseCombinedDeferredSymbol);
+ if (IS_UNDEFINED(deferred)) return true;
+ if (PromiseHasUserDefinedRejectHandlerRecursive(deferred.promise)) {
+ return true;
+ }
+ } else if (PromiseHasUserDefinedRejectHandlerRecursive(
+ queue[i + 1].promise)) {
return true;
}
}
« no previous file with comments | « src/heap/heap.h ('k') | test/mjsunit/es6/debug-promises/promise-all-caught.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698