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

Side by Side Diff: test/mjsunit/es6/debug-promises/promise-race-uncaught.js

Issue 2497973002: [debug-wrapper] Further extend the debug wrapper (Closed)
Patch Set: Address comments Created 4 years, 1 month 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.race has no catch handler, and is rejected
9 // because one of the Promises p2 passed to Promise.race is rejected.
10 // We expect one event for p2; the system recognizes the rejection of p3
11 // to be redundant and based on the rejection of p2 and does not trigger
12 // an additional rejection.
13
14 var Debug = debug.Debug;
15
16 var expected_events = 1;
17 var log = [];
18
19 function listener(event, exec_state, event_data, data) {
20 if (event != Debug.DebugEvent.Exception) return;
21 try {
22 expected_events--;
23 assertTrue(expected_events >= 0);
24 assertEquals("uncaught", event_data.exception().message);
25 assertTrue(event_data.promise() instanceof Promise);
26 // Assert that the debug event is triggered at the throw site.
27 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
28 assertEquals("p2", event_data.promise().name);
29 assertTrue(event_data.uncaught());
30 } catch (e) {
31 %AbortJS(e + "\n" + e.stack);
32 }
33 }
34
35 Debug.setBreakOnUncaughtException();
36 Debug.setListener(listener);
37
38 var p1 = Promise.resolve();
39 p1.name = "p1";
40
41 var p2 = p1.then(function() {
42 log.push("throw");
43 throw new Error("uncaught"); // event
44 });
45
46 p2.name = "p2";
47
48 var p3 = Promise.race([p2]);
49 p3.name = "p3";
50
51 log.push("end main");
52
53 function testDone(iteration) {
54 function checkResult() {
55 try {
56 assertTrue(iteration < 10);
57 if (expected_events === 0) {
58 assertEquals(["end main", "throw"], log);
59 } else {
60 testDone(iteration + 1);
61 }
62 } catch (e) {
63 %AbortJS(e + "\n" + e.stack);
64 }
65 }
66
67 %EnqueueMicrotask(checkResult);
68 }
69
70 testDone(0);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-promises/promise-all-uncaught.js ('k') | test/mjsunit/es6/debug-promises/reject-caught-all.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698