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(); |
})(); |