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

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: remove all networkProject.addFile calls 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
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 = async function(url, content, isContentScri pt, worldId) {
dgozman 2017/03/16 00:17:09 I'm worried this whether this forces everyone usin
lushnikov 2017/03/16 06:30:49 Done. The async is actually not needed here.
56 content += '\n//# sourceURL=' + url;
57 if (isContentScript)
58 content = `testRunner.evaluateScriptInIsolatedWorld(${worldId}, \`${cont ent}\`)`;
dgozman 2017/03/16 00:17:09 Nice one!
lushnikov 2017/03/16 06:30:49 Thanks!
59 InspectorTest.evaluateInPagePromise(content)
dgozman 2017/03/16 00:17:09 nit: missing semicolon
lushnikov 2017/03/16 06:30:49 Done.
60 return InspectorTest.waitForUISourceCode(url);
61 }
62
55 InspectorTest.evaluateInPagePromise = function(code) 63 InspectorTest.evaluateInPagePromise = function(code)
56 { 64 {
57 return new Promise(succ => InspectorTest.evaluateInPage(code, succ)); 65 return new Promise(succ => InspectorTest.evaluateInPage(code, succ));
58 } 66 }
59 67
60 InspectorTest.evaluateInPageAsync = function(code) 68 InspectorTest.evaluateInPageAsync = function(code)
61 { 69 {
62 var callback; 70 var callback;
63 var promise = new Promise((fulfill) => { callback = fulfill }); 71 var promise = new Promise((fulfill) => { callback = fulfill });
64 InspectorTest.RuntimeAgent.evaluate(code, 72 InspectorTest.RuntimeAgent.evaluate(code,
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 InspectorTest.waitForUISourceCodeRemoved = function(callback) 452 InspectorTest.waitForUISourceCodeRemoved = function(callback)
445 { 453 {
446 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode Removed, uiSourceCodeRemoved); 454 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode Removed, uiSourceCodeRemoved);
447 function uiSourceCodeRemoved(event) 455 function uiSourceCodeRemoved(event)
448 { 456 {
449 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISou rceCodeRemoved, uiSourceCodeRemoved); 457 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISou rceCodeRemoved, uiSourceCodeRemoved);
450 callback(event.data); 458 callback(event.data);
451 } 459 }
452 } 460 }
453 461
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) 462 InspectorTest.assertGreaterOrEqual = function(a, b, message)
461 { 463 {
462 if (a < b) 464 if (a < b)
463 InspectorTest.addResult("FAILED: " + (message ? message + ": " : "") + a + " < " + b); 465 InspectorTest.addResult("FAILED: " + (message ? message + ": " : "") + a + " < " + b);
464 } 466 }
465 467
466 InspectorTest.navigate = function(url, callback) 468 InspectorTest.navigate = function(url, callback)
467 { 469 {
468 InspectorTest._pageLoadedCallback = InspectorTest.safeWrap(callback); 470 InspectorTest._pageLoadedCallback = InspectorTest.safeWrap(callback);
469 InspectorTest.evaluateInPage("window.location.replace('" + url + "')"); 471 InspectorTest.evaluateInPage("window.location.replace('" + url + "')");
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 _output("[page] " + text); 1239 _output("[page] " + text);
1238 } 1240 }
1239 1241
1240 function _output(result) 1242 function _output(result)
1241 { 1243 {
1242 if (!outputElement) 1244 if (!outputElement)
1243 createOutputElement(); 1245 createOutputElement();
1244 outputElement.appendChild(document.createTextNode(result)); 1246 outputElement.appendChild(document.createTextNode(result));
1245 outputElement.appendChild(document.createElement("br")); 1247 outputElement.appendChild(document.createElement("br"));
1246 } 1248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698