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

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

Issue 2747863007: DevTools: clean up tests to not depend on NetworkProject.addFile method (Closed)
Patch Set: typo Created 3 years, 9 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 | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/page-mock.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 if (window.GCController) 1 if (window.GCController)
2 GCController.collectAll(); 2 GCController.collectAll();
3 3
4 var initialize_InspectorTest = function() { 4 var initialize_InspectorTest = function() {
5 Protocol.InspectorBackend.Options.suppressRequestErrors = true; 5 Protocol.InspectorBackend.Options.suppressRequestErrors = true;
6 var results = []; 6 var results = [];
7 7
8 function consoleOutputHook(messageType) 8 function consoleOutputHook(messageType)
9 { 9 {
10 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu ments, 1)); 10 InspectorTest.addResult(messageType + ": " + Array.prototype.slice.call(argu ments, 1));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 callback = InspectorTest.safeWrap(callback); 45 callback = InspectorTest.safeWrap(callback);
46 46
47 function mycallback(error, result, exceptionDetails) 47 function mycallback(error, result, exceptionDetails)
48 { 48 {
49 if (!error) 49 if (!error)
50 callback(InspectorTest.runtimeModel.createRemoteObject(result), exce ptionDetails); 50 callback(InspectorTest.runtimeModel.createRemoteObject(result), exce ptionDetails);
51 } 51 }
52 InspectorTest.RuntimeAgent.evaluate(code, "console", false, mycallback); 52 InspectorTest.RuntimeAgent.evaluate(code, "console", false, mycallback);
53 } 53 }
54 54
55 InspectorTest.addScriptUISourceCode = function(url, content, isContentScript, wo rldId) {
56 content += '\n//# sourceURL=' + url;
57 if (isContentScript)
58 content = `testRunner.evaluateScriptInIsolatedWorld(${worldId}, \`${cont ent}\`)`;
59 InspectorTest.evaluateInPagePromise(content);
60 return InspectorTest.waitForUISourceCode(url);
61 }
62
63 InspectorTest.addScriptForFrame = function(url, content, frame) {
64 content += '\n//# sourceURL=' + url;
65 var executionContext = InspectorTest.runtimeModel.executionContexts().find(c ontext => context.frameId === frame.id);
66 InspectorTest.RuntimeAgent.evaluate(content, "console", false, false, execut ionContext.id, function() { });
67 }
68
55 InspectorTest.evaluateInPagePromise = function(code) 69 InspectorTest.evaluateInPagePromise = function(code)
56 { 70 {
57 return new Promise(succ => InspectorTest.evaluateInPage(code, succ)); 71 return new Promise(succ => InspectorTest.evaluateInPage(code, succ));
58 } 72 }
59 73
60 InspectorTest.evaluateInPageAsync = function(code) 74 InspectorTest.evaluateInPageAsync = function(code)
61 { 75 {
62 var callback; 76 var callback;
63 var promise = new Promise((fulfill) => { callback = fulfill }); 77 var promise = new Promise((fulfill) => { callback = fulfill });
64 InspectorTest.RuntimeAgent.evaluate(code, 78 InspectorTest.RuntimeAgent.evaluate(code,
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 InspectorTest.waitForUISourceCodeRemoved = function(callback) 458 InspectorTest.waitForUISourceCodeRemoved = function(callback)
445 { 459 {
446 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode Removed, uiSourceCodeRemoved); 460 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode Removed, uiSourceCodeRemoved);
447 function uiSourceCodeRemoved(event) 461 function uiSourceCodeRemoved(event)
448 { 462 {
449 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISou rceCodeRemoved, uiSourceCodeRemoved); 463 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISou rceCodeRemoved, uiSourceCodeRemoved);
450 callback(event.data); 464 callback(event.data);
451 } 465 }
452 } 466 }
453 467
454 InspectorTest._mockTargetId = 1;
455 InspectorTest.createMockTarget = function(name, capabilities, dontAttachToMain)
456 {
457 return SDK.targetManager.createTarget('mock-target-' + InspectorTest._mockTa rgetId++, name, capabilities || SDK.Target.Capability.AllForTests, params => new SDK.StubConnection(params), dontAttachToMain ? null : InspectorTest.mainTarget) ;
458 }
459
460 InspectorTest.assertGreaterOrEqual = function(a, b, message) 468 InspectorTest.assertGreaterOrEqual = function(a, b, message)
461 { 469 {
462 if (a < b) 470 if (a < b)
463 InspectorTest.addResult("FAILED: " + (message ? message + ": " : "") + a + " < " + b); 471 InspectorTest.addResult("FAILED: " + (message ? message + ": " : "") + a + " < " + b);
464 } 472 }
465 473
466 InspectorTest.navigate = function(url, callback) 474 InspectorTest.navigate = function(url, callback)
467 { 475 {
468 InspectorTest._pageLoadedCallback = InspectorTest.safeWrap(callback); 476 InspectorTest._pageLoadedCallback = InspectorTest.safeWrap(callback);
469 InspectorTest.evaluateInPage("window.location.replace('" + url + "')"); 477 InspectorTest.evaluateInPage("window.location.replace('" + url + "')");
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 _output("[page] " + text); 1245 _output("[page] " + text);
1238 } 1246 }
1239 1247
1240 function _output(result) 1248 function _output(result)
1241 { 1249 {
1242 if (!outputElement) 1250 if (!outputElement)
1243 createOutputElement(); 1251 createOutputElement();
1244 outputElement.appendChild(document.createTextNode(result)); 1252 outputElement.appendChild(document.createTextNode(result));
1245 outputElement.appendChild(document.createElement("br")); 1253 outputElement.appendChild(document.createElement("br"));
1246 } 1254 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/inspector/page-mock.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698