OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 print("Test for Debugger.getPossibleBreakpoints"); | 5 print('Test for Debugger.getPossibleBreakpoints'); |
6 | 6 |
7 Protocol.Runtime.enable(); | 7 Protocol.Runtime.enable(); |
8 Protocol.Debugger.enable(); | 8 Protocol.Debugger.enable(); |
9 | 9 |
10 InspectorTest.runTestSuite([ | 10 InspectorTest.runTestSuite([ |
11 | 11 |
12 function getPossibleBreakpointsInRange(next) { | 12 function getPossibleBreakpointsInRange(next) { |
13 var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n"; | 13 var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n'; |
14 var scriptId; | 14 var scriptId; |
15 compileScript(source) | 15 compileScript(source) |
16 .then(id => scriptId = id) | 16 .then(id => scriptId = id) |
17 .then(() => InspectorTest.log("Test start.scriptId != end.scriptId.")) | 17 .then(() => InspectorTest.log('Test start.scriptId != end.scriptId.')) |
18 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
0, scriptId: scriptId + "0" }})) | 18 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
0, scriptId: scriptId + '0' }})) |
19 .then(InspectorTest.logMessage) | 19 .then(message => dumpAllLocations(message, source)) |
20 .then(() => InspectorTest.log("Test not existing scriptId.")) | 20 .then(() => InspectorTest.log('Test not existing scriptId.')) |
21 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: "-1" }})) | 21 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: '-1' }})) |
22 .then(InspectorTest.logMessage) | 22 .then(message => dumpAllLocations(message, source)) |
23 .then(() => InspectorTest.log("Test end < start.")) | 23 .then(() => InspectorTest.log('Test end < start.')) |
24 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
0, scriptId: scriptId }})) | 24 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
0, scriptId: scriptId }})) |
25 .then(InspectorTest.logMessage) | 25 .then(message => dumpAllLocations(message, source)) |
26 .then(() => InspectorTest.log("Test empty range in first line.")) | 26 .then(() => InspectorTest.log('Test empty range in first line.')) |
27 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
16, scriptId: scriptId }})) | 27 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
16, scriptId: scriptId }})) |
28 .then(InspectorTest.logMessage) | 28 .then(message => dumpAllLocations(message, source)) |
29 .then(() => InspectorTest.log("Test one character range in first line.")) | 29 .then(() => InspectorTest.log('Test one character range in first line.')) |
30 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
17, scriptId: scriptId }})) | 30 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
17, scriptId: scriptId }})) |
31 .then(InspectorTest.logMessage) | 31 .then(message => dumpAllLocations(message, source)) |
32 .then(() => InspectorTest.log("Test empty range in not first line.")) | 32 .then(() => InspectorTest.log('Test empty range in not first line.')) |
33 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
16, scriptId: scriptId }})) | 33 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
16, scriptId: scriptId }})) |
34 .then(InspectorTest.logMessage) | 34 .then(message => dumpAllLocations(message, source)) |
35 .then(() => InspectorTest.log("Test one character range in not first line.
")) | 35 .then(() => InspectorTest.log('Test one character range in not first line.
')) |
36 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
17, scriptId: scriptId }})) | 36 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
17, scriptId: scriptId }})) |
37 .then(InspectorTest.logMessage) | 37 .then(message => dumpAllLocations(message, source)) |
38 .then(() => InspectorTest.log("Test end is undefined")) | 38 .then(() => InspectorTest.log('Test end is undefined')) |
39 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }})) | 39 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }})) |
40 .then(InspectorTest.logMessage) | 40 .then(message => dumpAllLocations(message, source)) |
41 .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()")
) | 41 .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()')
) |
42 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber:
0, scriptId: scriptId }})) | 42 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber:
0, scriptId: scriptId }})) |
43 .then(InspectorTest.logMessage) | 43 .then(message => dumpAllLocations(message, source)) |
44 .then(() => InspectorTest.log("Test one string")) | 44 .then(() => InspectorTest.log('Test one string')) |
45 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
0, scriptId: scriptId }})) | 45 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
0, scriptId: scriptId }})) |
46 .then(InspectorTest.logMessage) | 46 .then(message => dumpAllLocations(message, source)) |
47 .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(),
should be the same as previous.")) | 47 .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(),
should be the same as previous.')) |
48 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
256, scriptId: scriptId }})) | 48 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 0, columnNumber:
256, scriptId: scriptId }})) |
49 .then(InspectorTest.logMessage) | 49 .then(message => dumpAllLocations(message, source)) |
50 .then(next); | 50 .then(next); |
51 }, | 51 }, |
52 | 52 |
53 function getPossibleBreakpointsInArrow(next) { | 53 function getPossibleBreakpointsInArrow(next) { |
54 var source = "function foo() { return Promise.resolve().then(() => 239).then
(() => 42).then(() => () => 42) }"; | 54 var source = 'function foo() { return Promise.resolve().then(() => 239).then
(() => 42).then(() => () => 42) }'; |
55 var scriptId; | 55 var scriptId; |
56 compileScript(source) | 56 compileScript(source) |
57 .then(id => scriptId = id) | 57 .then(id => scriptId = id) |
58 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }})) | 58 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }})) |
59 .then(InspectorTest.logMessage) | 59 .then(message => dumpAllLocations(message, source)) |
60 .then(next); | 60 .then(next); |
61 }, | 61 }, |
62 | 62 |
63 function arrowFunctionFirstLine(next) { | 63 function arrowFunctionFirstLine(next) { |
64 Protocol.Debugger.onPaused(message => { | 64 Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(mes
sage, source)); |
65 InspectorTest.log("paused in " + message.params.callFrames[0].functionName
); | |
66 InspectorTest.logMessage(message.params.callFrames[0].location); | |
67 Protocol.Debugger.resume(); | |
68 }); | |
69 | 65 |
70 var source = `function foo1() { Promise.resolve().then(() => 42) } | 66 var source = `function foo1() { Promise.resolve().then(() => 42) } |
71 function foo2() { Promise.resolve().then(() => 42) }`; | 67 function foo2() { Promise.resolve().then(() => 42) }`; |
72 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, { lin
eNumber: 1, columnNumber: 0 }) | 68 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, { lin
eNumber: 1, columnNumber: 0 }) |
73 .then(InspectorTest.logMessage) | 69 .then(message => dumpAllLocations(message, source)) |
74 .then(setAllBreakpoints) | 70 .then(setAllBreakpoints) |
75 .then(() => Protocol.Runtime.evaluate({ expression: "foo1(); foo2()"})) | 71 .then(() => Protocol.Runtime.evaluate({ expression: 'foo1(); foo2()'})) |
76 .then(next); | 72 .then(next); |
77 }, | 73 }, |
78 | 74 |
79 function arrowFunctionOnPause(next) { | 75 function arrowFunctionOnPause(next) { |
80 function dumpAndResume(message) { | |
81 InspectorTest.log("paused in " + message.params.callFrames[0].functionName
); | |
82 InspectorTest.logMessage(message.params.callFrames[0].location); | |
83 Protocol.Debugger.resume(); | |
84 } | |
85 | |
86 var source = `debugger; function foo3() { Promise.resolve().then(() => 42) } | 76 var source = `debugger; function foo3() { Promise.resolve().then(() => 42) } |
87 function foo4() { Promise.resolve().then(() => 42) };\nfoo3();\nfoo4();`; | 77 function foo4() { Promise.resolve().then(() => 42) };\nfoo3();\nfoo4();`; |
88 waitForPossibleBreakpointsOnPause(source, { lineNumber: 0, columnNumber: 0 }
, undefined, next) | 78 waitForPossibleBreakpointsOnPause(source, { lineNumber: 0, columnNumber: 0 }
, undefined, next) |
89 .then(InspectorTest.logMessage) | 79 .then(message => dumpAllLocations(message, source)) |
90 .then(setAllBreakpoints) | 80 .then(setAllBreakpoints) |
91 .then(() => Protocol.Debugger.onPaused(dumpAndResume)) | 81 .then(() => Protocol.Debugger.onPaused(message => dumpBreakLocationInSourc
eAndResume(message, source))) |
92 .then(() => Protocol.Debugger.resume()); | 82 .then(() => Protocol.Debugger.resume()); |
93 }, | 83 }, |
94 | 84 |
95 function getPossibleBreakpointsInRangeWithOffset(next) { | 85 function getPossibleBreakpointsInRangeWithOffset(next) { |
96 var source = "function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n"; | 86 var source = 'function foo(){ return Promise.resolve(); }\nfunction boo(){ r
eturn Promise.resolve().then(() => 42); }\n\n'; |
97 var scriptId; | 87 var scriptId; |
98 compileScript(source, { name: "with-offset.js", line_offset: 1, column_offse
t: 1 }) | 88 compileScript(source, { name: 'with-offset.js', line_offset: 1, column_offse
t: 1 }) |
99 .then(id => scriptId = id) | 89 .then(id => scriptId = id) |
100 .then(() => InspectorTest.log("Test empty range in first line.")) | 90 .then(() => InspectorTest.log('Test empty range in first line.')) |
101 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
17, scriptId: scriptId }})) | 91 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
17, scriptId: scriptId }})) |
102 .then(InspectorTest.logMessage) | 92 .then(message => dumpAllLocations(message, source, 1, 1)) |
103 .then(() => InspectorTest.log("Test one character range in first line.")) | 93 .then(() => InspectorTest.log('Test one character range in first line.')) |
104 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
18, scriptId: scriptId }})) | 94 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 17, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
18, scriptId: scriptId }})) |
105 .then(InspectorTest.logMessage) | 95 .then(message => dumpAllLocations(message, source, 1, 1)) |
106 .then(() => InspectorTest.log("Test empty range in not first line.")) | 96 .then(() => InspectorTest.log('Test empty range in not first line.')) |
107 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber:
16, scriptId: scriptId }})) | 97 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber:
16, scriptId: scriptId }})) |
108 .then(InspectorTest.logMessage) | 98 .then(message => dumpAllLocations(message, source, 1, 1)) |
109 .then(() => InspectorTest.log("Test one character range in not first line.
")) | 99 .then(() => InspectorTest.log('Test one character range in not first line.
')) |
110 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber:
17, scriptId: scriptId }})) | 100 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 2, columnNumber: 16, scriptId: scriptId }, end: { lineNumber: 2, columnNumber:
17, scriptId: scriptId }})) |
111 .then(InspectorTest.logMessage) | 101 .then(message => dumpAllLocations(message, source, 1, 1)) |
112 .then(() => InspectorTest.log("Test end is undefined")) | 102 .then(() => InspectorTest.log('Test end is undefined')) |
113 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }})) | 103 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }})) |
114 .then(InspectorTest.logMessage) | 104 .then(message => dumpAllLocations(message, source, 1, 1)) |
115 .then(() => InspectorTest.log("Test end.lineNumber > scripts.lineCount()")
) | 105 .then(() => InspectorTest.log('Test end.lineNumber > scripts.lineCount()')
) |
116 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber:
0, scriptId: scriptId }})) | 106 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 0, columnNumber: 0, scriptId: scriptId }, end: { lineNumber: 5, columnNumber:
0, scriptId: scriptId }})) |
117 .then(InspectorTest.logMessage) | 107 .then(message => dumpAllLocations(message, source, 1, 1)) |
118 .then(() => InspectorTest.log("Test one string")) | 108 .then(() => InspectorTest.log('Test one string')) |
119 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 2, columnNumber:
0, scriptId: scriptId }})) | 109 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 2, columnNumber:
0, scriptId: scriptId }})) |
120 .then(InspectorTest.logMessage) | 110 .then(message => dumpAllLocations(message, source, 1, 1)) |
121 .then(() => InspectorTest.log("Test end.columnNumber > end.line.length(),
should be the same as previous.")) | 111 .then(() => InspectorTest.log('Test end.columnNumber > end.line.length(),
should be the same as previous.')) |
122 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
256, scriptId: scriptId }})) | 112 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumber
: 1, columnNumber: 1, scriptId: scriptId }, end: { lineNumber: 1, columnNumber:
256, scriptId: scriptId }})) |
123 .then(InspectorTest.logMessage) | 113 .then(message => dumpAllLocations(message, source, 1, 1)) |
124 .then(next); | 114 .then(next); |
125 }, | 115 }, |
126 | 116 |
127 function withOffset(next) { | 117 function withOffset(next) { |
128 Protocol.Debugger.onPaused(message => { | 118 Protocol.Debugger.onPaused(message => dumpBreakLocationInSourceAndResume(mes
sage, source, 3, 18)); |
129 InspectorTest.log("paused in " + message.params.callFrames[0].functionName
); | |
130 InspectorTest.logMessage(message.params.callFrames[0].location); | |
131 Protocol.Debugger.resume(); | |
132 }); | |
133 | 119 |
134 var source = `function foo5() { Promise.resolve().then(() => 42) } | 120 var source = `function foo5() { Promise.resolve().then(() => 42) } |
135 function foo6() { Promise.resolve().then(() => 42) }`; | 121 function foo6() { Promise.resolve().then(() => 42) }`; |
136 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undef
ined, { name: "with-offset.js", line_offset: 3, column_offset: 18 }) | 122 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }, undef
ined, { name: 'with-offset.js', line_offset: 3, column_offset: 18 }) |
137 .then(InspectorTest.logMessage) | 123 .then(message => dumpAllLocations(message, source, 3, 18)) |
138 .then(setAllBreakpoints) | 124 .then(setAllBreakpoints) |
139 .then(() => Protocol.Runtime.evaluate({ expression: "foo5(); foo6()"})) | 125 .then(() => Protocol.Runtime.evaluate({ expression: 'foo5(); foo6()'})) |
140 .then(next); | 126 .then(next); |
141 }, | 127 }, |
142 | 128 |
143 function arrowFunctionReturn(next) { | 129 function arrowFunctionReturn(next) { |
144 waitForPossibleBreakpoints("() => 239\n", { lineNumber: 0, columnNumber: 0 }
) | 130 function checkSource(source, location) { |
145 .then(InspectorTest.logMessage) | 131 return waitForPossibleBreakpoints(source, location) |
146 .then(() => waitForPossibleBreakpoints("function foo() { function boo() {
return 239 } }\n", { lineNumber: 0, columnNumber: 0 })) | 132 .then(message => dumpAllLocations(message, source)); |
147 .then(InspectorTest.logMessage) | 133 } |
148 .then(() => waitForPossibleBreakpoints("() => { 239 }\n", { lineNumber: 0,
columnNumber: 0 })) | 134 |
149 .then(InspectorTest.logMessage) | 135 checkSource('() => 239\n', { lineNumber: 0, columnNumber: 0 }) |
150 // TODO(kozyatinskiy): lineNumber for return position should be 21 instead
of 22. | 136 .then(() => checkSource('function foo() { function boo() { return 239 } }
\n', { lineNumber: 0, columnNumber: 0 })) |
151 .then(() => waitForPossibleBreakpoints("function foo() { 239 }\n", { lineN
umber: 0, columnNumber: 0 })) | 137 .then(() => checkSource('() => { 239 }\n', { lineNumber: 0, columnNumber:
0 })) |
152 .then(InspectorTest.logMessage) | 138 .then(() => checkSource('function foo() { 239 }\n', { lineNumber: 0, colum
nNumber: 0 })) |
153 // TODO(kozyatinskiy): lineNumber for return position should be only 9, no
t 8. | 139 // TODO(kozyatinskiy): lineNumber for return position should be only 9, no
t 8. |
154 .then(() => waitForPossibleBreakpoints("() => 239", { lineNumber: 0, colum
nNumber: 0 })) | 140 .then(() => checkSource('() => 239', { lineNumber: 0, columnNumber: 0 })) |
155 .then(InspectorTest.logMessage) | 141 .then(() => checkSource('() => { return 239 }', { lineNumber: 0, columnNum
ber: 0 })) |
156 // TODO(kozyatinskiy): lineNumber for return position should be only 19, n
ot 20. | 142 .then(next); |
157 .then(() => waitForPossibleBreakpoints("() => { return 239 }", { lineNumbe
r: 0, columnNumber: 0 })) | 143 }, |
158 .then(InspectorTest.logMessage) | 144 |
159 .then(next) | 145 function argumentsAsCalls(next) { |
| 146 var source = 'function foo(){}\nfunction boo(){}\nfunction main(f1,f2){}\nma
in(foo(), boo());\n'; |
| 147 waitForPossibleBreakpoints(source, { lineNumber: 0, columnNumber: 0 }) |
| 148 .then(message => dumpAllLocations(message, source)) |
| 149 .then(next); |
160 } | 150 } |
161 ]); | 151 ]); |
162 | 152 |
163 function compileScript(source, origin) { | 153 function compileScript(source, origin) { |
164 var promise = Protocol.Debugger.onceScriptParsed().then(message => message.par
ams.scriptId); | 154 var promise = Protocol.Debugger.onceScriptParsed().then(message => message.par
ams.scriptId); |
165 if (!origin) origin = { name: "", line_offset: 0, column_offset: 0 }; | 155 if (!origin) origin = { name: '', line_offset: 0, column_offset: 0 }; |
166 compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column
_offset, false); | 156 compileAndRunWithOrigin(source, origin.name, origin.line_offset, origin.column
_offset, false); |
167 return promise; | 157 return promise; |
168 } | 158 } |
169 | 159 |
170 function waitForPossibleBreakpoints(source, start, end, origin) { | 160 function waitForPossibleBreakpoints(source, start, end, origin) { |
171 return compileScript(source, origin) | 161 return compileScript(source, origin) |
172 .then(scriptId => { (start || {}).scriptId = scriptId; (end || {}).scriptId
= scriptId }) | 162 .then(scriptId => { (start || {}).scriptId = scriptId; (end || {}).scriptId
= scriptId }) |
173 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en
d })); | 163 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en
d })); |
174 } | 164 } |
175 | 165 |
176 function waitForPossibleBreakpointsOnPause(source, start, end, next) { | 166 function waitForPossibleBreakpointsOnPause(source, start, end, next) { |
177 var promise = Protocol.Debugger.oncePaused() | 167 var promise = Protocol.Debugger.oncePaused() |
178 .then(msg => { (start || {}).scriptId = msg.params.callFrames[0].location.sc
riptId; (end || {}).scriptId = msg.params.callFrames[0].location.scriptId }) | 168 .then(msg => { (start || {}).scriptId = msg.params.callFrames[0].location.sc
riptId; (end || {}).scriptId = msg.params.callFrames[0].location.scriptId }) |
179 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en
d })); | 169 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en
d })); |
180 Protocol.Runtime.evaluate({ expression: source }).then(next); | 170 Protocol.Runtime.evaluate({ expression: source }).then(next); |
181 return promise; | 171 return promise; |
182 } | 172 } |
183 | 173 |
184 function setAllBreakpoints(message) { | 174 function setAllBreakpoints(message) { |
185 var promises = []; | 175 var promises = []; |
186 for (var location of message.result.locations) | 176 for (var location of message.result.locations) |
187 promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(c
heckBreakpointAndDump)); | 177 promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(c
heckBreakpoint)); |
188 return Promise.all(promises); | 178 return Promise.all(promises); |
189 } | 179 } |
190 | 180 |
191 function checkBreakpointAndDump(message) { | 181 function checkBreakpoint(message) { |
192 if (message.error) { | 182 if (message.error) { |
193 InspectorTest.log("FAIL: error in setBreakpoint"); | 183 InspectorTest.log('FAIL: error in setBreakpoint'); |
194 InspectorTest.logMessage(message); | 184 InspectorTest.logMessage(message); |
195 return; | 185 return; |
196 } | 186 } |
197 var id_data = message.result.breakpointId.split(":"); | 187 var id_data = message.result.breakpointId.split(':'); |
198 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse
Int(id_data[2]) !== message.result.actualLocation.columnNumber) { | 188 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse
Int(id_data[2]) !== message.result.actualLocation.columnNumber) { |
199 InspectorTest.log("FAIL: possible breakpoint was resolved in another locatio
n"); | 189 InspectorTest.log('FAIL: possible breakpoint was resolved in another locatio
n'); |
| 190 } |
| 191 } |
| 192 |
| 193 function dumpAllLocations(message, source, lineOffset, columnOffset) { |
| 194 if (message.error) { |
200 InspectorTest.logMessage(message); | 195 InspectorTest.logMessage(message); |
| 196 return; |
201 } | 197 } |
202 InspectorTest.logMessage(message); | 198 |
| 199 lineOffset = lineOffset || 0; |
| 200 columnOffset = columnOffset || 0; |
| 201 |
| 202 var sourceLines = source.split('\n') |
| 203 var lineOffsets = Array(sourceLines.length).fill(0); |
| 204 for (var location of message.result.locations) { |
| 205 var lineNumber = location.lineNumber - lineOffset; |
| 206 var columnNumber = lineNumber !== 0 ? location.columnNumber : location.colum
nNumber - columnOffset; |
| 207 var line = sourceLines[lineNumber] || ''; |
| 208 var offset = lineOffsets[lineNumber]; |
| 209 line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber
+ offset); |
| 210 ++lineOffsets[lineNumber]; |
| 211 sourceLines[lineNumber] = line; |
| 212 } |
| 213 InspectorTest.log(sourceLines.join('\n')); |
| 214 return message; |
203 } | 215 } |
| 216 |
| 217 function dumpBreakLocationInSourceAndResume(message, source, lineOffset, columnO
ffset) { |
| 218 lineOffset = lineOffset || 0; |
| 219 columnOffset = columnOffset || 0; |
| 220 |
| 221 InspectorTest.log('paused in ' + message.params.callFrames[0].functionName); |
| 222 var location = message.params.callFrames[0].location; |
| 223 var sourceLines = source.split('\n') |
| 224 |
| 225 var lineNumber = location.lineNumber - lineOffset; |
| 226 var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnN
umber - columnOffset; |
| 227 |
| 228 var line = sourceLines[lineNumber]; |
| 229 line = line.slice(0, columnNumber) + '^' + line.slice(columnNumber); |
| 230 sourceLines[lineNumber] = line; |
| 231 InspectorTest.log(sourceLines.join('\n')); |
| 232 Protocol.Debugger.resume(); |
| 233 } |
OLD | NEW |