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

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

Issue 67155: Support passing multiple handles in 'lookup' request (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 8 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 | « src/debug-delay.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 89
90 function listener(event, exec_state, event_data, data) { 90 function listener(event, exec_state, event_data, data) {
91 try { 91 try {
92 if (event == Debug.DebugEvent.Break) { 92 if (event == Debug.DebugEvent.Break) {
93 // Get the debug command processor. 93 // Get the debug command processor.
94 var dcp = exec_state.debugCommandProcessor(); 94 var dcp = exec_state.debugCommandProcessor();
95 95
96 // Test some illegal lookup requests. 96 // Test some illegal lookup requests.
97 lookupRequest(dcp, void 0, false); 97 lookupRequest(dcp, void 0, false);
98 lookupRequest(dcp, '{"handle":"a"}', false); 98 lookupRequest(dcp, '{"handles":["a"]}', false);
99 lookupRequest(dcp, '{"handle":-1}', false); 99 lookupRequest(dcp, '{"handles":[-1]}', false);
100 100
101 // Evaluate and get some handles. 101 // Evaluate and get some handles.
102 var handle_o = evaluateRequest(dcp, '{"expression":"o"}'); 102 var handle_o = evaluateRequest(dcp, '{"expression":"o"}');
103 var handle_p = evaluateRequest(dcp, '{"expression":"p"}'); 103 var handle_p = evaluateRequest(dcp, '{"expression":"p"}');
104 var handle_b = evaluateRequest(dcp, '{"expression":"a"}'); 104 var handle_b = evaluateRequest(dcp, '{"expression":"a"}');
105 var handle_a = evaluateRequest(dcp, '{"expression":"b","frame":1}'); 105 var handle_a = evaluateRequest(dcp, '{"expression":"b","frame":1}');
106 assertEquals(handle_o, handle_a); 106 assertEquals(handle_o, handle_a);
107 assertEquals(handle_a, handle_b); 107 assertEquals(handle_a, handle_b);
108 assertFalse(handle_o == handle_p, "o and p have he same handle"); 108 assertFalse(handle_o == handle_p, "o and p have he same handle");
109 109
110 var response; 110 var response;
111 var count; 111 var count;
112 response = lookupRequest(dcp, '{"handle":' + handle_o + '}', true); 112 response = lookupRequest(dcp, '{"handles":[' + handle_o + ']}', true);
113 assertEquals(handle_o, response.body.handle); 113 var obj = response.body[handle_o];
114 assertTrue(!!obj, 'Object not found: ' + handle_o);
115 assertEquals(handle_o, obj.handle);
114 count = 0; 116 count = 0;
115 for (i in response.body.properties) { 117 for (i in obj.properties) {
116 switch (response.body.properties[i].name) { 118 switch (obj.properties[i].name) {
117 case 'o': 119 case 'o':
118 response.body.properties[i].ref = handle_o; 120 obj.properties[i].ref = handle_o;
119 count++; 121 count++;
120 break; 122 break;
121 case 'p': 123 case 'p':
122 response.body.properties[i].ref = handle_p; 124 obj.properties[i].ref = handle_p;
123 count++; 125 count++;
124 break; 126 break;
125 } 127 }
126 } 128 }
127 assertEquals(2, count, 'Either "o" or "p" not found'); 129 assertEquals(2, count, 'Either "o" or "p" not found');
128 response = lookupRequest(dcp, '{"handle":' + handle_p + '}', true); 130 response = lookupRequest(dcp, '{"handles":[' + handle_p + ']}', true);
129 assertEquals(handle_p, response.body.handle); 131 obj = response.body[handle_p];
132 assertTrue(!!obj, 'Object not found: ' + handle_p);
133 assertEquals(handle_p, obj.handle);
130 134
131 // Check handles for functions on the stack. 135 // Check handles for functions on the stack.
132 var handle_f = evaluateRequest(dcp, '{"expression":"f"}'); 136 var handle_f = evaluateRequest(dcp, '{"expression":"f"}');
133 var handle_g = evaluateRequest(dcp, '{"expression":"g"}'); 137 var handle_g = evaluateRequest(dcp, '{"expression":"g"}');
134 var handle_caller = evaluateRequest(dcp, '{"expression":"f.caller"}'); 138 var handle_caller = evaluateRequest(dcp, '{"expression":"f.caller"}');
135 139
136 assertFalse(handle_f == handle_g, "f and g have he same handle"); 140 assertFalse(handle_f == handle_g, "f and g have he same handle");
137 assertEquals(handle_g, handle_caller, "caller for f should be g"); 141 assertEquals(handle_g, handle_caller, "caller for f should be g");
138 142
139 response = lookupRequest(dcp, '{"handle":' + handle_f + '}', true); 143 response = lookupRequest(dcp, '{"handles":[' + handle_f + ']}', true);
140 assertEquals(handle_f, response.body.handle); 144 obj = response.body[handle_f];
145 assertEquals(handle_f, obj.handle);
146
141 count = 0; 147 count = 0;
142 for (i in response.body.properties) { 148 for (i in obj.properties) {
143 var arguments = '{"handle":' + response.body.properties[i].ref + '}' 149 var ref = obj.properties[i].ref;
144 switch (response.body.properties[i].name) { 150 var arguments = '{"handles":[' + ref + ']}';
151 switch (obj.properties[i].name) {
145 case 'name': 152 case 'name':
146 var response_name; 153 var response_name;
147 response_name = lookupRequest(dcp, arguments, true); 154 response_name = lookupRequest(dcp, arguments, true);
148 assertEquals('string', response_name.body.type); 155 assertEquals('string', response_name.body[ref].type);
149 assertEquals("f", response_name.body.value); 156 assertEquals("f", response_name.body[ref].value);
150 count++; 157 count++;
151 break; 158 break;
152 case 'length': 159 case 'length':
153 var response_length; 160 var response_length;
154 response_length = lookupRequest(dcp, arguments, true); 161 response_length = lookupRequest(dcp, arguments, true);
155 assertEquals('number', response_length.body.type); 162 assertEquals('number', response_length.body[ref].type);
156 assertEquals(1, response_length.body.value); 163 assertEquals(1, response_length.body[ref].value);
157 count++; 164 count++;
158 break; 165 break;
159 case 'caller': 166 case 'caller':
160 assertEquals(handle_g, response.body.properties[i].ref); 167 assertEquals(handle_g, obj.properties[i].ref);
161 count++; 168 count++;
162 break; 169 break;
163 } 170 }
164 } 171 }
165 assertEquals(3, count, 'Either "name", "length" or "caller" not found'); 172 assertEquals(3, count, 'Either "name", "length" or "caller" not found');
166 173
167 174
175 // Resolve all at once.
176 var refs = [];
177 for (i in obj.properties) {
178 refs.push(obj.properties[i].ref);
179 }
180
181 var arguments = '{"handles":[' + refs.join(',') + ']}';
182 response = lookupRequest(dcp, arguments, true);
183 count = 0;
184 for (i in obj.properties) {
185 var ref = obj.properties[i].ref;
186 var val = response.body[ref];
187 assertTrue(!!val, 'Failed to lookup "' + obj.properties[i].name + '"');
188 switch (obj.properties[i].name) {
189 case 'name':
190 assertEquals('string', val.type);
191 assertEquals("f", val.value);
192 count++;
193 break;
194 case 'length':
195 assertEquals('number', val.type);
196 assertEquals(1, val.value);
197 count++;
198 break;
199 case 'caller':
200 assertEquals('function', val.type);
201 assertEquals(handle_g, ref);
202 count++;
203 break;
204 }
205 }
206 assertEquals(3, count, 'Either "name", "length" or "caller" not found');
207
208 count = 0;
209 for (var handle in response.body) {
210 assertTrue(refs.indexOf(parseInt(handle)) != -1,
211 'Handle not in the request: ' + handle);
212 count++;
213 }
214 assertEquals(count, obj.properties.length,
215 'Unexpected number of resolved objects');
216
217
168 // Indicate that all was processed. 218 // Indicate that all was processed.
169 listenerComplete = true; 219 listenerComplete = true;
170 } 220 }
171 } catch (e) { 221 } catch (e) {
172 exception = e 222 exception = e
173 }; 223 };
174 }; 224 };
175 225
176 // Add the debug event listener. 226 // Add the debug event listener.
177 Debug.setListener(listener); 227 Debug.setListener(listener);
(...skipping 10 matching lines...) Expand all
188 Debug.setBreakPoint(f, 2, 0); 238 Debug.setBreakPoint(f, 2, 0);
189 o = {}; 239 o = {};
190 p = {} 240 p = {}
191 o.o = o; 241 o.o = o;
192 o.p = p; 242 o.p = p;
193 p.o = o; 243 p.o = o;
194 p.p = p; 244 p.p = p;
195 g(o); 245 g(o);
196 246
197 // Make sure that the debug event listener vas invoked. 247 // Make sure that the debug event listener vas invoked.
198 assertTrue(listenerComplete, "listener did not run to completion"); 248 assertTrue(listenerComplete, "listener did not run to completion: " + exception) ;
199 assertFalse(exception, "exception in listener") 249 assertFalse(exception, "exception in listener")
OLDNEW
« no previous file with comments | « src/debug-delay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698