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

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

Issue 2513423003: DevTools: Convert inspector-unit tests to use reusable test harness (Closed)
Patch Set: clean diff Created 4 years 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 var UnitTest = {}; 1 var UnitTest = {};
2 (function() 2 var startTest;
3 { 3 (function() {
4 var lazyModules = []; 4 var lazyModules = [];
5 var oldLoadResourcePromise = Runtime.loadResourcePromise; 5 var oldLoadResourcePromise = Runtime.loadResourcePromise;
6 Runtime.loadResourcePromise = function(url) 6 Runtime.loadResourcePromise = function(url)
7 { 7 {
8 if (url.startsWith("/")) 8 if (url.startsWith("/"))
9 return oldLoadResourcePromise(url); 9 return oldLoadResourcePromise(url);
10 10
11 if (!url.startsWith("http://")) 11 if (!url.startsWith("http://"))
12 return oldLoadResourcePromise("/inspector-debug/" + url); 12 return oldLoadResourcePromise("/inspector-debug/" + url);
13 13
14 var parsedURL = new URL(url, location.href); 14 var parsedURL = new URL(url, location.href);
15 var parsedLocation = new URL(location.href); 15 var parsedLocation = new URL(location.href);
16 16
17 parsedURL.pathname = parsedURL.pathname.replace('/resources/', '/');
17 // hosted devtools is confused. 18 // hosted devtools is confused.
18 parsedURL.pathname = parsedURL.pathname.replace('/inspector-unit/', '/in spector-debug/'); 19 parsedURL.pathname = parsedURL.pathname.replace('/inspector-unit/', '/in spector-debug/');
19 return oldLoadResourcePromise(parsedURL.toString()); 20 return oldLoadResourcePromise(parsedURL.toString());
20 } 21 };
21 22
22 if (window.testRunner) { 23 if (window.testRunner) {
23 testRunner.dumpAsText(); 24 testRunner.dumpAsText();
24 testRunner.waitUntilDone(); 25 testRunner.waitUntilDone();
25 } 26 }
26 27
27 var results = []; 28 var results = [];
28 UnitTest.completeTest = function() 29 UnitTest.completeTest = function()
29 { 30 {
30 if (!window.testRunner) { 31 if (!window.testRunner) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return new KeyboardEvent("keydown", { key: key, bubbles: true, cancelabl e: true, ctrlKey: ctrlKey, altKey: altKey, shiftKey: shiftKey, metaKey: metaKey }); 117 return new KeyboardEvent("keydown", { key: key, bubbles: true, cancelabl e: true, ctrlKey: ctrlKey, altKey: altKey, shiftKey: shiftKey, metaKey: metaKey });
117 }; 118 };
118 119
119 function completeTestOnError(message, source, lineno, colno, error) 120 function completeTestOnError(message, source, lineno, colno, error)
120 { 121 {
121 UnitTest.addResult("TEST ENDED IN ERROR: " + error.stack); 122 UnitTest.addResult("TEST ENDED IN ERROR: " + error.stack);
122 UnitTest.completeTest(); 123 UnitTest.completeTest();
123 } 124 }
124 window.onerror = completeTestOnError; 125 window.onerror = completeTestOnError;
125 126
126 Runtime.startApplication("/inspector-unit/inspector-unit-test").then(runTest ); 127 startTest = function (test) {
128 Runtime.startApplication("/inspector-unit/inspector-unit-test").then(() => runTest(test));
einbinder 2016/11/22 02:19:45 Maybe don't force things to be wrapped in function
chenwilliam 2016/11/22 20:56:05 Done.
129 };
127 130
128 function runTest() 131 function runTest(test)
129 { 132 {
130 var description = document.body.textContent.trim(); 133 var description = document.body.textContent.trim();
131 if (description) 134 if (description)
132 UnitTest.addResult(description); 135 UnitTest.addResult(description);
133 136
134 Common.settings = new Common.Settings(new Common.SettingsStorage( 137 Common.settings = new Common.Settings(new Common.SettingsStorage(
135 {}, 138 {},
136 InspectorFrontendHost.setPreference, 139 InspectorFrontendHost.setPreference,
137 InspectorFrontendHost.removePreference, 140 InspectorFrontendHost.removePreference,
138 InspectorFrontendHost.clearPreferences)); 141 InspectorFrontendHost.clearPreferences));
139 142
140 143
141 UI.viewManager = new UI.ViewManager(); 144 UI.viewManager = new UI.ViewManager();
142 UI.initializeUIUtils(document, Common.settings.createSetting("uiTheme", "default")); 145 UI.initializeUIUtils(document, Common.settings.createSetting("uiTheme", "default"));
143 UI.installComponentRootStyles(document.body); 146 UI.installComponentRootStyles(document.body);
144 147
145 UI.zoomManager = new UI.ZoomManager(window, InspectorFrontendHost); 148 UI.zoomManager = new UI.ZoomManager(window, InspectorFrontendHost);
146 UI.inspectorView = UI.InspectorView.instance(); 149 UI.inspectorView = UI.InspectorView.instance();
147 UI.ContextMenu.initialize(); 150 UI.ContextMenu.initialize();
148 UI.ContextMenu.installHandler(document); 151 UI.ContextMenu.installHandler(document);
149 UI.Tooltip.installHandler(document); 152 UI.Tooltip.installHandler(document);
150 153
151 var rootView = new UI.RootView(); 154 var rootView = new UI.RootView();
152 UI.inspectorView.show(rootView.element); 155 UI.inspectorView.show(rootView.element);
153 rootView.attachToDocument(document); 156 rootView.attachToDocument(document);
154 Promise.all(lazyModules.map(lazyModule => window.runtime.loadModulePromi se(lazyModule))).then(test); 157 Promise.all(lazyModules.map(lazyModule => window.runtime.loadModulePromi se(lazyModule))).then(test);
155 } 158 }
156 })(); 159 })();
157 160
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698