Index: test/mjsunit/es6/throw-caught-by-default-reject-handler.js |
diff --git a/test/mjsunit/es6/debug-promises/reject-uncaught-late.js b/test/mjsunit/es6/throw-caught-by-default-reject-handler.js |
similarity index 61% |
copy from test/mjsunit/es6/debug-promises/reject-uncaught-late.js |
copy to test/mjsunit/es6/throw-caught-by-default-reject-handler.js |
index 4a883da13a793972d00fd2f4a9f8311b15b04811..89fc060c9f2778f1f3fc1dabf88659292ac78a05 100644 |
--- a/test/mjsunit/es6/debug-promises/reject-uncaught-late.js |
+++ b/test/mjsunit/es6/throw-caught-by-default-reject-handler.js |
@@ -10,24 +10,27 @@ |
Debug = debug.Debug; |
-var expected_events = 1; |
+var expected_events = 2; |
var log = []; |
-var reject_closure; |
- |
-var p = new Promise(function(resolve, reject) { |
- log.push("postpone p"); |
- reject_closure = reject; |
+var resolve, reject; |
+var p0 = new Promise(function(res, rej) { resolve = res; reject = rej; }); |
+var p1 = p0.then(function() { |
+ log.push("p0.then"); |
+ throw new Error("123"); // event |
+}); |
+var p2 = p1.then(function() { |
+ log.push("p1.then"); |
}); |
-var q = new Promise(function(resolve, reject) { |
+var q = new Promise(function(res, rej) { |
log.push("resolve q"); |
- resolve(); |
+ res(); |
}); |
q.then(function() { |
- log.push("reject p"); |
- reject_closure(new Error("uncaught reject p")); // event |
+ log.push("resolve p"); |
+ resolve(); |
}) |
@@ -36,12 +39,18 @@ function listener(event, exec_state, event_data, data) { |
if (event == Debug.DebugEvent.Exception) { |
expected_events--; |
assertTrue(expected_events >= 0); |
- assertEquals("uncaught reject p", event_data.exception().message); |
- assertTrue(event_data.promise() instanceof Promise); |
- assertSame(p, event_data.promise()); |
assertTrue(event_data.uncaught()); |
- // Assert that the debug event is triggered at the throw site. |
- assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0); |
+ 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. |
aandrey
2014/08/13 11:03:04
do we want the debugger to stop twice in this exam
Yang
2014/08/13 11:13:49
I'm not sure. Maybe we should suppress rejections
aandrey
2014/08/13 11:22:03
I'm not sure either, but DevTools will ignore paus
|
+ assertEquals(0, exec_state.frameCount()); |
+ assertSame(p2, event_data.promise()); |
+ } |
} |
} catch (e) { |
%AbortJS(e + "\n" + e.stack); |
@@ -58,7 +67,7 @@ function testDone(iteration) { |
try { |
assertTrue(iteration < 10); |
if (expected_events === 0) { |
- assertEquals(["postpone p", "resolve q", "end main", "reject p"], log); |
+ assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log); |
aandrey
2014/08/13 11:03:04
ditto
Yang
2014/08/13 11:13:49
Acknowledged.
|
} else { |
testDone(iteration + 1); |
} |