OLD | NEW |
| (Empty) |
1 // Copyright 2008 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | |
3 // modification, are permitted provided that the following conditions are | |
4 // met: | |
5 // | |
6 // * Redistributions of source code must retain the above copyright | |
7 // notice, this list of conditions and the following disclaimer. | |
8 // * Redistributions in binary form must reproduce the above | |
9 // copyright notice, this list of conditions and the following | |
10 // disclaimer in the documentation and/or other materials provided | |
11 // with the distribution. | |
12 // * Neither the name of Google Inc. nor the names of its | |
13 // contributors may be used to endorse or promote products derived | |
14 // from this software without specific prior written permission. | |
15 // | |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
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. | |
27 | |
28 // Flags: --expose-debug-as debug | |
29 // Get the Debug object exposed from the debug context global object. | |
30 Debug = debug.Debug | |
31 Debug.setListener(function(){}); | |
32 | |
33 var script_id; | |
34 var script_name; | |
35 | |
36 // Get current script id and name. | |
37 var scripts = Debug.scripts(); | |
38 for (var i = 0; i < scripts.length; i++) { | |
39 var name = scripts[i].name; | |
40 var id = scripts[i].id; | |
41 if (name !== undefined && name.includes("debug-script-breakpoints.js")) { | |
42 script_id = id; | |
43 script_name = name; | |
44 break; | |
45 } | |
46 } | |
47 assertTrue(script_id !== undefined); | |
48 assertTrue(script_name !== undefined); | |
49 print("#" + script_id + ": " + script_name); | |
50 | |
51 | |
52 // Checks script name, line and column. | |
53 var checkBreakPoint = function(id, line, column) { | |
54 var breakpoint = Debug.scriptBreakPoints()[id]; | |
55 assertEquals(script_name, breakpoint.script_name()); | |
56 assertEquals(line, breakpoint.line()); | |
57 assertEquals(column, breakpoint.column()); | |
58 } | |
59 | |
60 | |
61 // Set and remove a script break point for a named script. | |
62 var sbp = Debug.setScriptBreakPointByName(script_name, 35, 5); | |
63 assertEquals(1, Debug.scriptBreakPoints().length); | |
64 checkBreakPoint(0, 35, 5); | |
65 Debug.clearBreakPoint(sbp); | |
66 assertEquals(0, Debug.scriptBreakPoints().length); | |
67 | |
68 // Set three script break points for named scripts. | |
69 var sbp1 = Debug.setScriptBreakPointByName(script_name, 36, 3); | |
70 var sbp2 = Debug.setScriptBreakPointByName(script_name, 37, 4); | |
71 var sbp3 = Debug.setScriptBreakPointByName(script_name, 38, 5); | |
72 | |
73 // Check the content of the script break points. | |
74 assertEquals(3, Debug.scriptBreakPoints().length); | |
75 checkBreakPoint(0, 36, 3); | |
76 checkBreakPoint(1, 37, 4); | |
77 checkBreakPoint(2, 38, 5); | |
78 | |
79 // Remove script break points (in another order than they where added). | |
80 assertEquals(3, Debug.scriptBreakPoints().length); | |
81 Debug.clearBreakPoint(sbp1); | |
82 assertEquals(2, Debug.scriptBreakPoints().length); | |
83 Debug.clearBreakPoint(sbp3); | |
84 assertEquals(1, Debug.scriptBreakPoints().length); | |
85 Debug.clearBreakPoint(sbp2); | |
86 assertEquals(0, Debug.scriptBreakPoints().length); | |
87 | |
88 | |
89 // Checks script id, line and column. | |
90 var checkBreakPoint = function(id, line, column) { | |
91 var breakpoint = Debug.scriptBreakPoints()[id]; | |
92 assertEquals(script_id, breakpoint.script_id()); | |
93 assertEquals(line, breakpoint.line()); | |
94 assertEquals(column, breakpoint.column()); | |
95 } | |
96 | |
97 | |
98 // Set and remove a script break point for a script id. | |
99 var sbp = Debug.setScriptBreakPointById(script_id, 40, 6); | |
100 assertEquals(1, Debug.scriptBreakPoints().length); | |
101 checkBreakPoint(0, 40, 6); | |
102 Debug.clearBreakPoint(sbp); | |
103 assertEquals(0, Debug.scriptBreakPoints().length); | |
104 | |
105 // Set three script break points for script ids. | |
106 var sbp1 = Debug.setScriptBreakPointById(script_id, 42, 3); | |
107 var sbp2 = Debug.setScriptBreakPointById(script_id, 43, 4); | |
108 var sbp3 = Debug.setScriptBreakPointById(script_id, 44, 5); | |
109 | |
110 // Check the content of the script break points. | |
111 assertEquals(3, Debug.scriptBreakPoints().length); | |
112 checkBreakPoint(0, 42, 3); | |
113 checkBreakPoint(1, 43, 4); | |
114 checkBreakPoint(2, 44, 5); | |
115 | |
116 // Remove script break points (in another order than they where added). | |
117 assertEquals(3, Debug.scriptBreakPoints().length); | |
118 Debug.clearBreakPoint(sbp1); | |
119 assertEquals(2, Debug.scriptBreakPoints().length); | |
120 Debug.clearBreakPoint(sbp3); | |
121 assertEquals(1, Debug.scriptBreakPoints().length); | |
122 Debug.clearBreakPoint(sbp2); | |
123 assertEquals(0, Debug.scriptBreakPoints().length); | |
124 | |
125 Debug.setListener(null); | |
OLD | NEW |