Index: test/mjsunit/es6/reject-caught-by-default-reject-handler.js |
diff --git a/test/mjsunit/es6/debug-promises/reject-uncaught-late.js b/test/mjsunit/es6/reject-caught-by-default-reject-handler.js |
similarity index 63% |
copy from test/mjsunit/es6/debug-promises/reject-uncaught-late.js |
copy to test/mjsunit/es6/reject-caught-by-default-reject-handler.js |
index 4a883da13a793972d00fd2f4a9f8311b15b04811..7760b0eb4cfbb3ffad0f07dac3c13e7918204328 100644 |
--- a/test/mjsunit/es6/debug-promises/reject-uncaught-late.js |
+++ b/test/mjsunit/es6/reject-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"); |
+ return Promise.reject(new Error("123")); |
+}); |
+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,17 @@ 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. |
+ assertEquals(0, exec_state.frameCount()); |
Yang
2014/08/12 13:28:35
Note that this is because the promise is rejected
|
+ 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()); |
+ } |
} |
} catch (e) { |
%AbortJS(e + "\n" + e.stack); |
@@ -58,7 +66,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
should there be "p1.then" as well?
Yang
2014/08/13 11:13:49
No. That code path is never taken, since p1 is rej
|
} else { |
testDone(iteration + 1); |
} |