Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/external/wpt/webusb/resources/usb-helpers.js |
| diff --git a/third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js b/third_party/WebKit/LayoutTests/external/wpt/webusb/resources/usb-helpers.js |
| similarity index 64% |
| rename from third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js |
| rename to third_party/WebKit/LayoutTests/external/wpt/webusb/resources/usb-helpers.js |
| index 35ba6eaff40dd61e22d74146a0f8cb84401f2c63..5b8a9e90e6ce79e16823e56af0afe88bd575f81f 100644 |
| --- a/third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js |
| +++ b/third_party/WebKit/LayoutTests/external/wpt/webusb/resources/usb-helpers.js |
| @@ -1,8 +1,39 @@ |
| 'use strict'; |
| +// To enable these tests Chrome must be run with these options: |
| +// |
| +// --enable-blink-features=MojoJS,MojoJSTest |
| +let loadChromiumResources = Promise.resolve().then(() => { |
|
ortuno
2017/06/21 00:43:50
Sad that we have to include Chrome-specific code i
foolip
2017/06/21 08:23:29
Could this be made part of wpt_automation instead?
Reilly Grant (use Gerrit)
2017/06/21 21:35:16
One of the goals of this patch is to make these te
foolip
2017/06/22 22:30:38
Hmm, I didn't notice that /resources/chromium/*.js
foolip
2017/06/22 22:52:18
Discussed in https://codereview.chromium.org/27897
|
| + if (!MojoInterfaceInterceptor) { |
| + // Do nothing on non-Chromium-based browsers or when the Mojo bindings are |
| + // not present in the global namespace. |
| + return; |
| + } |
| + |
| + let chain = Promise.resolve(); |
| + [ |
| + '/resources/chromium/mojo_bindings.js', |
| + '/resources/chromium/device.mojom.js', |
| + '/resources/chromium/device_manager.mojom.js', |
| + '/resources/chromium/chooser_service.mojom.js', |
| + '/resources/chromium/webusb-test.js', |
| + ].forEach(path => { |
| + let script = document.createElement('script'); |
| + script.src = path; |
| + script.async = false; |
| + chain = chain.then(() => new Promise(resolve => { |
| + script.onload = () => resolve(); |
| + })); |
| + document.head.appendChild(script); |
| + }); |
| + |
| + return chain; |
| +}); |
| + |
| function usb_test(func, name, properties) { |
| promise_test(async () => { |
| - await navigator.usb.test.initialize() |
| + await loadChromiumResources; |
| + await navigator.usb.test.initialize(); |
| try { |
| await func(); |
| } finally { |
| @@ -72,24 +103,17 @@ function assertDeviceInfoEquals(usbDevice, deviceInit) { |
| } |
| } |
| -// TODO(reillyg): Remove when jyasskin upstreams this to testharness.js: |
| -// https://crbug.com/509058. |
| -function callWithKeyDown(functionCalledOnKeyPress) { |
| +function callWithTrustedClick(callback) { |
| return new Promise(resolve => { |
| - function onKeyPress() { |
| - document.removeEventListener('keypress', onKeyPress, false); |
| - resolve(functionCalledOnKeyPress()); |
| - } |
| - document.addEventListener('keypress', onKeyPress, false); |
| - |
| - eventSender.keyDown(' ', []); |
| - }); |
| -} |
| - |
| -function runGarbageCollection() { |
| - // Run gc() as a promise. |
| - return new Promise((resolve, reject) => { |
| - GCController.collect(); |
| - setTimeout(resolve, 0); |
| + let button = document.createElement('button'); |
| + button.textContent = 'click to continue test'; |
| + button.style.display = 'block'; |
| + button.style.fontSize = '20px'; |
| + button.style.padding = '10px'; |
| + button.onclick = () => { |
| + resolve(callback()); |
| + document.body.removeChild(button); |
| + }; |
| + document.body.appendChild(button); |
| }); |
| } |