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

Side by Side Diff: test/debugger/debug/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
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --expose-debug-as debug --allow-natives-syntax
6 5
7 // Test debug events when we only listen to uncaught exceptions and 6 // 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. 7 // 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 8 // We expect only one debug event: when the first Promise is rejected
10 // and only has default reject handlers. No event is triggered when 9 // and only has default reject handlers. No event is triggered when
11 // simply forwarding the rejection with .then's default handler. 10 // simply forwarding the rejection with .then's default handler.
12 11
13 Debug = debug.Debug; 12 Debug = debug.Debug;
14 13
15 var expected_events = 1; 14 var expected_events = 1;
(...skipping 19 matching lines...) Expand all
35 resolve(); 34 resolve();
36 }) 35 })
37 36
38 37
39 function listener(event, exec_state, event_data, data) { 38 function listener(event, exec_state, event_data, data) {
40 try { 39 try {
41 if (event == Debug.DebugEvent.Exception) { 40 if (event == Debug.DebugEvent.Exception) {
42 expected_events--; 41 expected_events--;
43 assertTrue(expected_events >= 0); 42 assertTrue(expected_events >= 0);
44 assertTrue(event_data.uncaught()); 43 assertTrue(event_data.uncaught());
45 assertTrue(event_data.promise() instanceof Promise);
46 // p1 is rejected, uncaught, with the error from the Promise.reject line 44 // p1 is rejected, uncaught, with the error from the Promise.reject line
47 assertNotNull(event_data.sourceLineText().match("Promise.reject")); 45 assertNotNull(event_data.sourceLineText().match("Promise.reject"));
48 assertSame(p1, event_data.promise());
49 } 46 }
50 } catch (e) { 47 } catch (e) {
51 %AbortJS(e + "\n" + e.stack); 48 %AbortJS(e + "\n" + e.stack);
52 } 49 }
53 } 50 }
54 51
55 Debug.setBreakOnUncaughtException(); 52 Debug.setBreakOnUncaughtException();
56 Debug.setListener(listener); 53 Debug.setListener(listener);
57 54
58 log.push("end main"); 55 log.push("end main");
59 56
60 function testDone(iteration) { 57 function testDone(iteration) {
61 function checkResult() { 58 function checkResult() {
62 try { 59 try {
63 assertTrue(iteration < 10); 60 assertTrue(iteration < 10);
64 if (expected_events === 0) { 61 if (expected_events === 0) {
65 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log); 62 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log);
66 } else { 63 } else {
67 testDone(iteration + 1); 64 testDone(iteration + 1);
68 } 65 }
69 } catch (e) { 66 } catch (e) {
70 %AbortJS(e + "\n" + e.stack); 67 %AbortJS(e + "\n" + e.stack);
71 } 68 }
72 } 69 }
73 70
74 %EnqueueMicrotask(checkResult); 71 %EnqueueMicrotask(checkResult);
75 } 72 }
76 73
77 testDone(0); 74 testDone(0);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698