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

Side by Side Diff: test/mjsunit/debug-evaluate-recursive.js

Issue 2566093002: [debug-wrapper] migrate some scope related tests (Closed)
Patch Set: address comments Created 4 years 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 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 // Flags: --expose-debug-as debug
29 // Get the Debug object exposed from the debug context global object.
30 Debug = debug.Debug
31
32 listenerComplete = false;
33 exception = false;
34
35 // Event listener which evaluates with break disabled.
36 function listener(event, exec_state, event_data, data) {
37 try {
38 if (event == Debug.DebugEvent.Break)
39 {
40 // Call functions with break using the FrameMirror directly.
41 assertEquals(1, exec_state.evaluateGlobal('f()', true).value());
42 assertEquals(2, exec_state.evaluateGlobal('g()', true).value());
43 assertEquals(1, exec_state.frame(0).evaluate('f()', true).value());
44 assertEquals(2, exec_state.frame(0).evaluate('g()', true).value());
45 // Indicate that all was processed.
46 listenerComplete = true;
47 }
48 } catch (e) {
49 exception = e
50 };
51 };
52
53
54 // Event listener which evaluates with break enabled one time and the second
55 // time evaluates with break disabled.
56 var break_count = 0;
57 function listener_recurse(event, exec_state, event_data, data) {
58 try {
59 if (event == Debug.DebugEvent.Break)
60 {
61 break_count++;
62
63 // Call functions with break using the FrameMirror directly.
64 if (break_count == 1) {
65 // First break event evaluates with break enabled.
66 assertEquals(1, exec_state.frame(0).evaluate('f()', false).value());
67 listenerComplete = true;
68 } else {
69 // Second break event evaluates with break disabled.
70 assertEquals(2, break_count);
71 assertFalse(listenerComplete);
72 assertEquals(1, exec_state.frame(0).evaluate('f()', true).value());
73 }
74 }
75 } catch (e) {
76 exception = e
77 };
78 };
79
80 // Add the debug event listener.
81 Debug.setListener(listener);
82
83 // Test functions - one with break point and one with debugger statement.
84 function f() {
85 return 1;
86 };
87
88 function g() {
89 debugger;
90 return 2;
91 };
92
93 Debug.setBreakPoint(f, 2, 0);
94
95 // Cause a debug break event.
96 debugger;
97
98 assertFalse(exception, "exception in listener")
99 // Make sure that the debug event listener vas invoked.
100 assertTrue(listenerComplete);
101
102 // Remove the debug event listener.
103 Debug.setListener(null);
104
105 // Set debug event listener wich uses recursive breaks.
106 Debug.setListener(listener_recurse);
107 listenerComplete = false;
108
109 Debug.setBreakPoint(f, 2, 0);
110
111 debugger;
112
113 assertFalse(exception, "exception in listener")
114 // Make sure that the debug event listener vas invoked.
115 assertTrue(listenerComplete);
116 assertEquals(2, break_count);
OLDNEW
« no previous file with comments | « test/mjsunit/debug-evaluate-bool-constructor.js ('k') | test/mjsunit/debug-evaluate-with-context.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698