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 InspectorTest = {}; | 5 InspectorTest = {}; |
6 InspectorTest._dispatchTable = new Map(); | |
7 InspectorTest._requestId = 0; | |
8 InspectorTest._dumpInspectorProtocolMessages = false; | 6 InspectorTest._dumpInspectorProtocolMessages = false; |
9 InspectorTest._eventHandler = {}; | |
10 InspectorTest._commandsForLogging = new Set(); | 7 InspectorTest._commandsForLogging = new Set(); |
11 | 8 |
12 Protocol = new Proxy({}, { | 9 InspectorTest.createContextGroup = function() { |
13 get: function(target, agentName, receiver) { | 10 var contextGroup = {}; |
14 return new Proxy({}, { | 11 contextGroup.id = utils.createContextGroup(); |
15 get: function(target, methodName, receiver) { | 12 contextGroup.schedulePauseOnNextStatement = (reason, details) => utils.schedul
ePauseOnNextStatement(contextGroup.id, reason, details); |
16 const eventPattern = /^on(ce)?([A-Z][A-Za-z0-9]+)/; | 13 contextGroup.cancelPauseOnNextStatement = () => utils.cancelPauseOnNextStateme
nt(contextGroup.id); |
17 var match = eventPattern.exec(methodName); | 14 contextGroup.addScript = (string, lineOffset, columnOffset, url) => utils.comp
ileAndRunWithOrigin(contextGroup.id, string, url || '', lineOffset || 0, columnO
ffset || 0, false); |
18 if (!match) { | 15 contextGroup.addModule = (string, url, lineOffset, columnOffset) => utils.comp
ileAndRunWithOrigin(contextGroup.id, string, url, lineOffset || 0, columnOffset
|| 0, true); |
19 return (args, contextGroupId) => InspectorTest._sendCommandPromise(`${
agentName}.${methodName}`, args || {}, contextGroupId); | 16 return contextGroup; |
20 } else { | 17 } |
21 var eventName = match[2]; | 18 |
22 eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1); | 19 InspectorTest._sessions = new Map(); |
23 if (match[1]) | 20 InspectorTest.createSession = function(contextGroup) { |
24 return () => InspectorTest._waitForEventPromise( | 21 var session = { |
25 `${agentName}.${eventName}`); | 22 contextGroup: contextGroup, |
26 else | 23 _dispatchTable: new Map(), |
27 return (listener) => { InspectorTest._eventHandler[`${agentName}.${e
ventName}`] = listener }; | 24 _eventHandler: {}, |
| 25 _requestId: 0, |
| 26 }; |
| 27 session.Protocol = new Proxy({}, { |
| 28 get: function(target, agentName, receiver) { |
| 29 return new Proxy({}, { |
| 30 get: function(target, methodName, receiver) { |
| 31 const eventPattern = /^on(ce)?([A-Z][A-Za-z0-9]+)/; |
| 32 var match = eventPattern.exec(methodName); |
| 33 if (!match) { |
| 34 return args => session._sendCommandPromise(`${agentName}.${methodNam
e}`, args || {}); |
| 35 } else { |
| 36 var eventName = match[2]; |
| 37 eventName = eventName.charAt(0).toLowerCase() + eventName.slice(1); |
| 38 if (match[1]) |
| 39 return () => InspectorTest._waitForEventPromise(session, `${agentN
ame}.${eventName}`); |
| 40 else |
| 41 return (listener) => { session._eventHandler[`${agentName}.${event
Name}`] = listener }; |
| 42 } |
28 } | 43 } |
| 44 }); |
| 45 } |
| 46 }); |
| 47 session._dispatchMessage = messageString => { |
| 48 let messageObject = JSON.parse(messageString); |
| 49 if (InspectorTest._dumpInspectorProtocolMessages) |
| 50 utils.print("backend: " + JSON.stringify(messageObject)); |
| 51 try { |
| 52 var messageId = messageObject["id"]; |
| 53 if (typeof messageId === "number") { |
| 54 var handler = session._dispatchTable.get(messageId); |
| 55 if (handler) { |
| 56 handler(messageObject); |
| 57 session._dispatchTable.delete(messageId); |
| 58 } |
| 59 } else { |
| 60 var eventName = messageObject["method"]; |
| 61 var eventHandler = session._eventHandler[eventName]; |
| 62 if (session._scriptMap && eventName === "Debugger.scriptParsed") |
| 63 session._scriptMap.set(messageObject.params.scriptId, JSON.parse(JSON.
stringify(messageObject.params))); |
| 64 if (eventName === "Debugger.scriptParsed" && messageObject.params.url ==
= "wait-pending-tasks.js") |
| 65 return; |
| 66 if (eventHandler) |
| 67 eventHandler(messageObject); |
29 } | 68 } |
30 }); | 69 } catch (e) { |
| 70 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.st
ack + "\n message = " + JSON.stringify(messageObject, null, 2)); |
| 71 InspectorTest.completeTest(); |
| 72 } |
| 73 }; |
| 74 session.id = utils.connectSession(contextGroup.id, '', session._dispatchMessag
e.bind(session)); |
| 75 InspectorTest._sessions.set(session.id, session); |
| 76 session.disconnect = () => utils.disconnectSession(session.id); |
| 77 session.reconnect = () => { |
| 78 InspectorTest._sessions.delete(session.id); |
| 79 var state = utils.disconnectSession(session.id); |
| 80 session.id = utils.connectSession(contextGroup.id, state, session._dispatchM
essage.bind(session)); |
| 81 InspectorTest._sessions.set(session.id, session); |
| 82 }; |
| 83 session.sendRawCommand = (requestId, command, handler) => { |
| 84 if (InspectorTest._dumpInspectorProtocolMessages) |
| 85 utils.print("frontend: " + command); |
| 86 session._dispatchTable.set(requestId, handler); |
| 87 utils.sendMessageToBackend(session.id, command); |
31 } | 88 } |
32 }); | 89 session._sendCommandPromise = (method, params) => { |
| 90 var requestId = ++session._requestId; |
| 91 var messageObject = { "id": requestId, "method": method, "params": params }; |
| 92 var fulfillCallback; |
| 93 var promise = new Promise(fulfill => fulfillCallback = fulfill); |
| 94 if (InspectorTest._commandsForLogging.has(method)) { |
| 95 utils.print(method + ' called'); |
| 96 } |
| 97 session.sendRawCommand(requestId, JSON.stringify(messageObject), fulfillCall
back); |
| 98 return promise; |
| 99 } |
| 100 return session; |
| 101 } |
33 | 102 |
34 InspectorTest.logProtocolCommandCalls = (command) => InspectorTest._commandsForL
ogging.add(command); | 103 InspectorTest.logProtocolCommandCalls = (command) => InspectorTest._commandsForL
ogging.add(command); |
35 | 104 |
36 InspectorTest.log = utils.print.bind(null); | 105 InspectorTest.log = utils.print.bind(null); |
37 | 106 |
38 InspectorTest.logMessage = function(originalMessage) | 107 InspectorTest.logMessage = function(originalMessage) |
39 { | 108 { |
40 var message = JSON.parse(JSON.stringify(originalMessage)); | 109 var message = JSON.parse(JSON.stringify(originalMessage)); |
41 if (message.id) | 110 if (message.id) |
42 message.id = "<messageId>"; | 111 message.id = "<messageId>"; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 lines.push(firstLinePrefix + "["); | 170 lines.push(firstLinePrefix + "["); |
102 for (var i = 0; i < object.length; ++i) | 171 for (var i = 0; i < object.length; ++i) |
103 dumpValue(object[i], " " + prefix, " " + prefix + "[" + i + "] : "); | 172 dumpValue(object[i], " " + prefix, " " + prefix + "[" + i + "] : "); |
104 lines.push(prefix + "]"); | 173 lines.push(prefix + "]"); |
105 } | 174 } |
106 | 175 |
107 dumpValue(object, "", title || ""); | 176 dumpValue(object, "", title || ""); |
108 InspectorTest.log(lines.join("\n")); | 177 InspectorTest.log(lines.join("\n")); |
109 } | 178 } |
110 | 179 |
111 InspectorTest.logCallFrames = function(callFrames) | 180 InspectorTest.logCallFrames = function(callFrames, session) |
112 { | 181 { |
| 182 session = session || InspectorTest.session; |
113 for (var frame of callFrames) { | 183 for (var frame of callFrames) { |
114 var functionName = frame.functionName || '(anonymous)'; | 184 var functionName = frame.functionName || '(anonymous)'; |
115 var url = frame.url ? frame.url : InspectorTest._scriptMap.get(frame.locatio
n.scriptId).url; | 185 var url = frame.url ? frame.url : session._scriptMap.get(frame.location.scri
ptId).url; |
116 var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumb
er; | 186 var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumb
er; |
117 var columnNumber = frame.location ? frame.location.columnNumber : frame.colu
mnNumber; | 187 var columnNumber = frame.location ? frame.location.columnNumber : frame.colu
mnNumber; |
118 InspectorTest.log(`${functionName} (${url}:${lineNumber}:${columnNumber})`); | 188 InspectorTest.log(`${functionName} (${url}:${lineNumber}:${columnNumber})`); |
119 } | 189 } |
120 } | 190 } |
121 | 191 |
122 InspectorTest.logSourceLocation = function(location) | 192 InspectorTest.logSourceLocation = function(location, session) |
123 { | 193 { |
| 194 session = session || InspectorTest.session; |
124 var scriptId = location.scriptId; | 195 var scriptId = location.scriptId; |
125 if (!InspectorTest._scriptMap || !InspectorTest._scriptMap.has(scriptId)) { | 196 if (!session._scriptMap || !session._scriptMap.has(scriptId)) { |
126 InspectorTest.log("InspectorTest.setupScriptMap should be called before Prot
ocol.Debugger.enable."); | 197 InspectorTest.log("InspectorTest.setupScriptMap should be called before Prot
ocol.Debugger.enable."); |
127 InspectorTest.completeTest(); | 198 InspectorTest.completeTest(); |
128 } | 199 } |
129 var script = InspectorTest._scriptMap.get(scriptId); | 200 var script = session._scriptMap.get(scriptId); |
130 if (!script.scriptSource) { | 201 if (!script.scriptSource) { |
131 // TODO(kozyatinskiy): doesn't assume that contextId == contextGroupId. | 202 return session.Protocol.Debugger.getScriptSource({ scriptId }) |
132 return Protocol.Debugger.getScriptSource({ scriptId }, script.executionConte
xtId) | |
133 .then(message => script.scriptSource = message.result.scriptSource) | 203 .then(message => script.scriptSource = message.result.scriptSource) |
134 .then(dumpSourceWithLocation); | 204 .then(dumpSourceWithLocation); |
135 } | 205 } |
136 return Promise.resolve().then(dumpSourceWithLocation); | 206 return Promise.resolve().then(dumpSourceWithLocation); |
137 | 207 |
138 function dumpSourceWithLocation() { | 208 function dumpSourceWithLocation() { |
139 var lines = script.scriptSource.split('\n'); | 209 var lines = script.scriptSource.split('\n'); |
140 var line = lines[location.lineNumber]; | 210 var line = lines[location.lineNumber]; |
141 line = line.slice(0, location.columnNumber) + '#' + (line.slice(location.col
umnNumber) || ''); | 211 line = line.slice(0, location.columnNumber) + '#' + (line.slice(location.col
umnNumber) || ''); |
142 lines[location.lineNumber] = line; | 212 lines[location.lineNumber] = line; |
143 lines = lines.filter(line => line.indexOf('//# sourceURL=') === -1); | 213 lines = lines.filter(line => line.indexOf('//# sourceURL=') === -1); |
144 InspectorTest.log(lines.slice(Math.max(location.lineNumber - 1, 0), location
.lineNumber + 2).join('\n')); | 214 InspectorTest.log(lines.slice(Math.max(location.lineNumber - 1, 0), location
.lineNumber + 2).join('\n')); |
145 InspectorTest.log(''); | 215 InspectorTest.log(''); |
146 } | 216 } |
147 } | 217 } |
148 | 218 |
149 InspectorTest.logSourceLocations = function(locations) { | 219 InspectorTest.logSourceLocations = function(locations, session) { |
150 if (locations.length == 0) return Promise.resolve(); | 220 if (locations.length == 0) return Promise.resolve(); |
151 return InspectorTest.logSourceLocation(locations[0]) | 221 return InspectorTest.logSourceLocation(locations[0], session) |
152 .then(() => InspectorTest.logSourceLocations(locations.splice(1))); | 222 .then(() => InspectorTest.logSourceLocations(locations.splice(1), session)
); |
153 } | 223 } |
154 | 224 |
155 InspectorTest.logAsyncStackTrace = function(asyncStackTrace) | 225 InspectorTest.logAsyncStackTrace = function(asyncStackTrace, session) |
156 { | 226 { |
| 227 session = InspectorTest.session || session; |
157 while (asyncStackTrace) { | 228 while (asyncStackTrace) { |
158 if (asyncStackTrace.promiseCreationFrame) { | 229 if (asyncStackTrace.promiseCreationFrame) { |
159 var frame = asyncStackTrace.promiseCreationFrame; | 230 var frame = asyncStackTrace.promiseCreationFrame; |
160 InspectorTest.log(`-- ${asyncStackTrace.description} (${frame.url | 231 InspectorTest.log(`-- ${asyncStackTrace.description} (${frame.url |
161 }:${frame.lineNumber}:${frame.columnNumber})--`); | 232 }:${frame.lineNumber}:${frame.columnNumber})--`); |
162 } else { | 233 } else { |
163 InspectorTest.log(`-- ${asyncStackTrace.description} --`); | 234 InspectorTest.log(`-- ${asyncStackTrace.description} --`); |
164 } | 235 } |
165 InspectorTest.logCallFrames(asyncStackTrace.callFrames); | 236 InspectorTest.logCallFrames(asyncStackTrace.callFrames, session); |
166 asyncStackTrace = asyncStackTrace.parent; | 237 asyncStackTrace = asyncStackTrace.parent; |
167 } | 238 } |
168 } | 239 } |
169 | 240 |
170 InspectorTest.completeTest = () => Protocol.Debugger.disable().then(() => utils.
quit()); | 241 InspectorTest.completeTest = () => Protocol.Debugger.disable().then(() => utils.
quit()); |
171 | 242 |
172 InspectorTest.completeTestAfterPendingTimeouts = function() | 243 InspectorTest.completeTestAfterPendingTimeouts = function() |
173 { | 244 { |
174 InspectorTest.waitPendingTasks().then(InspectorTest.completeTest); | 245 InspectorTest.waitPendingTasks().then(InspectorTest.completeTest); |
175 } | 246 } |
176 | 247 |
177 InspectorTest.waitPendingTasks = function() | 248 InspectorTest.waitPendingTasks = function() |
178 { | 249 { |
179 return Protocol.Runtime.evaluate({ expression: "new Promise(r => setTimeout(r,
0))//# sourceURL=wait-pending-tasks.js", awaitPromise: true }); | 250 var promises = []; |
| 251 for (var session of InspectorTest._sessions.values()) |
| 252 promises.push(session.Protocol.Runtime.evaluate({ expression: "new Promise(r
=> setTimeout(r, 0))//# sourceURL=wait-pending-tasks.js", awaitPromise: true })
); |
| 253 return Promise.all(promises); |
180 } | 254 } |
181 | 255 |
182 InspectorTest.addScript = (string, lineOffset, columnOffset) => utils.compileAnd
RunWithOrigin(string, "", lineOffset || 0, columnOffset || 0, false); | |
183 InspectorTest.addScriptWithUrl = (string, url) => utils.compileAndRunWithOrigin(
string, url, 0, 0, false); | |
184 InspectorTest.addModule = (string, url, lineOffset, columnOffset) => utils.compi
leAndRunWithOrigin(string, url, lineOffset || 0, columnOffset || 0, true); | |
185 | |
186 InspectorTest.startDumpingProtocolMessages = function() | 256 InspectorTest.startDumpingProtocolMessages = function() |
187 { | 257 { |
188 InspectorTest._dumpInspectorProtocolMessages = true; | 258 InspectorTest._dumpInspectorProtocolMessages = true; |
189 } | 259 } |
190 | 260 |
191 InspectorTest.sendRawCommand = function(requestId, command, handler, contextGrou
pId) | |
192 { | |
193 if (InspectorTest._dumpInspectorProtocolMessages) | |
194 utils.print("frontend: " + command); | |
195 InspectorTest._dispatchTable.set(requestId, handler); | |
196 sendMessageToBackend(command, contextGroupId || 0); | |
197 } | |
198 | |
199 InspectorTest.checkExpectation = function(fail, name, messageObject) | 261 InspectorTest.checkExpectation = function(fail, name, messageObject) |
200 { | 262 { |
201 if (fail === !!messageObject.error) { | 263 if (fail === !!messageObject.error) { |
202 InspectorTest.log("PASS: " + name); | 264 InspectorTest.log("PASS: " + name); |
203 return true; | 265 return true; |
204 } | 266 } |
205 | 267 |
206 InspectorTest.log("FAIL: " + name + ": " + JSON.stringify(messageObject)); | 268 InspectorTest.log("FAIL: " + name + ": " + JSON.stringify(messageObject)); |
207 InspectorTest.completeTest(); | 269 InspectorTest.completeTest(); |
208 return false; | 270 return false; |
209 } | 271 } |
210 InspectorTest.expectedSuccess = InspectorTest.checkExpectation.bind(null, false)
; | 272 InspectorTest.expectedSuccess = InspectorTest.checkExpectation.bind(null, false)
; |
211 InspectorTest.expectedError = InspectorTest.checkExpectation.bind(null, true); | 273 InspectorTest.expectedError = InspectorTest.checkExpectation.bind(null, true); |
212 | 274 |
213 InspectorTest.setupScriptMap = function() { | 275 InspectorTest.setupScriptMap = function(session) { |
214 if (InspectorTest._scriptMap) | 276 session = session || InspectorTest.session; |
| 277 if (session._scriptMap) |
215 return; | 278 return; |
216 InspectorTest._scriptMap = new Map(); | 279 session._scriptMap = new Map(); |
217 } | 280 } |
218 | 281 |
219 InspectorTest.runTestSuite = function(testSuite) | 282 InspectorTest.runTestSuite = function(testSuite) |
220 { | 283 { |
221 function nextTest() | 284 function nextTest() |
222 { | 285 { |
223 if (!testSuite.length) { | 286 if (!testSuite.length) { |
224 InspectorTest.completeTest(); | 287 InspectorTest.completeTest(); |
225 return; | 288 return; |
226 } | 289 } |
227 var fun = testSuite.shift(); | 290 var fun = testSuite.shift(); |
228 InspectorTest.log("\nRunning test: " + fun.name); | 291 InspectorTest.log("\nRunning test: " + fun.name); |
229 fun(nextTest); | 292 fun(nextTest); |
230 } | 293 } |
231 nextTest(); | 294 nextTest(); |
232 } | 295 } |
233 | 296 |
234 InspectorTest.runAsyncTestSuite = async function(testSuite) { | 297 InspectorTest.runAsyncTestSuite = async function(testSuite) { |
235 for (var test of testSuite) { | 298 for (var test of testSuite) { |
236 InspectorTest.log("\nRunning test: " + test.name); | 299 InspectorTest.log("\nRunning test: " + test.name); |
237 await test(); | 300 try { |
| 301 await test(); |
| 302 } catch (e) { |
| 303 utils.print(e.stack); |
| 304 } |
238 } | 305 } |
239 InspectorTest.completeTest(); | 306 InspectorTest.completeTest(); |
240 } | 307 } |
241 | 308 |
242 InspectorTest._sendCommandPromise = function(method, params, contextGroupId) | 309 InspectorTest._waitForEventPromise = function(session, eventName) |
243 { | 310 { |
244 var requestId = ++InspectorTest._requestId; | 311 return new Promise(fulfill => session._eventHandler[eventName] = fullfillAndCl
earListener.bind(null, fulfill)); |
245 var messageObject = { "id": requestId, "method": method, "params": params }; | |
246 var fulfillCallback; | |
247 var promise = new Promise(fulfill => fulfillCallback = fulfill); | |
248 if (InspectorTest._commandsForLogging.has(method)) { | |
249 utils.print(method + ' called'); | |
250 } | |
251 InspectorTest.sendRawCommand(requestId, JSON.stringify(messageObject), fulfill
Callback, contextGroupId); | |
252 return promise; | |
253 } | |
254 | |
255 InspectorTest._waitForEventPromise = function(eventName) | |
256 { | |
257 return new Promise(fulfill => InspectorTest._eventHandler[eventName] = fullfil
lAndClearListener.bind(null, fulfill)); | |
258 | 312 |
259 function fullfillAndClearListener(fulfill, result) | 313 function fullfillAndClearListener(fulfill, result) |
260 { | 314 { |
261 delete InspectorTest._eventHandler[eventName]; | 315 delete session._eventHandler[eventName]; |
262 fulfill(result); | 316 fulfill(result); |
263 } | 317 } |
264 } | 318 } |
265 | 319 |
266 InspectorTest._dispatchMessage = function(messageObject) | 320 InspectorTest.setupInjectedScriptEnvironment = function(debug, session) { |
267 { | 321 session = session || InspectorTest.session; |
268 if (InspectorTest._dumpInspectorProtocolMessages) | |
269 utils.print("backend: " + JSON.stringify(messageObject)); | |
270 try { | |
271 var messageId = messageObject["id"]; | |
272 if (typeof messageId === "number") { | |
273 var handler = InspectorTest._dispatchTable.get(messageId); | |
274 if (handler) { | |
275 handler(messageObject); | |
276 InspectorTest._dispatchTable.delete(messageId); | |
277 } | |
278 } else { | |
279 var eventName = messageObject["method"]; | |
280 var eventHandler = InspectorTest._eventHandler[eventName]; | |
281 if (InspectorTest._scriptMap && eventName === "Debugger.scriptParsed") | |
282 InspectorTest._scriptMap.set(messageObject.params.scriptId, JSON.parse(J
SON.stringify(messageObject.params))); | |
283 if (eventName === "Debugger.scriptParsed" && messageObject.params.url ===
"wait-pending-tasks.js") | |
284 return; | |
285 if (eventHandler) | |
286 eventHandler(messageObject); | |
287 } | |
288 } catch (e) { | |
289 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); | |
290 InspectorTest.completeTest(); | |
291 } | |
292 } | |
293 | |
294 InspectorTest.loadScript = function(fileName) { | |
295 InspectorTest.addScript(utils.read(fileName)); | |
296 } | |
297 | |
298 InspectorTest.setupInjectedScriptEnvironment = function(debug) { | |
299 let scriptSource = ''; | 322 let scriptSource = ''; |
300 // First define all getters on Object.prototype. | 323 // First define all getters on Object.prototype. |
301 let injectedScriptSource = utils.read('src/inspector/injected-script-source.js
'); | 324 let injectedScriptSource = utils.read('src/inspector/injected-script-source.js
'); |
302 let getterRegex = /\.[a-zA-Z0-9]+/g; | 325 let getterRegex = /\.[a-zA-Z0-9]+/g; |
303 let match; | 326 let match; |
304 let getters = new Set(); | 327 let getters = new Set(); |
305 while (match = getterRegex.exec(injectedScriptSource)) { | 328 while (match = getterRegex.exec(injectedScriptSource)) { |
306 getters.add(match[0].substr(1)); | 329 getters.add(match[0].substr(1)); |
307 } | 330 } |
308 scriptSource += `(function installSettersAndGetters() { | 331 scriptSource += `(function installSettersAndGetters() { |
309 let defineProperty = Object.defineProperty; | 332 let defineProperty = Object.defineProperty; |
310 let ObjectPrototype = Object.prototype;\n`; | 333 let ObjectPrototype = Object.prototype;\n`; |
311 scriptSource += Array.from(getters).map(getter => ` | 334 scriptSource += Array.from(getters).map(getter => ` |
312 defineProperty(ObjectPrototype, '${getter}', { | 335 defineProperty(ObjectPrototype, '${getter}', { |
313 set() { debugger; throw 42; }, get() { debugger; throw 42; }, | 336 set() { debugger; throw 42; }, get() { debugger; throw 42; }, |
314 __proto__: null | 337 __proto__: null |
315 }); | 338 }); |
316 `).join('\n') + '})();'; | 339 `).join('\n') + '})();'; |
317 InspectorTest.addScript(scriptSource); | 340 session.contextGroup.addScript(scriptSource); |
318 | 341 |
319 if (debug) { | 342 if (debug) { |
320 InspectorTest.log('WARNING: InspectorTest.setupInjectedScriptEnvironment wit
h debug flag for debugging only and should not be landed.'); | 343 InspectorTest.log('WARNING: InspectorTest.setupInjectedScriptEnvironment wit
h debug flag for debugging only and should not be landed.'); |
321 InspectorTest.log('WARNING: run test with --expose-inspector-scripts flag to
get more details.'); | 344 InspectorTest.log('WARNING: run test with --expose-inspector-scripts flag to
get more details.'); |
322 InspectorTest.log('WARNING: you can additionally comment rjsmin in xxd.py to
get unminified injected-script-source.js.'); | 345 InspectorTest.log('WARNING: you can additionally comment rjsmin in xxd.py to
get unminified injected-script-source.js.'); |
323 InspectorTest.setupScriptMap(); | 346 InspectorTest.setupScriptMap(session); |
324 Protocol.Debugger.enable(); | 347 sesison.Protocol.Debugger.enable(); |
325 Protocol.Debugger.onPaused(message => { | 348 session.Protocol.Debugger.onPaused(message => { |
326 let callFrames = message.params.callFrames; | 349 let callFrames = message.params.callFrames; |
327 InspectorTest.logSourceLocations(callFrames.map(frame => frame.location)); | 350 InspectorTest.logSourceLocations(callFrames.map(frame => frame.location),
session); |
328 }) | 351 }) |
329 } | 352 } |
330 } | 353 } |
| 354 |
| 355 try { |
| 356 InspectorTest.contextGroup = InspectorTest.createContextGroup(); |
| 357 InspectorTest.session = InspectorTest.createSession(InspectorTest.contextGroup
); |
| 358 this.Protocol = InspectorTest.session.Protocol; |
| 359 InspectorTest.addScript = InspectorTest.contextGroup.addScript.bind(InspectorT
est.contextGroup); |
| 360 InspectorTest.addModule = InspectorTest.contextGroup.addModule.bind(InspectorT
est.contextGroup); |
| 361 InspectorTest.loadScript = fileName => InspectorTest.addScript(utils.read(file
Name)); |
| 362 } catch (e) { |
| 363 utils.print(e.stack); |
| 364 } |
OLD | NEW |