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

Side by Side Diff: test/mjsunit/es6/debug-promises/promise-all-uncaught.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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --expose-debug-as debug --allow-natives-syntax
6
7 // Test debug events when we only listen to uncaught exceptions and a
8 // Promise p3 created by Promise.all has no catch handler, and is rejected
9 // because one of the Promises p2 passed to Promise.all is rejected. We
10 // expect two Exception debug events to be triggered, for p2 and p3 each,
11 // because neither has an user-defined catch handler.
12
13 var Debug = debug.Debug;
14
15 var expected_events = 2;
16 var log = [];
17
18 var p1 = Promise.resolve();
19 p1.name = "p1";
20
21 var p2 = p1.then(function() {
22 log.push("throw");
23 throw new Error("uncaught"); // event
24 });
25
26 p2.name = "p2";
27
28 var p3 = Promise.all([p2]);
29 p3.name = "p3";
30
31 function listener(event, exec_state, event_data, data) {
32 if (event != Debug.DebugEvent.Exception) return;
33 try {
34 expected_events--;
35 assertTrue(expected_events >= 0);
36 assertEquals("uncaught", event_data.exception().message);
37 assertTrue(event_data.promise() instanceof Promise);
38 if (expected_events === 1) {
39 // Assert that the debug event is triggered at the throw site.
40 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
41 assertEquals("p2", event_data.promise().name);
42 } else {
43 assertEquals("p3", event_data.promise().name);
44 }
45 assertTrue(event_data.uncaught());
46 } catch (e) {
47 %AbortJS(e + "\n" + e.stack);
48 }
49 }
50
51 Debug.setBreakOnUncaughtException();
52 Debug.setListener(listener);
53
54 log.push("end main");
55
56 function testDone(iteration) {
57 function checkResult() {
58 try {
59 assertTrue(iteration < 10);
60 if (expected_events === 0) {
61 assertEquals(["end main", "throw"], log);
62 } else {
63 testDone(iteration + 1);
64 }
65 } catch (e) {
66 %AbortJS(e + "\n" + e.stack);
67 }
68 }
69
70 %EnqueueMicrotask(checkResult);
71 }
72
73 testDone(0);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698