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

Side by Side Diff: test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.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 2014 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
8 // there is only a default reject handler for the to-be-rejected Promise.
9 // We expect only one debug event: when the first Promise is rejected
10 // and only has default reject handlers. No event is triggered when
11 // simply forwarding the rejection with .then's default handler.
12
13 Debug = debug.Debug;
14
15 var expected_events = 1;
16 var log = [];
17
18 var resolve, reject;
19 var p0 = new Promise(function(res, rej) { resolve = res; reject = rej; });
20 var p1 = p0.then(function() {
21 log.push("p0.then");
22 throw new Error("123"); // event
23 });
24 var p2 = p1.then(function() {
25 log.push("p1.then");
26 });
27
28 var q = new Promise(function(res, rej) {
29 log.push("resolve q");
30 res();
31 });
32
33 q.then(function() {
34 log.push("resolve p");
35 resolve();
36 })
37
38
39 function listener(event, exec_state, event_data, data) {
40 try {
41 if (event == Debug.DebugEvent.Exception) {
42 expected_events--;
43 assertTrue(expected_events >= 0);
44 assertTrue(event_data.uncaught());
45 assertTrue(event_data.promise() instanceof Promise);
46 // p1 is rejected, uncaught except for its default reject handler.
47 assertTrue(
48 exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
49 assertSame(p1, event_data.promise());
50 }
51 } catch (e) {
52 %AbortJS(e + "\n" + e.stack);
53 }
54 }
55
56 Debug.setBreakOnUncaughtException();
57 Debug.setListener(listener);
58
59 log.push("end main");
60
61 function testDone(iteration) {
62 function checkResult() {
63 try {
64 assertTrue(iteration < 10);
65 if (expected_events === 0) {
66 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log);
67 } else {
68 testDone(iteration + 1);
69 }
70 } catch (e) {
71 %AbortJS(e + "\n" + e.stack);
72 }
73 }
74
75 %EnqueueMicrotask(checkResult);
76 }
77
78 testDone(0);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-promises/throw-caught-all.js ('k') | test/mjsunit/es6/debug-promises/throw-finally-caught-all.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698