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

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

Issue 2789723003: Migrate WebUSB LayoutTests into external/wpt (Closed)
Patch Set: 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 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..d247c158f7cd376de0638bc0a48d12f6b164de07 100644
--- a/third_party/WebKit/LayoutTests/resources/testharnessreport.js
+++ b/third_party/WebKit/LayoutTests/resources/testharnessreport.js
@@ -128,6 +128,40 @@
document.head.appendChild(script);
}
+ function importTestPolyfils() {
+ var pathAndBase = pathAndBaseNameInWPT();
+ if (!pathAndBase)
+ return;
+ var automationPath = location.pathname.replace(/\/external\/wpt\/.*$/, '/external/wpt_automation');
ortuno 2017/04/03 01:47:19 wpt_automation has a very specific purpose: Turn m
Reilly Grant (use Gerrit) 2017/04/05 18:39:37 Created a new wpt_polyfill directory for these.
+ if (location.hostname == 'web-platform.test')
+ automationPath = '/wpt_automation';
+
+ var script = document.createElement('script');
+ if (pathAndBase.startsWith('/webusb/')) {
+ // WebUSB tests require a polyfil 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 = automationPath + '/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 +300,5 @@
}
});
+ importTestPolyfils();
})();

Powered by Google App Engine
This is Rietveld 408576698