| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 assertTrue(response.success, request + ' -> ' + response.message); | 57 assertTrue(response.success, request + ' -> ' + response.message); |
| 58 assertEquals(result, response.body.value); | 58 assertEquals(result, response.body.value); |
| 59 } else { | 59 } else { |
| 60 assertFalse(response.success, request + ' -> ' + response.message); | 60 assertFalse(response.success, request + ' -> ' + response.message); |
| 61 } | 61 } |
| 62 assertFalse(response.running, request + ' -> expected not running'); | 62 assertFalse(response.running, request + ' -> expected not running'); |
| 63 } | 63 } |
| 64 | 64 |
| 65 function listener(event, exec_state, event_data, data) { | 65 function listener(event, exec_state, event_data, data) { |
| 66 try { | 66 try { |
| 67 if (event == Debug.DebugEvent.Break) { | 67 if (event == Debug.DebugEvent.Break) { |
| 68 // Get the debug command processor. | 68 // Get the debug command processor. |
| 69 var dcp = exec_state.debugCommandProcessor(); | 69 var dcp = exec_state.debugCommandProcessor(); |
| 70 | 70 |
| 71 // Test some illegal evaluate requests. | 71 // Test some illegal evaluate requests. |
| 72 testRequest(dcp, void 0, false); | 72 testRequest(dcp, void 0, false); |
| 73 testRequest(dcp, '{"expression":"1","global"=true}', false); | 73 testRequest(dcp, '{"expression":"1","global"=true}', false); |
| 74 testRequest(dcp, '{"expression":"a","frame":4}', false); | 74 testRequest(dcp, '{"expression":"a","frame":4}', false); |
| 75 | 75 |
| 76 // Test some legal evaluate requests. | 76 // Test some legal evaluate requests. |
| 77 testRequest(dcp, '{"expression":"1+2"}', true, 3); | 77 testRequest(dcp, '{"expression":"1+2"}', true, 3); |
| 78 testRequest(dcp, '{"expression":"a+2"}', true, 5); | 78 testRequest(dcp, '{"expression":"a+2"}', true, 5); |
| 79 testRequest(dcp, '{"expression":"({\\"a\\":1,\\"b\\":2}).b+2"}', true, 4); | 79 testRequest(dcp, '{"expression":"({\\"a\\":1,\\"b\\":2}).b+2"}', true, 4); |
| 80 | 80 |
| 81 // Test evaluation of a in the stack frames and the global context. | 81 // Test evaluation of a in the stack frames and the global context. |
| 82 testRequest(dcp, '{"expression":"a"}', true, 3); | 82 testRequest(dcp, '{"expression":"a"}', true, 3); |
| 83 testRequest(dcp, '{"expression":"a","frame":0}', true, 3); | 83 testRequest(dcp, '{"expression":"a","frame":0}', true, 3); |
| 84 testRequest(dcp, '{"expression":"a","frame":1}', true, 2); | 84 testRequest(dcp, '{"expression":"a","frame":1}', true, 2); |
| 85 testRequest(dcp, '{"expression":"a","frame":2}', true, 1); | 85 testRequest(dcp, '{"expression":"a","frame":2}', true, 1); |
| 86 testRequest(dcp, '{"expression":"a","global":true}', true, 1); | 86 testRequest(dcp, '{"expression":"a","global":true}', true, 1); |
| 87 testRequest(dcp, '{"expression":"this.a","global":true}', true, 1); | 87 testRequest(dcp, '{"expression":"this.a","global":true}', true, 1); |
| 88 | 88 |
| 89 // Indicate that all was processed. | 89 // Indicate that all was processed. |
| 90 listenerComplete = true; | 90 listenerComplete = true; |
| 91 } | 91 } |
| 92 } catch (e) { | 92 } catch (e) { |
| 93 exception = e | 93 exception = e |
| 94 }; | 94 }; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 // Add the debug event listener. | 97 // Add the debug event listener. |
| 98 Debug.addListener(listener); | 98 Debug.addListener(listener); |
| 99 | 99 |
| 100 function f() { | 100 function f() { |
| 101 var a = 3; | 101 var a = 3; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 function g() { | 104 function g() { |
| 105 var a = 2; | 105 var a = 2; |
| 106 f(); | 106 f(); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 a = 1; | 109 a = 1; |
| 110 | 110 |
| 111 // Set a break point at return in f and invoke g to hit the breakpoint. | 111 // Set a break point at return in f and invoke g to hit the breakpoint. |
| 112 Debug.setBreakPoint(f, 2, 0); | 112 Debug.setBreakPoint(f, 2, 0); |
| 113 g(); | 113 g(); |
| 114 | 114 |
| 115 // Make sure that the debug event listener vas invoked. | 115 // Make sure that the debug event listener vas invoked. |
| 116 assertTrue(listenerComplete, "listener did not run to completion"); | 116 assertTrue(listenerComplete, "listener did not run to completion"); |
| 117 assertFalse(exception, "exception in listener") | 117 assertFalse(exception, "exception in listener") |
| OLD | NEW |