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

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

Issue 40317: Added unique id to all scripts (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 months 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-script-breakpoints.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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
(...skipping 12 matching lines...) Expand all
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 // Simple function which stores the last debug event. 32 // Simple function which stores the last debug event.
33 listenerComplete = false; 33 var listenerComplete = false;
34 exception = false; 34 var exception = false;
35 var f_script_id = 0;
36 var g_script_id = 0;
37 var h_script_id = 0;
38 var f_line = 0;
39 var g_line = 0;
35 40
36 var base_request = '"seq":0,"type":"request","command":"setbreakpoint"' 41 var base_request = '"seq":0,"type":"request","command":"setbreakpoint"'
37 42
38 function safeEval(code) { 43 function safeEval(code) {
39 try { 44 try {
40 return eval('(' + code + ')'); 45 return eval('(' + code + ')');
41 } catch (e) { 46 } catch (e) {
42 assertEquals(void 0, e); 47 assertEquals(void 0, e);
43 return undefined; 48 return undefined;
44 } 49 }
45 } 50 }
46 51
47 function testArguments(dcp, arguments, success, type) { 52 function testArguments(dcp, arguments, success, is_script) {
48 var request = '{' + base_request + ',"arguments":' + arguments + '}' 53 var request = '{' + base_request + ',"arguments":' + arguments + '}'
49 var json_response = dcp.processDebugJSONRequest(request); 54 var json_response = dcp.processDebugJSONRequest(request);
50 var response = safeEval(json_response); 55 var response = safeEval(json_response);
51 if (success) { 56 if (success) {
52 assertTrue(response.success, json_response); 57 assertTrue(response.success, json_response);
53 assertEquals(type ? type : 'script', response.body.type, json_response); 58 if (is_script) {
59 assertEquals('scriptName', response.body.type, json_response);
60 } else {
61 assertEquals('scriptId', response.body.type, json_response);
62 print(response.body.script_id);
63 }
54 } else { 64 } else {
55 assertFalse(response.success, json_response); 65 assertFalse(response.success, json_response);
56 } 66 }
57 } 67 }
58 68
59 function listener(event, exec_state, event_data, data) { 69 function listener(event, exec_state, event_data, data) {
60 try { 70 try {
61 if (event == Debug.DebugEvent.Break) { 71 if (event == Debug.DebugEvent.Break) {
62 // Get the debug command processor. 72 // Get the debug command processor.
63 var dcp = exec_state.debugCommandProcessor(); 73 var dcp = exec_state.debugCommandProcessor();
64 74
65 // Test some illegal setbreakpoint requests. 75 // Test some illegal setbreakpoint requests.
66 var request = '{' + base_request + '}' 76 var request = '{' + base_request + '}'
67 var response = safeEval(dcp.processDebugJSONRequest(request)); 77 var response = safeEval(dcp.processDebugJSONRequest(request));
68 assertFalse(response.success); 78 assertFalse(response.success);
69 79
70 testArguments(dcp, '{}', false); 80 testArguments(dcp, '{}', false);
71 testArguments(dcp, '{"type":"xx"}', false); 81 testArguments(dcp, '{"type":"xx"}', false);
72 testArguments(dcp, '{"type":"function"}', false); 82 testArguments(dcp, '{"type":"function"}', false);
73 testArguments(dcp, '{"type":"script"}', false); 83 testArguments(dcp, '{"type":"script"}', false);
74 testArguments(dcp, '{"target":"f"}', false); 84 testArguments(dcp, '{"target":"f"}', false);
75 testArguments(dcp, '{"type":"xx","target":"xx"}', false); 85 testArguments(dcp, '{"type":"xx","target":"xx"}', false);
76 testArguments(dcp, '{"type":"function","target":1}', false); 86 testArguments(dcp, '{"type":"function","target":1}', false);
77 testArguments(dcp, '{"type":"function","target":"f","line":-1}', false); 87 testArguments(dcp, '{"type":"function","target":"f","line":-1}', false);
78 testArguments(dcp, '{"type":"function","target":"f","column":-1}', false); 88 testArguments(dcp, '{"type":"function","target":"f","column":-1}', false);
79 testArguments(dcp, '{"type":"function","target":"f","ignoreCount":-1}', fals e); 89 testArguments(dcp, '{"type":"function","target":"f","ignoreCount":-1}', fals e);
80 90
81 // Test some legal setbreakpoint requests. 91 // Test some legal setbreakpoint requests.
82 testArguments(dcp, '{"type":"function","target":"f"}', true); 92 testArguments(dcp, '{"type":"function","target":"f"}', true, false);
83 testArguments(dcp, '{"type":"function","target":"h"}', true, 'function'); 93 testArguments(dcp, '{"type":"function","target":"h"}', true, false);
84 testArguments(dcp, '{"type":"function","target":"f","line":1}', true); 94 testArguments(dcp, '{"type":"function","target":"f","line":1}', true, false) ;
85 testArguments(dcp, '{"type":"function","target":"f","position":1}', true); 95 testArguments(dcp, '{"type":"function","target":"f","position":1}', true, fa lse);
86 testArguments(dcp, '{"type":"function","target":"f","condition":"i == 1"}', true); 96 testArguments(dcp, '{"type":"function","target":"f","condition":"i == 1"}', true, false);
87 testArguments(dcp, '{"type":"function","target":"f","enabled":true}', true); 97 testArguments(dcp, '{"type":"function","target":"f","enabled":true}', true, false);
88 testArguments(dcp, '{"type":"function","target":"f","enabled":false}', true) ; 98 testArguments(dcp, '{"type":"function","target":"f","enabled":false}', true, false);
89 testArguments(dcp, '{"type":"function","target":"f","ignoreCount":7}', true) ; 99 testArguments(dcp, '{"type":"function","target":"f","ignoreCount":7}', true, false);
90 testArguments(dcp, '{"type":"script","target":"test"}', true); 100
91 testArguments(dcp, '{"type":"script","target":"test"}', true); 101 testArguments(dcp, '{"type":"script","target":"test"}', true, true);
92 testArguments(dcp, '{"type":"script","target":"test","line":1}', true); 102 testArguments(dcp, '{"type":"script","target":"test"}', true, true);
93 testArguments(dcp, '{"type":"script","target":"test","column":1}', true); 103 testArguments(dcp, '{"type":"script","target":"test","line":1}', true, true) ;
104 testArguments(dcp, '{"type":"script","target":"test","column":1}', true, tru e);
105
106 testArguments(dcp, '{"type":"scriptId","target":' + f_script_id + ',"line":' + f_line + '}', true, false);
107 testArguments(dcp, '{"type":"scriptId","target":' + g_script_id + ',"line":' + g_line + '}', true, false);
108 testArguments(dcp, '{"type":"scriptId","target":' + h_script_id + ',"line":' + h_line + '}', true, false);
94 109
95 // Indicate that all was processed. 110 // Indicate that all was processed.
96 listenerComplete = true; 111 listenerComplete = true;
97 } 112 }
98 } catch (e) { 113 } catch (e) {
99 exception = e 114 exception = e
100 }; 115 };
101 }; 116 };
102 117
103 // Add the debug event listener. 118 // Add the debug event listener.
104 Debug.setListener(listener); 119 Debug.setListener(listener);
105 120
106 function f() { 121 function f() {
107 a=1 122 a=1
108 }; 123 };
109 124
110 function g() { 125 function g() {
111 f(); 126 f();
112 }; 127 };
113 128
114 eval('function h(){}'); 129 eval('function h(){}');
115 130
131 // Check the script ids for the test functions.
132 f_script_id = Debug.findScript(f).id;
133 g_script_id = Debug.findScript(g).id;
134 h_script_id = Debug.findScript(h).id;
135 assertTrue(f_script_id > 0, "invalid script id for f");
136 assertTrue(g_script_id > 0, "invalid script id for g");
137 assertTrue(h_script_id > 0, "invalid script id for h");
138 assertEquals(f_script_id, g_script_id);
139
140 // Get the source line for the test functions.
141 f_line = Debug.findFunctionSourceLocation(f).line;
142 g_line = Debug.findFunctionSourceLocation(g).line;
143 h_line = Debug.findFunctionSourceLocation(h).line;
144 assertTrue(f_line > 0, "invalid line for f");
145 assertTrue(g_line > 0, "invalid line for g");
146 assertTrue(f_line < g_line);
147 assertEquals(h_line, 0, "invalid line for h");
148
116 // Set a break point and call to invoke the debug event listener. 149 // Set a break point and call to invoke the debug event listener.
117 Debug.setBreakPoint(g, 0, 0); 150 Debug.setBreakPoint(g, 0, 0);
118 g(); 151 g();
119 152
120 // Make sure that the debug event listener vas invoked. 153 // Make sure that the debug event listener vas invoked.
121 assertTrue(listenerComplete, "listener did not run to completion"); 154 assertTrue(listenerComplete, "listener did not run to completion: " + exception) ;
122 assertFalse(exception, "exception in listener")
OLDNEW
« no previous file with comments | « test/mjsunit/debug-script-breakpoints.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698