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

Unified Diff: third_party/WebKit/LayoutTests/resources/testharnessreport.js

Issue 2789723003: Migrate WebUSB LayoutTests into external/wpt (Closed)
Patch Set: Rebased Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/resources/testharnessreport.js
diff --git a/third_party/WebKit/LayoutTests/resources/testharnessreport.js b/third_party/WebKit/LayoutTests/resources/testharnessreport.js
index cbcfbe2ef00ba6b126a33e2f9f34f238cd51f102..e387a4190c3877f76a56ab534132eb6a21c2dd5b 100644
--- a/third_party/WebKit/LayoutTests/resources/testharnessreport.js
+++ b/third_party/WebKit/LayoutTests/resources/testharnessreport.js
@@ -78,9 +78,11 @@
function isWPTManualTest() {
var path = location.pathname;
- if (location.hostname == 'web-platform.test' && path.endsWith('-manual.html'))
+ if (location.hostname == 'web-platform.test'
+ && /.*-manual(\.https)?\.html$/.test(path)) {
return true;
- return /\/external\/wpt\/.*-manual\.html$/.test(path);
+ }
+ return /\/external\/wpt\/.*-manual(\.https)?\.html$/.test(path);
}
// Returns a directory part relative to WPT root and a basename part of the
@@ -113,8 +115,10 @@
}
var src;
- if (pathAndBase.startsWith('/fullscreen/')) {
- // Fullscreen tests all use the same automation script.
+ if (pathAndBase.startsWith('/fullscreen/')
+ || pathAndBase.startsWith('/webusb/')) {
+ // Fullscreen tests all use the same automation script and WebUSB
+ // tests borrow it.
src = automationPath + '/fullscreen/auto-click.js';
} else if (pathAndBase.startsWith('/pointerevents/')
|| pathAndBase.startsWith('/uievents/')) {
@@ -128,6 +132,40 @@
document.head.appendChild(script);
}
+ function importTestPolyfills() {
+ var pathAndBase = pathAndBaseNameInWPT();
+ if (!pathAndBase)
+ return;
+ var automationPath = location.pathname.replace(/\/external\/wpt\/.*$/, '/external/wpt_polyfill');
+ if (location.hostname == 'web-platform.test')
+ polyfillPath = '/wpt_polyfill';
+
+ var script = document.createElement('script');
+ if (pathAndBase.startsWith('/webusb/')) {
+ // WebUSB tests require a polyfill for navigator.usb.test. This
+ // script will be loaded asynchronously so we need to patch in
+ // a version of navigator.usb.test.initialize() that will wait for
+ // the script to load.
+ script.src = polyfillPath + '/webusb/webusb-test.js';
+ let initializePromise = null;
+ navigator.usb.test = {
+ initialize: function() {
+ if (!initializePromise) {
+ initializePromise = new Promise(resolve => {
+ script.onload = () => {
+ resolve(navigator.usb.test.initialize());
+ }
+ });
+ }
+ return initializePromise;
+ }
+ };
+ } else {
+ return;
+ }
+ document.head.appendChild(script);
+ }
+
var didDispatchLoadEvent = false;
window.addEventListener('load', function() {
didDispatchLoadEvent = true;
@@ -266,4 +304,5 @@
}
});
+ importTestPolyfills();
})();

Powered by Google App Engine
This is Rietveld 408576698