Commit aae17eb3 authored by littledan's avatar littledan Committed by Commit bot

Do not trigger ExceptionEvents for another forwarding case

This patch fixes up one last case of redundant ExceptionEvents being
triggered in the debugger for Promises--it makes the default reject
handler for Promises (e.g., if the second argument for
Promise.prototype.then is missing) appear to the debugger as a
rethrow.

R=adamk@chromium.org,jgruber@chromium.org
BUG=v8:5167

Review-Url: https://codereview.chromium.org/2278643002
Cr-Commit-Position: refs/heads/master@{#38876}
parent e916dad3
......@@ -216,8 +216,8 @@ function PromiseAttachCallbacks(promise, deferred, onResolve, onReject) {
}
}
function PromiseIdResolveHandler(x) { return x }
function PromiseIdRejectHandler(r) { throw r }
function PromiseIdResolveHandler(x) { return x; }
function PromiseIdRejectHandler(r) { %_ReThrow(r); }
function PromiseNopResolver() {}
......
......@@ -6,13 +6,13 @@
// Test debug events when we only listen to uncaught exceptions and
// there is only a default reject handler for the to-be-rejected Promise.
// We expect two Exception debug events:
// - when the first Promise is rejected and only has default reject handlers.
// - when the default reject handler passes the rejection on.
// We expect only one debug event: when the first Promise is rejected
// and only has default reject handlers. No event is triggered when
// simply forwarding the rejection with .then's default handler.
Debug = debug.Debug;
var expected_events = 2;
var expected_events = 1;
var log = [];
var resolve, reject;
......@@ -43,15 +43,9 @@ function listener(event, exec_state, event_data, data) {
assertTrue(expected_events >= 0);
assertTrue(event_data.uncaught());
assertTrue(event_data.promise() instanceof Promise);
if (expected_events == 1) {
// p1 is rejected, uncaught, with the error from the Promise.reject line
assertNotNull(event_data.sourceLineText().match("Promise.reject"));
assertSame(p1, event_data.promise());
} else {
// p2 is rejected by p1's default reject handler.
assertEquals(0, exec_state.frameCount());
assertSame(p2, event_data.promise());
}
// p1 is rejected, uncaught, with the error from the Promise.reject line
assertNotNull(event_data.sourceLineText().match("Promise.reject"));
assertSame(p1, event_data.promise());
}
} catch (e) {
%AbortJS(e + "\n" + e.stack);
......
......@@ -6,13 +6,13 @@
// Test debug events when we only listen to uncaught exceptions and
// there is only a default reject handler for the to-be-rejected Promise.
// We expect two Exception debug events:
// - when the first Promise is rejected and only has default reject handlers.
// - when the default reject handler passes the rejection on.
// We expect only one debug event: when the first Promise is rejected
// and only has default reject handlers. No event is triggered when
// simply forwarding the rejection with .then's default handler.
Debug = debug.Debug;
var expected_events = 2;
var expected_events = 1;
var log = [];
var resolve, reject;
......@@ -43,16 +43,10 @@ function listener(event, exec_state, event_data, data) {
assertTrue(expected_events >= 0);
assertTrue(event_data.uncaught());
assertTrue(event_data.promise() instanceof Promise);
if (expected_events == 1) {
// p1 is rejected, uncaught except for its default reject handler.
assertTrue(
exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
assertSame(p1, event_data.promise());
} else {
// p2 is rejected by p1's default reject handler.
assertEquals(0, exec_state.frameCount());
assertSame(p2, event_data.promise());
}
// p1 is rejected, uncaught except for its default reject handler.
assertTrue(
exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
assertSame(p1, event_data.promise());
}
} catch (e) {
%AbortJS(e + "\n" + e.stack);
......
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