blob: 0d5c650f1efed67a110ec2c6751961887dc4ba7d [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
7function static() {
8 print("> static"); // Break
9}
10
11var Debug = debug.Debug;
12var exception = null;
13var break_count = 0;
14
15function 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
26Debug.setListener(listener);
27
28function install() {
29 eval("this.dynamic = function dynamic() { \n" +
30 " print(\"> dynamic\"); // Break\n" +
31 "}\n" +
32 "//@ sourceURL=dynamicScript");
33}
34
35install();
36
37var scripts = Debug.scripts();
38var dynamic_script;
39var static_script;
40for (var script of scripts) {
41 if (script.source_url == "dynamicScript") dynamic_script = script;
42 if (script.source_url == "staticScript") static_script = script;
43}
44
45Debug.setScriptBreakPointById(dynamic_script.id, 1);
46Debug.setScriptBreakPointById(static_script.id, 7);
47
48dynamic();
49static();
50
51Debug.setListener(null);
52
53assertNull(exception);
54assertEquals(2, break_count);
55
56//@ sourceURL=staticScript