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

Side by Side Diff: test/mjsunit/es6/debug-promises/reject-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 return Promise.reject(new Error("123"));
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, with the error from the Promise.reject line
47 assertNotNull(event_data.sourceLineText().match("Promise.reject"));
48 assertSame(p1, event_data.promise());
49 }
50 } catch (e) {
51 %AbortJS(e + "\n" + e.stack);
52 }
53 }
54
55 Debug.setBreakOnUncaughtException();
56 Debug.setListener(listener);
57
58 log.push("end main");
59
60 function testDone(iteration) {
61 function checkResult() {
62 try {
63 assertTrue(iteration < 10);
64 if (expected_events === 0) {
65 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log);
66 } else {
67 testDone(iteration + 1);
68 }
69 } catch (e) {
70 %AbortJS(e + "\n" + e.stack);
71 }
72 }
73
74 %EnqueueMicrotask(checkResult);
75 }
76
77 testDone(0);
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-promises/reject-caught-all.js ('k') | test/mjsunit/es6/debug-promises/reject-in-constructor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698