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

Side by Side Diff: test/mjsunit/debug-clearbreakpointgroup.js

Issue 2557043005: [debugger] remove remaining uses of the debug command processor. (Closed)
Patch Set: fix 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
« no previous file with comments | « test/mjsunit/debug-clearbreakpoint.js ('k') | test/mjsunit/debug-continue.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var Debug = debug.Debug
31
32 // Simple function which stores the last debug event.
33 var listenerComplete = false;
34 var exception = false;
35
36 var base_request = '"seq":0,"type":"request","command":"clearbreakpointgroup"';
37 var scriptId = null;
38 var muteListener = false;
39
40 function safeEval(code) {
41 try {
42 muteListener = true;
43 return eval('(' + code + ')');
44 } catch (e) {
45 assertEquals(void 0, e);
46 return undefined;
47 } finally {
48 muteListener = false;
49 }
50 }
51
52 function testArguments(dcp, arguments, success) {
53 var request = '{' + base_request + ',"arguments":' + arguments + '}'
54 var json_response = dcp.processDebugJSONRequest(request);
55 var response = safeEval(json_response);
56 if (success) {
57 assertTrue(response.success, json_response);
58 } else {
59 assertFalse(response.success, json_response);
60 }
61 }
62
63 function listener(event, exec_state, event_data, data) {
64 if (muteListener) return;
65 try {
66 if (event == Debug.DebugEvent.Break) {
67 // Get the debug command processor.
68 var dcp = exec_state.debugCommandProcessor("unspecified_running_state");
69
70 // Clear breakpoint group 1.
71 testArguments(dcp, '{"groupId":1}', true);
72
73 // Indicate that all was processed.
74 listenerComplete = true;
75 } else if (event == Debug.DebugEvent.AfterCompile) {
76 scriptId = event_data.script().id();
77 assertEquals(source, event_data.script().source());
78 }
79 } catch (e) {
80 exception = e
81 };
82 };
83
84
85 // Add the debug event listener.
86 Debug.setListener(listener);
87
88 var source = 'function f(n) {\nreturn n+1;\n}\nfunction g() {return f(10);}' +
89 '\nvar r = g(); g;';
90 eval(source);
91
92 assertNotNull(scriptId);
93
94 var groupId1 = 1;
95 var groupId2 = 2;
96 // Set a break point and call to invoke the debug event listener.
97 var bp1 = Debug.setScriptBreakPointById(scriptId, 1, null, null, groupId1);
98 var bp2 = Debug.setScriptBreakPointById(scriptId, 1, null, null, groupId2);
99 var bp3 = Debug.setScriptBreakPointById(scriptId, 1, null, null, null);
100 var bp4 = Debug.setScriptBreakPointById(scriptId, 3, null, null, groupId1);
101 var bp5 = Debug.setScriptBreakPointById(scriptId, 4, null, null, groupId2);
102
103 assertEquals(5, Debug.scriptBreakPoints().length);
104
105 // Call function 'g' from the compiled script to trigger breakpoint.
106 g();
107
108 // Make sure that the debug event listener vas invoked.
109 assertTrue(listenerComplete,
110 "listener did not run to completion: " + exception);
111
112 var breakpoints = Debug.scriptBreakPoints();
113 assertEquals(3, breakpoints.length);
114 var breakpointNumbers = breakpoints.map(
115 function(scriptBreakpoint) { return scriptBreakpoint.number(); },
116 breakpointNumbers);
117
118 // Check that all breakpoints from group 1 were deleted and all the
119 // rest are preserved.
120 assertEquals([bp2, bp3, bp5].sort(), breakpointNumbers.sort());
121
122 assertFalse(exception, "exception in listener");
123
124 // Clear all breakpoints to allow the test to run again (--stress-opt).
125 Debug.clearBreakPoint(bp2);
126 Debug.clearBreakPoint(bp3);
127 Debug.clearBreakPoint(bp5);
OLDNEW
« no previous file with comments | « test/mjsunit/debug-clearbreakpoint.js ('k') | test/mjsunit/debug-continue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698