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

Side by Side Diff: test/debugger/debug/es6/debug-promises/try-throw-reject-in-constructor.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
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 // an exception is thrown in the Promise constructor, but caught in an 7 // an exception is thrown in the Promise constructor, but caught in an
9 // inner try-catch. The Promise is rejected afterwards. 8 // inner try-catch. The Promise is rejected afterwards.
10 // We expect an Exception debug event with a promise to be triggered. 9 // We expect an Exception debug event with a promise to be triggered.
11 10
12 Debug = debug.Debug; 11 Debug = debug.Debug;
13 12
14 var step = 0; 13 var step = 0;
15 var exception = null; 14 var exception = null;
16 15
17 function listener(event, exec_state, event_data, data) { 16 function listener(event, exec_state, event_data, data) {
18 try { 17 try {
19 if (event == Debug.DebugEvent.Exception) { 18 if (event == Debug.DebugEvent.Exception) {
20 assertEquals(0, step); 19 assertEquals(0, step);
21 assertEquals("uncaught", event_data.exception().message); 20 assertEquals("uncaught", event_data.exception().message);
22 assertTrue(event_data.promise() instanceof Promise);
23 assertTrue(event_data.uncaught()); 21 assertTrue(event_data.uncaught());
24 // Assert that the debug event is triggered at the throw site. 22 // Assert that the debug event is triggered at the throw site.
25 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0); 23 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0);
26 step++; 24 step++;
27 } 25 }
28 } catch (e) { 26 } catch (e) {
29 exception = e; 27 exception = e;
30 } 28 }
31 } 29 }
32 30
33 Debug.setBreakOnUncaughtException(); 31 Debug.setBreakOnUncaughtException();
34 Debug.setListener(listener); 32 Debug.setListener(listener);
35 33
36 var p = new Promise(function(resolve, reject) { 34 var p = new Promise(function(resolve, reject) {
37 try { // This try-catch must not prevent this uncaught reject event. 35 try { // This try-catch must not prevent this uncaught reject event.
38 throw new Error("caught"); 36 throw new Error("caught");
39 } catch (e) { } 37 } catch (e) { }
40 reject(new Error("uncaught")); // event 38 reject(new Error("uncaught")); // event
41 }); 39 });
42 40
43 assertEquals(1, step); 41 assertEquals(1, step);
44 assertNull(exception); 42 assertNull(exception);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698