OLD | NEW |
| (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 --harmony-default-parameters | |
6 | |
7 // Get the Debug object exposed from the debug context global object. | |
8 Debug = debug.Debug | |
9 | |
10 listenerComplete = false; | |
11 breakPointCount = 0; | |
12 | |
13 function listener(event, exec_state, event_data, data) { | |
14 if (event == Debug.DebugEvent.Break) { | |
15 breakPointCount++; | |
16 if (breakPointCount == 1) { | |
17 // Break point in initializer for parameter `a`, invoked by | |
18 // initializer for parameter `b` | |
19 assertEquals('default', exec_state.frame(1).evaluate('mode').value()); | |
20 | |
21 // initializer for `b` can't refer to `b` | |
22 assertThrows(function() { | |
23 exec_state.frame(1).evaluate('b').value(); | |
24 }, ReferenceError); | |
25 | |
26 assertThrows(function() { | |
27 exec_state.frame(1).evaluate('c'); | |
28 }, ReferenceError); | |
29 } else if (breakPointCount == 2) { | |
30 // Break point in IIFE initializer for parameter `c` | |
31 assertEquals('modeFn', exec_state.frame(1).evaluate('a.name').value()); | |
32 assertEquals('default', exec_state.frame(1).evaluate('b').value()); | |
33 assertThrows(function() { | |
34 exec_state.frame(1).evaluate('c'); | |
35 }, ReferenceError); | |
36 } else if (breakPointCount == 3) { | |
37 // Break point in function body --- `c` parameter is shadowed | |
38 assertEquals('modeFn', exec_state.frame(0).evaluate('a.name').value()); | |
39 assertEquals('default', exec_state.frame(0).evaluate('b').value()); | |
40 assertEquals('local', exec_state.frame(0).evaluate('d').value()); | |
41 } | |
42 } | |
43 }; | |
44 | |
45 // Add the debug event listener. | |
46 Debug.setListener(listener); | |
47 | |
48 function f(a = function modeFn(mode) { debugger; return mode; }, | |
49 b = a("default"), | |
50 c = (function() { debugger; })()) { | |
51 var d = 'local'; | |
52 debugger; | |
53 }; | |
54 | |
55 f(); | |
56 | |
57 // Make sure that the debug event listener vas invoked. | |
58 assertEquals(3, breakPointCount); | |
OLD | NEW |