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

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

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/debug-ignore-breakpoints.js ('k') | test/mjsunit/debug-liveedit-1.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --expose-debug-as debug 28 // Flags: --expose-debug-as debug
29 // Get the Debug object exposed from the debug context global object. 29 // Get the Debug object exposed from the debug context global object.
30 Debug = debug.Debug 30 Debug = debug.Debug;
31 31
32 // Note: the following tests only checks the debugger handling of the 32 // Note: the following tests only checks the debugger handling of the
33 // setexceptionbreak command. It does not test whether the debugger 33 // setexceptionbreak command. It does not test whether the debugger
34 // actually breaks on exceptions or not. That functionality is tested 34 // actually breaks on exceptions or not. That functionality is tested
35 // in test-debug.cc instead. 35 // in test-debug.cc instead.
36 36
37 // Note: The following function g() is purposedly placed here so that 37 // Note: The following function g() is purposedly placed here so that
38 // its line numbers will not change should we add more lines of test code 38 // its line numbers will not change should we add more lines of test code
39 // below. The test checks for these line numbers. 39 // below. The test checks for these line numbers.
40 40
41 function g() { // line 40 41 function g() { // line 40
42 var x = 5; 42 var x = 5;
43 var y = 6; 43 var y = 6;
44 var z = 7; 44 var z = 7;
45 }; 45 }
46 46
47 var first_lineno = 40; // Must be the line number of g() above. 47 var first_lineno = 40; // Must be the line number of g() above.
48 // The first line of the file is line 0. 48 // The first line of the file is line 0.
49 49
50 // Simple function which stores the last debug event. 50 // Simple function which stores the last debug event.
51 listenerComplete = false; 51 listenerComplete = false;
52 exception = false; 52 exception = false;
53 53
54 var breakpoint1 = -1; 54 var breakpoint1 = -1;
55 var base_request = '"seq":0,"type":"request","command":"listbreakpoints"' 55 var base_request = '"seq":0,"type":"request","command":"listbreakpoints"';
56 56
57 function safeEval(code) { 57 function safeEval(code) {
58 try { 58 try {
59 return eval('(' + code + ')'); 59 return eval('(' + code + ')');
60 } catch (e) { 60 } catch (e) {
61 assertEquals(void 0, e); 61 assertEquals(void 0, e);
62 return undefined; 62 return undefined;
63 } 63 }
64 } 64 }
65 65
66 66
67 function clearBreakpoint(dcp, breakpoint_id) { 67 function clearBreakpoint(dcp, breakpoint_id) {
68 var base_request = '"seq":0,"type":"request","command":"clearbreakpoint"' 68 var base_request = '"seq":0,"type":"request","command":"clearbreakpoint"';
69 var arguments = '{"breakpoint":' + breakpoint_id + '}' 69 var arguments = '{"breakpoint":' + breakpoint_id + '}';
70 var request = '{' + base_request + ',"arguments":' + arguments + '}' 70 var request = '{' + base_request + ',"arguments":' + arguments + '}';
71 var json_response = dcp.processDebugJSONRequest(request); 71 var json_response = dcp.processDebugJSONRequest(request);
72 } 72 }
73 73
74 74
75 function setBreakOnException(dcp, type, enabled) { 75 function setBreakOnException(dcp, type, enabled) {
76 var base_request = '"seq":0,"type":"request","command":"setexceptionbreak"' 76 var base_request = '"seq":0,"type":"request","command":"setexceptionbreak"';
77 var arguments = '{"type":"' + type + '","enabled":' + enabled + '}' 77 var arguments = '{"type":"' + type + '","enabled":' + enabled + '}';
78 var request = '{' + base_request + ',"arguments":' + arguments + '}' 78 var request = '{' + base_request + ',"arguments":' + arguments + '}';
79 var json_response = dcp.processDebugJSONRequest(request); 79 var json_response = dcp.processDebugJSONRequest(request);
80 } 80 }
81 81
82 82
83 function testArguments(dcp, success, breakpoint_ids, breakpoint_linenos, 83 function testArguments(dcp, success, breakpoint_ids, breakpoint_linenos,
84 break_on_all, break_on_uncaught) { 84 break_on_all, break_on_uncaught) {
85 var request = '{' + base_request + '}' 85 var request = '{' + base_request + '}';
86 var json_response = dcp.processDebugJSONRequest(request); 86 var json_response = dcp.processDebugJSONRequest(request);
87 var response = safeEval(json_response); 87 var response = safeEval(json_response);
88 var num_breakpoints = breakpoint_ids.length; 88 var num_breakpoints = breakpoint_ids.length;
89 89
90 if (success) { 90 if (success) {
91 assertTrue(response.success, json_response); 91 assertTrue(response.success, json_response);
92 assertEquals(response.body.breakpoints.length, num_breakpoints); 92 assertEquals(response.body.breakpoints.length, num_breakpoints);
93 if (num_breakpoints > 0) { 93 if (num_breakpoints > 0) {
94 var breakpoints = response.body.breakpoints; 94 var breakpoints = response.body.breakpoints;
95 for (var i = 0; i < breakpoints.length; i++) { 95 for (var i = 0; i < breakpoints.length; i++) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 false, false); 187 false, false);
188 188
189 clearBreakpoint(dcp, bp5); 189 clearBreakpoint(dcp, bp5);
190 testArguments(dcp, true, [], [], false, false); 190 testArguments(dcp, true, [], [], false, false);
191 191
192 // Indicate that all was processed. 192 // Indicate that all was processed.
193 listenerComplete = true; 193 listenerComplete = true;
194 194
195 } 195 }
196 } catch (e) { 196 } catch (e) {
197 exception = e 197 exception = e;
198 }; 198 }
199 }; 199 }
200 200
201 // Add the debug event listener. 201 // Add the debug event listener.
202 Debug.setListener(listener); 202 Debug.setListener(listener);
203 203
204 // Set a break point and call to invoke the debug event listener. 204 // Set a break point and call to invoke the debug event listener.
205 breakpoint1 = Debug.setBreakPoint(g, 0, 0); 205 breakpoint1 = Debug.setBreakPoint(g, 0, 0);
206 g(); 206 g();
207 207
208 // Make sure that the debug event listener vas invoked. 208 // Make sure that the debug event listener vas invoked.
209 assertFalse(exception, "exception in listener") 209 assertFalse(exception, "exception in listener");
210 assertTrue(listenerComplete, "listener did not run to completion"); 210 assertTrue(listenerComplete, "listener did not run to completion");
OLDNEW
« no previous file with comments | « test/mjsunit/debug-ignore-breakpoints.js ('k') | test/mjsunit/debug-liveedit-1.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698