| OLD | NEW |
| 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 |
| 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 listenerComplete = false; | 32 listenerComplete = false; |
| 33 exception = false; | 33 exception = false; |
| 34 | 34 |
| 35 function safeEval(code) { | 35 function safeEval(code) { |
| 36 try { | 36 try { |
| 37 return eval('(' + code + ')'); | 37 return eval('(' + code + ')'); |
| 38 } catch (e) { | 38 } catch (e) { |
| 39 assertEquals(void 0, e); | 39 assertEquals(void 0, e); |
| 40 return undefined; | 40 return undefined; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 | 44 |
| 45 // Send an evaluation request and return the handle of the result. | 45 // Send an evaluation request and return the handle of the result. |
| 46 function evaluateRequest(exec_state, arguments) { | 46 function evaluateRequest(exec_state, arguments) { |
| 47 // Get the debug command processor. | 47 // Get the debug command processor. |
| 48 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | 48 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); |
| 49 | 49 |
| 50 // The base part of all evaluate requests. | 50 // The base part of all evaluate requests. |
| 51 var base_request = '"seq":0,"type":"request","command":"evaluate"' | 51 var base_request = '"seq":0,"type":"request","command":"evaluate"'; |
| 52 | 52 |
| 53 // Generate request with the supplied arguments. | 53 // Generate request with the supplied arguments. |
| 54 var request; | 54 var request; |
| 55 if (arguments) { | 55 if (arguments) { |
| 56 request = '{' + base_request + ',"arguments":' + arguments + '}'; | 56 request = '{' + base_request + ',"arguments":' + arguments + '}'; |
| 57 } else { | 57 } else { |
| 58 request = '{' + base_request + '}' | 58 request = '{' + base_request + '}'; |
| 59 } | 59 } |
| 60 | 60 |
| 61 var response = safeEval(dcp.processDebugJSONRequest(request)); | 61 var response = safeEval(dcp.processDebugJSONRequest(request)); |
| 62 assertTrue(response.success, request + ' -> ' + response.message); | 62 assertTrue(response.success, request + ' -> ' + response.message); |
| 63 | 63 |
| 64 return response.body.handle; | 64 return response.body.handle; |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 // Send a lookup request and return the evaluated JSON response. | 68 // Send a lookup request and return the evaluated JSON response. |
| 69 function lookupRequest(exec_state, arguments, success) { | 69 function lookupRequest(exec_state, arguments, success) { |
| 70 // Get the debug command processor. | 70 // Get the debug command processor. |
| 71 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); | 71 var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); |
| 72 | 72 |
| 73 // The base part of all lookup requests. | 73 // The base part of all lookup requests. |
| 74 var base_request = '"seq":0,"type":"request","command":"lookup"' | 74 var base_request = '"seq":0,"type":"request","command":"lookup"'; |
| 75 | 75 |
| 76 // Generate request with the supplied arguments. | 76 // Generate request with the supplied arguments. |
| 77 var request; | 77 var request; |
| 78 if (arguments) { | 78 if (arguments) { |
| 79 request = '{' + base_request + ',"arguments":' + arguments + '}'; | 79 request = '{' + base_request + ',"arguments":' + arguments + '}'; |
| 80 } else { | 80 } else { |
| 81 request = '{' + base_request + '}' | 81 request = '{' + base_request + '}'; |
| 82 } | 82 } |
| 83 | 83 |
| 84 var response = safeEval(dcp.processDebugJSONRequest(request)); | 84 var response = safeEval(dcp.processDebugJSONRequest(request)); |
| 85 if (success) { | 85 if (success) { |
| 86 assertTrue(response.success, request + ' -> ' + response.message); | 86 assertTrue(response.success, request + ' -> ' + response.message); |
| 87 } else { | 87 } else { |
| 88 assertFalse(response.success, request + ' -> ' + response.message); | 88 assertFalse(response.success, request + ' -> ' + response.message); |
| 89 } | 89 } |
| 90 assertEquals(response.running, dcp.isRunning(), request + ' -> expected not ru
nning'); | 90 assertEquals(response.running, dcp.isRunning(), request + ' -> expected not ru
nning'); |
| 91 | 91 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 count++; | 215 count++; |
| 216 } | 216 } |
| 217 assertEquals(count, obj.properties.length, | 217 assertEquals(count, obj.properties.length, |
| 218 'Unexpected number of resolved objects'); | 218 'Unexpected number of resolved objects'); |
| 219 | 219 |
| 220 | 220 |
| 221 // Indicate that all was processed. | 221 // Indicate that all was processed. |
| 222 listenerComplete = true; | 222 listenerComplete = true; |
| 223 } | 223 } |
| 224 } catch (e) { | 224 } catch (e) { |
| 225 exception = e | 225 exception = e; |
| 226 }; | 226 } |
| 227 }; | 227 } |
| 228 | 228 |
| 229 // Add the debug event listener. | 229 // Add the debug event listener. |
| 230 Debug.setListener(listener); | 230 Debug.setListener(listener); |
| 231 | 231 |
| 232 function f(a) { | 232 function f(a) { |
| 233 debugger; | 233 debugger; |
| 234 }; | 234 } |
| 235 | 235 |
| 236 function g(b) { | 236 function g(b) { |
| 237 f(b); | 237 f(b); |
| 238 }; | 238 } |
| 239 | 239 |
| 240 // Set a break point at return in f and invoke g to hit the breakpoint. | 240 // Set a break point at return in f and invoke g to hit the breakpoint. |
| 241 Debug.setBreakPoint(f, 2, 0); | 241 Debug.setBreakPoint(f, 2, 0); |
| 242 o = {}; | 242 o = {}; |
| 243 p = {} | 243 p = {}; |
| 244 o.o = o; | 244 o.o = o; |
| 245 o.p = p; | 245 o.p = p; |
| 246 p.o = o; | 246 p.o = o; |
| 247 p.p = p; | 247 p.p = p; |
| 248 g(o); | 248 g(o); |
| 249 | 249 |
| 250 assertFalse(exception, "exception in listener") | 250 assertFalse(exception, "exception in listener"); |
| 251 // Make sure that the debug event listener vas invoked. | 251 // Make sure that the debug event listener vas invoked. |
| 252 assertTrue(listenerComplete, "listener did not run to completion: " + exception)
; | 252 assertTrue(listenerComplete, "listener did not run to completion: " + exception)
; |
| OLD | NEW |