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 15 matching lines...) Expand all Loading... |
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 --nocrankshaft | 28 // Flags: --expose-debug-as debug --nocrankshaft |
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 function DebuggerStatement() { | 32 function DebuggerStatement() { |
33 debugger; /*pause*/ | 33 debugger; /*pause*/ |
34 } | 34 } |
35 | 35 |
36 function TestCase(fun, frame_number) { | 36 function TestCase(fun, frame_number, line_number) { |
37 var exception = false; | 37 var exception = false; |
38 var codeSnippet = undefined; | 38 var codeSnippet = undefined; |
39 var resultPositions = undefined; | 39 var resultPositions = undefined; |
40 var step = 0; | 40 var step = 0; |
41 | 41 |
42 function listener(event, exec_state, event_data, data) { | 42 function listener(event, exec_state, event_data, data) { |
43 try { | 43 try { |
44 if (event == Debug.DebugEvent.Break || | 44 if (event == Debug.DebugEvent.Break || |
45 event == Debug.DebugEvent.Exception) { | 45 event == Debug.DebugEvent.Exception) { |
46 if (step++ > 0) return; | 46 if (step++ > 0) return; |
(...skipping 10 matching lines...) Expand all Loading... |
57 function assertHasLineMark(mark, frame) { | 57 function assertHasLineMark(mark, frame) { |
58 var line = frame.sourceLineText(); | 58 var line = frame.sourceLineText(); |
59 if (!mark.exec(frame.sourceLineText())) { | 59 if (!mark.exec(frame.sourceLineText())) { |
60 throw new Error("Line " + line + " should contain mark " + mark); | 60 throw new Error("Line " + line + " should contain mark " + mark); |
61 } | 61 } |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 Debug.setListener(listener); | 65 Debug.setListener(listener); |
66 | 66 |
| 67 var breakpointId; |
| 68 if (line_number) breakpointId = Debug.setBreakPoint(fun, line_number); |
| 69 |
67 fun(); | 70 fun(); |
68 | 71 |
| 72 if (line_number) Debug.clearBreakPoint(breakpointId); |
| 73 |
69 Debug.setListener(null); | 74 Debug.setListener(null); |
70 | 75 |
71 assertTrue(!exception, exception); | 76 assertTrue(!exception, exception); |
72 | 77 |
73 var expectedPositions = {}; | 78 var expectedPositions = {}; |
74 var markPattern = new RegExp("/\\*#\\*/", "g"); | 79 var markPattern = new RegExp("/\\*#\\*/", "g"); |
75 | 80 |
76 var matchResult; | 81 var matchResult; |
77 while ( (matchResult = markPattern.exec(codeSnippet)) ) { | 82 while ( (matchResult = markPattern.exec(codeSnippet)) ) { |
78 expectedPositions[matchResult.index] = true; | 83 expectedPositions[matchResult.index] = true; |
(...skipping 30 matching lines...) Expand all Loading... |
109 } | 114 } |
110 assertFalse(unexpectedPositionFound, "Found unexpected position: " + | 115 assertFalse(unexpectedPositionFound, "Found unexpected position: " + |
111 decoratedResult); | 116 decoratedResult); |
112 } | 117 } |
113 | 118 |
114 function TestCaseWithDebugger(fun) { | 119 function TestCaseWithDebugger(fun) { |
115 TestCase(fun, 1); | 120 TestCase(fun, 1); |
116 } | 121 } |
117 | 122 |
118 function TestCaseWithBreakpoint(fun, line_number, frame_number) { | 123 function TestCaseWithBreakpoint(fun, line_number, frame_number) { |
119 var breakpointId = Debug.setBreakPoint(fun, line_number); | 124 TestCase(fun, frame_number, line_number); |
120 TestCase(fun, frame_number); | |
121 Debug.clearBreakPoint(breakpointId); | |
122 } | 125 } |
123 | 126 |
124 function TestCaseWithException(fun, frame_number) { | 127 function TestCaseWithException(fun, frame_number) { |
125 Debug.setBreakOnException(); | 128 Debug.setBreakOnException(); |
126 TestCase(fun, frame_number); | 129 TestCase(fun, frame_number); |
127 Debug.clearBreakOnException(); | 130 Debug.clearBreakOnException(); |
128 } | 131 } |
129 | 132 |
130 | 133 |
131 // Test cases. | 134 // Test cases. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 })(Object); | 218 })(Object); |
216 TestCaseWithDebugger(fun); | 219 TestCaseWithDebugger(fun); |
217 | 220 |
218 // Global function, global object construction, calls before pause point. | 221 // Global function, global object construction, calls before pause point. |
219 var fun = (function(p) { | 222 var fun = (function(p) { |
220 return function() { | 223 return function() { |
221 var res = [ Math.abs(new Object()), DebuggerStatement(), Math./*#*/abs(4), /
*#*/new Object()./*#*/toString() ]; /*positions*/ | 224 var res = [ Math.abs(new Object()), DebuggerStatement(), Math./*#*/abs(4), /
*#*/new Object()./*#*/toString() ]; /*positions*/ |
222 }; | 225 }; |
223 })(Object); | 226 })(Object); |
224 TestCaseWithDebugger(fun); | 227 TestCaseWithDebugger(fun); |
OLD | NEW |