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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/inspector/debugger-test.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
OLDNEW
1 function scheduleTestFunction() 1 function scheduleTestFunction()
2 { 2 {
3 setTimeout(testFunction, 0); 3 setTimeout(testFunction, 0);
4 } 4 }
5 5
6 var initialize_DebuggerTest = function() { 6 var initialize_DebuggerTest = function() {
7 7
8 InspectorTest.preloadPanel("sources"); 8 InspectorTest.preloadPanel("sources");
9 9
10 InspectorTest.startDebuggerTest = function(callback, quiet) 10 InspectorTest.startDebuggerTest = function(callback, quiet)
11 { 11 {
12 console.assert(InspectorTest.debuggerModel.debuggerEnabled(), "Debugger has to be enabled"); 12 console.assert(InspectorTest.debuggerModel.debuggerEnabled(), "Debugger has to be enabled");
13 if (quiet !== undefined) 13 if (quiet !== undefined)
14 InspectorTest._quiet = quiet; 14 InspectorTest._quiet = quiet;
15 WebInspector.viewManager.showView("sources"); 15 UI.viewManager.showView("sources");
16 16
17 InspectorTest.addSniffer(WebInspector.DebuggerModel.prototype, "_pausedScrip t", InspectorTest._pausedScript, true); 17 InspectorTest.addSniffer(SDK.DebuggerModel.prototype, "_pausedScript", Inspe ctorTest._pausedScript, true);
18 InspectorTest.addSniffer(WebInspector.DebuggerModel.prototype, "_resumedScri pt", InspectorTest._resumedScript, true); 18 InspectorTest.addSniffer(SDK.DebuggerModel.prototype, "_resumedScript", Insp ectorTest._resumedScript, true);
19 InspectorTest.safeWrap(callback)(); 19 InspectorTest.safeWrap(callback)();
20 }; 20 };
21 21
22 InspectorTest.startDebuggerTestPromise = function(quiet) 22 InspectorTest.startDebuggerTestPromise = function(quiet)
23 { 23 {
24 var cb; 24 var cb;
25 var p = new Promise(fullfill => cb = fullfill); 25 var p = new Promise(fullfill => cb = fullfill);
26 InspectorTest.startDebuggerTest(cb, quiet); 26 InspectorTest.startDebuggerTest(cb, quiet);
27 return p; 27 return p;
28 } 28 }
29 29
30 InspectorTest.completeDebuggerTest = function() 30 InspectorTest.completeDebuggerTest = function()
31 { 31 {
32 WebInspector.breakpointManager.setBreakpointsActive(true); 32 Bindings.breakpointManager.setBreakpointsActive(true);
33 InspectorTest.resumeExecution(InspectorTest.completeTest.bind(InspectorTest) ); 33 InspectorTest.resumeExecution(InspectorTest.completeTest.bind(InspectorTest) );
34 }; 34 };
35 35
36 (function() { 36 (function() {
37 // FIXME: Until there is no window.onerror() for uncaught exceptions in prom ises 37 // FIXME: Until there is no window.onerror() for uncaught exceptions in prom ises
38 // we use this hack to print the exceptions instead of just timing out. 38 // we use this hack to print the exceptions instead of just timing out.
39 39
40 var origThen = Promise.prototype.then; 40 var origThen = Promise.prototype.then;
41 var origCatch = Promise.prototype.catch; 41 var origCatch = Promise.prototype.catch;
42 42
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 callback = InspectorTest.safeWrap(callback); 159 callback = InspectorTest.safeWrap(callback);
160 160
161 if (!InspectorTest._pausedScriptArguments) 161 if (!InspectorTest._pausedScriptArguments)
162 callback(); 162 callback();
163 else 163 else
164 InspectorTest._waitUntilResumedCallback = callback; 164 InspectorTest._waitUntilResumedCallback = callback;
165 }; 165 };
166 166
167 InspectorTest.resumeExecution = function(callback) 167 InspectorTest.resumeExecution = function(callback)
168 { 168 {
169 if (WebInspector.panels.sources.paused()) 169 if (UI.panels.sources.paused())
170 WebInspector.panels.sources._togglePause(); 170 UI.panels.sources._togglePause();
171 InspectorTest.waitUntilResumed(callback); 171 InspectorTest.waitUntilResumed(callback);
172 }; 172 };
173 173
174 InspectorTest.waitUntilPausedAndDumpStackAndResume = function(callback, options) 174 InspectorTest.waitUntilPausedAndDumpStackAndResume = function(callback, options)
175 { 175 {
176 InspectorTest.waitUntilPaused(paused); 176 InspectorTest.waitUntilPaused(paused);
177 InspectorTest.addSniffer(WebInspector.SourcesPanel.prototype, "_updateDebugg erButtonsAndStatus", setStatus); 177 InspectorTest.addSniffer(Sources.SourcesPanel.prototype, "_updateDebuggerBut tonsAndStatus", setStatus);
178 178
179 var caption; 179 var caption;
180 var callFrames; 180 var callFrames;
181 var asyncStackTrace; 181 var asyncStackTrace;
182 182
183 function setStatus() 183 function setStatus()
184 { 184 {
185 var statusElement = this.element.querySelector(".paused-message"); 185 var statusElement = this.element.querySelector(".paused-message");
186 caption = statusElement.deepTextContent(); 186 caption = statusElement.deepTextContent();
187 if (callFrames) 187 if (callFrames)
(...skipping 16 matching lines...) Expand all
204 } 204 }
205 205
206 function step2() 206 function step2()
207 { 207 {
208 InspectorTest.resumeExecution(InspectorTest.safeWrap(callback)); 208 InspectorTest.resumeExecution(InspectorTest.safeWrap(callback));
209 } 209 }
210 }; 210 };
211 211
212 InspectorTest.stepOver = function() 212 InspectorTest.stepOver = function()
213 { 213 {
214 Promise.resolve().then(function(){WebInspector.panels.sources._stepOver()}); 214 Promise.resolve().then(function(){UI.panels.sources._stepOver()});
215 }; 215 };
216 216
217 InspectorTest.stepInto = function() 217 InspectorTest.stepInto = function()
218 { 218 {
219 Promise.resolve().then(function(){WebInspector.panels.sources._stepInto()}); 219 Promise.resolve().then(function(){UI.panels.sources._stepInto()});
220 }; 220 };
221 221
222 InspectorTest.stepOut = function() 222 InspectorTest.stepOut = function()
223 { 223 {
224 Promise.resolve().then(function(){WebInspector.panels.sources._stepOut()}); 224 Promise.resolve().then(function(){UI.panels.sources._stepOut()});
225 }; 225 };
226 226
227 InspectorTest.togglePause = function() 227 InspectorTest.togglePause = function()
228 { 228 {
229 Promise.resolve().then(function(){WebInspector.panels.sources._togglePause() }); 229 Promise.resolve().then(function(){UI.panels.sources._togglePause()});
230 }; 230 };
231 231
232 InspectorTest.waitUntilPausedAndPerformSteppingActions = function(actions, callb ack) 232 InspectorTest.waitUntilPausedAndPerformSteppingActions = function(actions, callb ack)
233 { 233 {
234 callback = InspectorTest.safeWrap(callback); 234 callback = InspectorTest.safeWrap(callback);
235 InspectorTest.waitUntilPaused(didPause); 235 InspectorTest.waitUntilPaused(didPause);
236 236
237 function didPause(callFrames, reason, breakpointIds, asyncStackTrace) 237 function didPause(callFrames, reason, breakpointIds, asyncStackTrace)
238 { 238 {
239 var action = actions.shift(); 239 var action = actions.shift();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 { 283 {
284 var results = []; 284 var results = [];
285 options = options || {}; 285 options = options || {};
286 function printCallFrames(callFrames, locationFunction, returnValueFunction) 286 function printCallFrames(callFrames, locationFunction, returnValueFunction)
287 { 287 {
288 var printed = 0; 288 var printed = 0;
289 for (var i = 0; i < callFrames.length; i++) { 289 for (var i = 0; i < callFrames.length; i++) {
290 var frame = callFrames[i]; 290 var frame = callFrames[i];
291 var location = locationFunction.call(frame); 291 var location = locationFunction.call(frame);
292 var script = location.script(); 292 var script = location.script();
293 var uiLocation = WebInspector.debuggerWorkspaceBinding.rawLocationTo UILocation(location); 293 var uiLocation = Bindings.debuggerWorkspaceBinding.rawLocationToUILo cation(location);
294 var isFramework = WebInspector.blackboxManager.isBlackboxedRawLocati on(location); 294 var isFramework = Bindings.blackboxManager.isBlackboxedRawLocation(l ocation);
295 if (options.dropFrameworkCallFrames && isFramework) 295 if (options.dropFrameworkCallFrames && isFramework)
296 continue; 296 continue;
297 var url; 297 var url;
298 var lineNumber; 298 var lineNumber;
299 if (uiLocation && uiLocation.uiSourceCode.project().type() !== WebIn spector.projectTypes.Debugger) { 299 if (uiLocation && uiLocation.uiSourceCode.project().type() !== Works pace.projectTypes.Debugger) {
300 url = uiLocation.uiSourceCode.name(); 300 url = uiLocation.uiSourceCode.name();
301 lineNumber = uiLocation.lineNumber + 1; 301 lineNumber = uiLocation.lineNumber + 1;
302 } else { 302 } else {
303 url = WebInspector.displayNameForURL(script.sourceURL); 303 url = Bindings.displayNameForURL(script.sourceURL);
304 lineNumber = location.lineNumber + 1; 304 lineNumber = location.lineNumber + 1;
305 } 305 }
306 var s = (isFramework ? " * " : " ") + (printed++) + ") " + frame .functionName + " (" + url + (options.dropLineNumbers ? "" : ":" + lineNumber) + ")"; 306 var s = (isFramework ? " * " : " ") + (printed++) + ") " + frame .functionName + " (" + url + (options.dropLineNumbers ? "" : ":" + lineNumber) + ")";
307 results.push(s); 307 results.push(s);
308 if (options.printReturnValue && returnValueFunction && returnValueFu nction.call(frame)) 308 if (options.printReturnValue && returnValueFunction && returnValueFu nction.call(frame))
309 results.push(" <return>: " + returnValueFunction.call(fram e).description); 309 results.push(" <return>: " + returnValueFunction.call(fram e).description);
310 if (frame.functionName === "scheduleTestFunction") { 310 if (frame.functionName === "scheduleTestFunction") {
311 var remainingFrames = callFrames.length - 1 - i; 311 var remainingFrames = callFrames.length - 1 - i;
312 if (remainingFrames) 312 if (remainingFrames)
313 results.push(" <... skipped remaining frames ...>"); 313 results.push(" <... skipped remaining frames ...>");
314 break; 314 break;
315 } 315 }
316 } 316 }
317 return printed; 317 return printed;
318 } 318 }
319 319
320 function runtimeCallFramePosition() 320 function runtimeCallFramePosition()
321 { 321 {
322 return new WebInspector.DebuggerModel.Location(debuggerModel, this.scrip tId, this.lineNumber, this.columnNumber); 322 return new SDK.DebuggerModel.Location(debuggerModel, this.scriptId, this .lineNumber, this.columnNumber);
323 } 323 }
324 324
325 results.push("Call stack:"); 325 results.push("Call stack:");
326 printCallFrames(callFrames, WebInspector.DebuggerModel.CallFrame.prototype.l ocation, WebInspector.DebuggerModel.CallFrame.prototype.returnValue); 326 printCallFrames(callFrames, SDK.DebuggerModel.CallFrame.prototype.location, SDK.DebuggerModel.CallFrame.prototype.returnValue);
327 while (asyncStackTrace) { 327 while (asyncStackTrace) {
328 results.push(" [" + (asyncStackTrace.description || "Async Call") + " ]"); 328 results.push(" [" + (asyncStackTrace.description || "Async Call") + " ]");
329 var debuggerModel = WebInspector.DebuggerModel.fromTarget(WebInspector.t argetManager.mainTarget()); 329 var debuggerModel = SDK.DebuggerModel.fromTarget(SDK.targetManager.mainT arget());
330 var printed = printCallFrames(asyncStackTrace.callFrames, runtimeCallFra mePosition); 330 var printed = printCallFrames(asyncStackTrace.callFrames, runtimeCallFra mePosition);
331 if (!printed) 331 if (!printed)
332 results.pop(); 332 results.pop();
333 asyncStackTrace = asyncStackTrace.parent; 333 asyncStackTrace = asyncStackTrace.parent;
334 } 334 }
335 return results.join("\n"); 335 return results.join("\n");
336 }; 336 };
337 337
338 InspectorTest.dumpSourceFrameContents = function(sourceFrame) 338 InspectorTest.dumpSourceFrameContents = function(sourceFrame)
339 { 339 {
340 InspectorTest.addResult("==Source frame contents start=="); 340 InspectorTest.addResult("==Source frame contents start==");
341 var textEditor = sourceFrame._textEditor; 341 var textEditor = sourceFrame._textEditor;
342 for (var i = 0; i < textEditor.linesCount; ++i) 342 for (var i = 0; i < textEditor.linesCount; ++i)
343 InspectorTest.addResult(textEditor.line(i)); 343 InspectorTest.addResult(textEditor.line(i));
344 InspectorTest.addResult("==Source frame contents end=="); 344 InspectorTest.addResult("==Source frame contents end==");
345 }; 345 };
346 346
347 InspectorTest._pausedScript = function(callFrames, reason, auxData, breakpointId s, asyncStackTrace) 347 InspectorTest._pausedScript = function(callFrames, reason, auxData, breakpointId s, asyncStackTrace)
348 { 348 {
349 if (!InspectorTest._quiet) 349 if (!InspectorTest._quiet)
350 InspectorTest.addResult("Script execution paused."); 350 InspectorTest.addResult("Script execution paused.");
351 var debuggerModel = WebInspector.DebuggerModel.fromTarget(this.target()); 351 var debuggerModel = SDK.DebuggerModel.fromTarget(this.target());
352 InspectorTest._pausedScriptArguments = [WebInspector.DebuggerModel.CallFrame .fromPayloadArray(debuggerModel, callFrames), reason, breakpointIds, asyncStackT race, auxData]; 352 InspectorTest._pausedScriptArguments = [SDK.DebuggerModel.CallFrame.fromPayl oadArray(debuggerModel, callFrames), reason, breakpointIds, asyncStackTrace, aux Data];
353 if (InspectorTest._waitUntilPausedCallback) { 353 if (InspectorTest._waitUntilPausedCallback) {
354 var callback = InspectorTest._waitUntilPausedCallback; 354 var callback = InspectorTest._waitUntilPausedCallback;
355 delete InspectorTest._waitUntilPausedCallback; 355 delete InspectorTest._waitUntilPausedCallback;
356 setTimeout(() => callback.apply(callback, InspectorTest._pausedScriptArg uments)); 356 setTimeout(() => callback.apply(callback, InspectorTest._pausedScriptArg uments));
357 } 357 }
358 }; 358 };
359 359
360 InspectorTest._resumedScript = function() 360 InspectorTest._resumedScript = function()
361 { 361 {
362 if (!InspectorTest._quiet) 362 if (!InspectorTest._quiet)
363 InspectorTest.addResult("Script execution resumed."); 363 InspectorTest.addResult("Script execution resumed.");
364 delete InspectorTest._pausedScriptArguments; 364 delete InspectorTest._pausedScriptArguments;
365 if (InspectorTest._waitUntilResumedCallback) { 365 if (InspectorTest._waitUntilResumedCallback) {
366 var callback = InspectorTest._waitUntilResumedCallback; 366 var callback = InspectorTest._waitUntilResumedCallback;
367 delete InspectorTest._waitUntilResumedCallback; 367 delete InspectorTest._waitUntilResumedCallback;
368 callback(); 368 callback();
369 } 369 }
370 }; 370 };
371 371
372 InspectorTest.showUISourceCode = function(uiSourceCode, callback) 372 InspectorTest.showUISourceCode = function(uiSourceCode, callback)
373 { 373 {
374 var panel = WebInspector.panels.sources; 374 var panel = UI.panels.sources;
375 panel.showUISourceCode(uiSourceCode); 375 panel.showUISourceCode(uiSourceCode);
376 var sourceFrame = panel.visibleView; 376 var sourceFrame = panel.visibleView;
377 if (sourceFrame.loaded) 377 if (sourceFrame.loaded)
378 callback(sourceFrame); 378 callback(sourceFrame);
379 else 379 else
380 InspectorTest.addSniffer(sourceFrame, "onTextEditorContentSet", callback && callback.bind(null, sourceFrame)); 380 InspectorTest.addSniffer(sourceFrame, "onTextEditorContentSet", callback && callback.bind(null, sourceFrame));
381 }; 381 };
382 382
383 InspectorTest.showUISourceCodePromise = function(uiSourceCode) 383 InspectorTest.showUISourceCodePromise = function(uiSourceCode)
384 { 384 {
385 var fulfill; 385 var fulfill;
386 var promise = new Promise(x => fulfill = x); 386 var promise = new Promise(x => fulfill = x);
387 InspectorTest.showUISourceCode(uiSourceCode, fulfill); 387 InspectorTest.showUISourceCode(uiSourceCode, fulfill);
388 return promise; 388 return promise;
389 } 389 }
390 390
391 InspectorTest.showScriptSource = function(scriptName, callback) 391 InspectorTest.showScriptSource = function(scriptName, callback)
392 { 392 {
393 InspectorTest.waitForScriptSource(scriptName, onScriptSource); 393 InspectorTest.waitForScriptSource(scriptName, onScriptSource);
394 394
395 function onScriptSource(uiSourceCode) 395 function onScriptSource(uiSourceCode)
396 { 396 {
397 InspectorTest.showUISourceCode(uiSourceCode, callback); 397 InspectorTest.showUISourceCode(uiSourceCode, callback);
398 } 398 }
399 }; 399 };
400 400
401 InspectorTest.waitForScriptSource = function(scriptName, callback) 401 InspectorTest.waitForScriptSource = function(scriptName, callback)
402 { 402 {
403 var panel = WebInspector.panels.sources; 403 var panel = UI.panels.sources;
404 var uiSourceCodes = panel._workspace.uiSourceCodes(); 404 var uiSourceCodes = panel._workspace.uiSourceCodes();
405 for (var i = 0; i < uiSourceCodes.length; ++i) { 405 for (var i = 0; i < uiSourceCodes.length; ++i) {
406 if (uiSourceCodes[i].project().type() === WebInspector.projectTypes.Serv ice) 406 if (uiSourceCodes[i].project().type() === Workspace.projectTypes.Service )
407 continue; 407 continue;
408 if (uiSourceCodes[i].name() === scriptName) { 408 if (uiSourceCodes[i].name() === scriptName) {
409 callback(uiSourceCodes[i]); 409 callback(uiSourceCodes[i]);
410 return; 410 return;
411 } 411 }
412 } 412 }
413 413
414 InspectorTest.addSniffer(WebInspector.SourcesView.prototype, "_addUISourceCo de", InspectorTest.waitForScriptSource.bind(InspectorTest, scriptName, callback) ); 414 InspectorTest.addSniffer(Sources.SourcesView.prototype, "_addUISourceCode", InspectorTest.waitForScriptSource.bind(InspectorTest, scriptName, callback));
415 }; 415 };
416 416
417 InspectorTest.setBreakpoint = function(sourceFrame, lineNumber, condition, enabl ed) 417 InspectorTest.setBreakpoint = function(sourceFrame, lineNumber, condition, enabl ed)
418 { 418 {
419 if (!sourceFrame._muted) 419 if (!sourceFrame._muted)
420 sourceFrame._setBreakpoint(lineNumber, 0, condition, enabled); 420 sourceFrame._setBreakpoint(lineNumber, 0, condition, enabled);
421 }; 421 };
422 422
423 InspectorTest.removeBreakpoint = function(sourceFrame, lineNumber) 423 InspectorTest.removeBreakpoint = function(sourceFrame, lineNumber)
424 { 424 {
425 sourceFrame._breakpointManager.findBreakpoints(sourceFrame._uiSourceCode, li neNumber)[0].remove(); 425 sourceFrame._breakpointManager.findBreakpoints(sourceFrame._uiSourceCode, li neNumber)[0].remove();
426 }; 426 };
427 427
428 InspectorTest.dumpBreakpointSidebarPane = function(title) 428 InspectorTest.dumpBreakpointSidebarPane = function(title)
429 { 429 {
430 var paneElement = self.runtime.sharedInstance(WebInspector.JavaScriptBreakpo intsSidebarPane).element; 430 var paneElement = self.runtime.sharedInstance(Sources.JavaScriptBreakpointsS idebarPane).element;
431 InspectorTest.addResult("Breakpoint sidebar pane " + (title || "")); 431 InspectorTest.addResult("Breakpoint sidebar pane " + (title || ""));
432 InspectorTest.addResult(InspectorTest.textContentWithLineBreaks(paneElement) ); 432 InspectorTest.addResult(InspectorTest.textContentWithLineBreaks(paneElement) );
433 }; 433 };
434 434
435 InspectorTest.dumpScopeVariablesSidebarPane = function() 435 InspectorTest.dumpScopeVariablesSidebarPane = function()
436 { 436 {
437 InspectorTest.addResult("Scope variables sidebar pane:"); 437 InspectorTest.addResult("Scope variables sidebar pane:");
438 var sections = InspectorTest.scopeChainSections(); 438 var sections = InspectorTest.scopeChainSections();
439 for (var i = 0; i < sections.length; ++i) { 439 for (var i = 0; i < sections.length; ++i) {
440 var textContent = InspectorTest.textContentWithLineBreaks(sections[i].el ement); 440 var textContent = InspectorTest.textContentWithLineBreaks(sections[i].el ement);
441 var text = InspectorTest.clearSpecificInfoFromStackFrames(textContent); 441 var text = InspectorTest.clearSpecificInfoFromStackFrames(textContent);
442 if (text.length > 0) 442 if (text.length > 0)
443 InspectorTest.addResult(text); 443 InspectorTest.addResult(text);
444 if (!sections[i].objectTreeElement().expanded) 444 if (!sections[i].objectTreeElement().expanded)
445 InspectorTest.addResult(" <section collapsed>"); 445 InspectorTest.addResult(" <section collapsed>");
446 } 446 }
447 }; 447 };
448 448
449 InspectorTest.scopeChainSections = function() 449 InspectorTest.scopeChainSections = function()
450 { 450 {
451 var children = self.runtime.sharedInstance(WebInspector.ScopeChainSidebarPan e).contentElement.children; 451 var children = self.runtime.sharedInstance(Sources.ScopeChainSidebarPane).co ntentElement.children;
452 var sections = []; 452 var sections = [];
453 for (var i = 0; i < children.length; ++i) 453 for (var i = 0; i < children.length; ++i)
454 sections.push(children[i]._section); 454 sections.push(children[i]._section);
455 455
456 return sections; 456 return sections;
457 } 457 }
458 458
459 InspectorTest.expandScopeVariablesSidebarPane = function(callback) 459 InspectorTest.expandScopeVariablesSidebarPane = function(callback)
460 { 460 {
461 // Expand all but the global scope. Expanding global scope takes for too lon g so we keep it collapsed. 461 // Expand all but the global scope. Expanding global scope takes for too lon g so we keep it collapsed.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 for (var scriptId in InspectorTest.debuggerModel._scripts) { 521 for (var scriptId in InspectorTest.debuggerModel._scripts) {
522 var script = InspectorTest.debuggerModel._scripts[scriptId]; 522 var script = InspectorTest.debuggerModel._scripts[scriptId];
523 if (!filter || filter(script)) 523 if (!filter || filter(script))
524 scripts.push(script); 524 scripts.push(script);
525 } 525 }
526 return scripts; 526 return scripts;
527 }; 527 };
528 528
529 InspectorTest.createScriptMock = function(url, startLine, startColumn, isContent Script, source, target, preRegisterCallback) 529 InspectorTest.createScriptMock = function(url, startLine, startColumn, isContent Script, source, target, preRegisterCallback)
530 { 530 {
531 target = target || WebInspector.targetManager.mainTarget(); 531 target = target || SDK.targetManager.mainTarget();
532 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 532 var debuggerModel = SDK.DebuggerModel.fromTarget(target);
533 var scriptId = ++InspectorTest._lastScriptId + ""; 533 var scriptId = ++InspectorTest._lastScriptId + "";
534 var lineCount = source.computeLineEndings().length; 534 var lineCount = source.computeLineEndings().length;
535 var endLine = startLine + lineCount - 1; 535 var endLine = startLine + lineCount - 1;
536 var endColumn = lineCount === 1 ? startColumn + source.length : source.lengt h - source.computeLineEndings()[lineCount - 2]; 536 var endColumn = lineCount === 1 ? startColumn + source.length : source.lengt h - source.computeLineEndings()[lineCount - 2];
537 var hasSourceURL = !!source.match(/\/\/#\ssourceURL=\s*(\S*?)\s*$/m) || !!so urce.match(/\/\/@\ssourceURL=\s*(\S*?)\s*$/m); 537 var hasSourceURL = !!source.match(/\/\/#\ssourceURL=\s*(\S*?)\s*$/m) || !!so urce.match(/\/\/@\ssourceURL=\s*(\S*?)\s*$/m);
538 var script = new WebInspector.Script(debuggerModel, scriptId, url, startLine , startColumn, endLine, endColumn, 0, "", isContentScript, false, undefined, has SourceURL); 538 var script = new SDK.Script(debuggerModel, scriptId, url, startLine, startCo lumn, endLine, endColumn, 0, "", isContentScript, false, undefined, hasSourceURL );
539 script.requestContent = function() 539 script.requestContent = function()
540 { 540 {
541 var trimmedSource = WebInspector.Script._trimSourceURLComment(source); 541 var trimmedSource = SDK.Script._trimSourceURLComment(source);
542 return Promise.resolve(trimmedSource); 542 return Promise.resolve(trimmedSource);
543 }; 543 };
544 if (preRegisterCallback) 544 if (preRegisterCallback)
545 preRegisterCallback(script); 545 preRegisterCallback(script);
546 debuggerModel._registerScript(script); 546 debuggerModel._registerScript(script);
547 return script; 547 return script;
548 }; 548 };
549 549
550 InspectorTest._lastScriptId = 0; 550 InspectorTest._lastScriptId = 0;
551 551
552 InspectorTest.checkRawLocation = function(script, lineNumber, columnNumber, loca tion) 552 InspectorTest.checkRawLocation = function(script, lineNumber, columnNumber, loca tion)
553 { 553 {
554 InspectorTest.assertEquals(script.scriptId, location.scriptId, "Incorrect sc riptId"); 554 InspectorTest.assertEquals(script.scriptId, location.scriptId, "Incorrect sc riptId");
555 InspectorTest.assertEquals(lineNumber, location.lineNumber, "Incorrect lineN umber"); 555 InspectorTest.assertEquals(lineNumber, location.lineNumber, "Incorrect lineN umber");
556 InspectorTest.assertEquals(columnNumber, location.columnNumber, "Incorrect c olumnNumber"); 556 InspectorTest.assertEquals(columnNumber, location.columnNumber, "Incorrect c olumnNumber");
557 }; 557 };
558 558
559 InspectorTest.checkUILocation = function(uiSourceCode, lineNumber, columnNumber, location) 559 InspectorTest.checkUILocation = function(uiSourceCode, lineNumber, columnNumber, location)
560 { 560 {
561 InspectorTest.assertEquals(uiSourceCode, location.uiSourceCode, "Incorrect u iSourceCode, expected '" + (uiSourceCode ? uiSourceCode.url() : null) + "'," + 561 InspectorTest.assertEquals(uiSourceCode, location.uiSourceCode, "Incorrect u iSourceCode, expected '" + (uiSourceCode ? uiSourceCode.url() : null) + "'," +
562 " but got '" + (location.uiSourceCode ? location.uiSourceCode.url() : null) + "'"); 562 " but got '" + (location.uiSourceCode ? location.uiSourceCode.url() : null) + "'");
563 InspectorTest.assertEquals(lineNumber, location.lineNumber, "Incorrect lineN umber, expected '" + lineNumber + "', but got '" + location.lineNumber + "'"); 563 InspectorTest.assertEquals(lineNumber, location.lineNumber, "Incorrect lineN umber, expected '" + lineNumber + "', but got '" + location.lineNumber + "'");
564 InspectorTest.assertEquals(columnNumber, location.columnNumber, "Incorrect c olumnNumber, expected '" + columnNumber + "', but got '" + location.columnNumber + "'"); 564 InspectorTest.assertEquals(columnNumber, location.columnNumber, "Incorrect c olumnNumber, expected '" + columnNumber + "', but got '" + location.columnNumber + "'");
565 }; 565 };
566 566
567 InspectorTest.scriptFormatter = function() 567 InspectorTest.scriptFormatter = function()
568 { 568 {
569 return self.runtime.allInstances(WebInspector.SourcesView.EditorAction).then (function(editorActions) { 569 return self.runtime.allInstances(Sources.SourcesView.EditorAction).then(func tion(editorActions) {
570 for (var i = 0; i < editorActions.length; ++i) { 570 for (var i = 0; i < editorActions.length; ++i) {
571 if (editorActions[i] instanceof WebInspector.ScriptFormatterEditorAc tion) 571 if (editorActions[i] instanceof Sources.ScriptFormatterEditorAction)
572 return editorActions[i]; 572 return editorActions[i];
573 } 573 }
574 return null; 574 return null;
575 }); 575 });
576 }; 576 };
577 577
578 InspectorTest.waitForExecutionContextInTarget = function(target, callback) 578 InspectorTest.waitForExecutionContextInTarget = function(target, callback)
579 { 579 {
580 if (target.runtimeModel.executionContexts().length) { 580 if (target.runtimeModel.executionContexts().length) {
581 callback(target.runtimeModel.executionContexts()[0]); 581 callback(target.runtimeModel.executionContexts()[0]);
582 return; 582 return;
583 } 583 }
584 target.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.Execut ionContextCreated, contextCreated); 584 target.runtimeModel.addEventListener(SDK.RuntimeModel.Events.ExecutionContex tCreated, contextCreated);
585 585
586 function contextCreated() 586 function contextCreated()
587 { 587 {
588 target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events .ExecutionContextCreated, contextCreated); 588 target.runtimeModel.removeEventListener(SDK.RuntimeModel.Events.Executio nContextCreated, contextCreated);
589 callback(target.runtimeModel.executionContexts()[0]); 589 callback(target.runtimeModel.executionContexts()[0]);
590 } 590 }
591 } 591 }
592 592
593 InspectorTest.selectThread = function(target) 593 InspectorTest.selectThread = function(target)
594 { 594 {
595 var threadsPane = self.runtime.sharedInstance(WebInspector.ThreadsSidebarPan e); 595 var threadsPane = self.runtime.sharedInstance(Sources.ThreadsSidebarPane);
596 var listItem = threadsPane._listItemForTarget(target); 596 var listItem = threadsPane._listItemForTarget(target);
597 threadsPane._onListItemClick(listItem); 597 threadsPane._onListItemClick(listItem);
598 } 598 }
599 599
600 InspectorTest.evaluateOnCurrentCallFrame = function(code) 600 InspectorTest.evaluateOnCurrentCallFrame = function(code)
601 { 601 {
602 return new Promise(succ => InspectorTest.debuggerModel.evaluateOnSelectedCal lFrame(code, "console", false, true, false, false, InspectorTest.safeWrap(succ)) ); 602 return new Promise(succ => InspectorTest.debuggerModel.evaluateOnSelectedCal lFrame(code, "console", false, true, false, false, InspectorTest.safeWrap(succ)) );
603 } 603 }
604 604
605 }; 605 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698