OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-debug-as debug |
| 6 |
| 7 function static() { |
| 8 print("> static"); // Break |
| 9 } |
| 10 |
| 11 var Debug = debug.Debug; |
| 12 var exception = null; |
| 13 var break_count = 0; |
| 14 |
| 15 function listener(event, exec_state, event_data, data) { |
| 16 if (event != Debug.DebugEvent.Break) return; |
| 17 try { |
| 18 print("breakpoint hit at " + exec_state.frame(0).sourceLineText()); |
| 19 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// Break") > 0); |
| 20 break_count++; |
| 21 } catch (e) { |
| 22 exception = e; |
| 23 } |
| 24 } |
| 25 |
| 26 Debug.setListener(listener); |
| 27 |
| 28 function install() { |
| 29 eval("this.dynamic = function dynamic() { \n" + |
| 30 " print(\"> dynamic\"); // Break\n" + |
| 31 "}\n" + |
| 32 "//@ sourceURL=dynamicScript"); |
| 33 } |
| 34 |
| 35 install(); |
| 36 |
| 37 var scripts = Debug.scripts(); |
| 38 var dynamic_script; |
| 39 var static_script; |
| 40 for (var script of scripts) { |
| 41 if (script.source_url == "dynamicScript") dynamic_script = script; |
| 42 if (script.source_url == "staticScript") static_script = script; |
| 43 } |
| 44 |
| 45 Debug.setScriptBreakPointById(dynamic_script.id, 1); |
| 46 Debug.setScriptBreakPointById(static_script.id, 7); |
| 47 |
| 48 dynamic(); |
| 49 static(); |
| 50 |
| 51 Debug.setListener(null); |
| 52 |
| 53 assertNull(exception); |
| 54 assertEquals(2, break_count); |
| 55 |
| 56 //@ sourceURL=staticScript |
OLD | NEW |