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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test-helper.js

Issue 2513423003: DevTools: Convert inspector-unit tests to use reusable test harness (Closed)
Patch Set: address CL feedback 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test-helper.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test-helper.js
similarity index 88%
rename from third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test.js
rename to third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test-helper.js
index bb1ca19ec5297f1f2e8ea5a0e52e668b39523f21..b5a6b88357eacdb998197082a6537d33868da896 100644
--- a/third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test.js
+++ b/third_party/WebKit/LayoutTests/http/tests/inspector-unit/inspector-unit-test-helper.js
@@ -1,7 +1,6 @@
var UnitTest = {};
-(function()
-{
- var lazyModules = [];
+var startTest;
+(function() {
var oldLoadResourcePromise = Runtime.loadResourcePromise;
Runtime.loadResourcePromise = function(url)
{
@@ -12,12 +11,11 @@ var UnitTest = {};
return oldLoadResourcePromise("/inspector-debug/" + url);
var parsedURL = new URL(url, location.href);
- var parsedLocation = new URL(location.href);
// hosted devtools is confused.
parsedURL.pathname = parsedURL.pathname.replace('/inspector-unit/', '/inspector-debug/');
return oldLoadResourcePromise(parsedURL.toString());
- }
+ };
if (window.testRunner) {
testRunner.dumpAsText();
@@ -106,9 +104,8 @@ var UnitTest = {};
});
};
- UnitTest.addDependency = function(lazyModule)
- {
- lazyModules.push(lazyModule);
+ UnitTest.loadLazyModules = function (lazyModules) {
+ return Promise.all(lazyModules.map(lazyModule => window.runtime.loadModulePromise(lazyModule)));
dgozman 2016/11/28 18:44:51 window -> self
chenwilliam 2016/11/29 22:33:33 Done.
};
UnitTest.createKeyEvent = function(key, ctrlKey, altKey, shiftKey, metaKey)
@@ -151,7 +148,17 @@ var UnitTest = {};
var rootView = new UI.RootView();
UI.inspectorView.show(rootView.element);
rootView.attachToDocument(document);
- Promise.all(lazyModules.map(lazyModule => window.runtime.loadModulePromise(lazyModule))).then(test);
+ executeTestScript();
+ }
+
+ function executeTestScript() {
+ fetch(`/inspector-unit/${Runtime.queryParam('test')}`)
+ .then((data) => data.text())
+ .then((testScript) => eval(`(function(){${testScript}})()`))
+ .catch((error) => {
+ UnitTest.addResult(`Unable to execute test script because of error: ${error}`);
+ UnitTest.completeTest();
+ });
}
})();

Powered by Google App Engine
This is Rietveld 408576698