Index: third_party/WebKit/LayoutTests/external/wpt/webusb/idlharness.https.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/webusb/idlharness.https.html b/third_party/WebKit/LayoutTests/external/wpt/webusb/idlharness.https.html |
index b4c79c3865699b22f3e49e5abc66999d9109c932..17612777fc632af4247b8463e3ad02aa6426688e 100644 |
--- a/third_party/WebKit/LayoutTests/external/wpt/webusb/idlharness.https.html |
+++ b/third_party/WebKit/LayoutTests/external/wpt/webusb/idlharness.https.html |
@@ -8,14 +8,24 @@ |
<script src=/resources/testharnessreport.js></script> |
<script src=/resources/WebIDLParser.js></script> |
<script src=/resources/idlharness.js></script> |
+ <script src=resources/fake-devices.js></script> |
+ <script src=resources/usb-helpers.js></script> |
</head> |
<body> |
<script> |
'use strict'; |
+ // Object instances used by the IDL test. |
+ var usbDevice; |
+ var usbConfiguration; |
+ var usbInterface; |
+ var usbAlternateInterface; |
+ var usbEndpoint; |
+ var usbConnectionEvent; |
+ |
promise_test(async () => { |
let response = await fetch('/interfaces/webusb.idl'); |
- let idl_text = response.text(); |
+ let idl_text = await response.text(); |
let idl_array = new IdlArray(); |
idl_array.add_idls(idl_text); |
@@ -37,6 +47,34 @@ |
USBIsochronousOutTransferPacket: ['new USBIsochronousOutTransferPacket("ok")'], |
}); |
+ // If the WebUSB Test API is available then interfaces requiring an |
+ // instance of USBDevice can be tested. |
+ try { |
+ await navigator.usb.test.initialize(); |
+ navigator.usb.test.addFakeDevice(fakeDeviceInit); |
+ usbDevice = await new Promise(resolve => { |
+ navigator.usb.onconnect = e => resolve(e.device); |
+ }); |
+ |
+ usbConfiguration = usbDevice.configurations[0]; |
+ usbInterface = usbConfiguration.interfaces[0]; |
+ usbAlternateInterface = usbInterface.alternates[0]; |
+ usbEndpoint = usbAlternateInterface.endpoints[0]; |
+ usbConnectionEvent = |
+ new USBConnectionEvent('connect', { device: usbDevice }) |
+ |
+ idl_array.add_objects({ |
+ USBAlternateInterface: ['usbAlternateInterface'], |
+ USBConfiguration: ['usbConfiguration'], |
+ USBConnectionEvent: ['usbConnectionEvent'], |
+ USBDevice: ['usbDevice'], |
+ USBEndpoint: ['usbEndpoint'], |
+ USBInterface: ['usbInterface'] |
+ }); |
+ } catch (e) { |
+ // Do nothing. |
+ } |
+ |
idl_array.test(); |
}, 'WebUSB IDL test'); |
</script> |