Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: test/mjsunit/debug-stepin-positions.js

Issue 1181013007: Debugger: require debugger to be active when dealing with breaks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix yet another test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/debug-script-breakpoints.js ('k') | test/mjsunit/deserialize-script-id.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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);
OLDNEW
« no previous file with comments | « test/mjsunit/debug-script-breakpoints.js ('k') | test/mjsunit/deserialize-script-id.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698