| Index: third_party/WebKit/LayoutTests/usb/idlharness.html
|
| diff --git a/third_party/WebKit/LayoutTests/usb/idlharness.html b/third_party/WebKit/LayoutTests/usb/idlharness.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..af8581a0dad3b8d515c1ff51634e4f9f89468b29
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/usb/idlharness.html
|
| @@ -0,0 +1,251 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| + <head>
|
| + <meta charset=utf-8>
|
| + <title>WebUSB IDL test</title>
|
| + <link rel="help" href="https://wicg.github.io/webusb/">
|
| + <script src="../resources/testharness.js"></script>
|
| + <script src="../resources/testharnessreport.js"></script>
|
| + <script src="../resources/WebIDLParser.js"></script>
|
| + <script src="../resources/idlharness.js"></script>
|
| + <script src="../resources/mojo-helpers.js"></script>
|
| + <script src="resources/fake-devices.js"></script>
|
| + <script src="resources/usb-helpers.js"></script>
|
| + </head>
|
| + <body>
|
| + <script type="text/plain" id="untested">
|
| + interface Event {};
|
| + interface EventHandler {};
|
| + interface EventTarget {};
|
| + interface Navigator {};
|
| + </script>
|
| + <script type="text/plain" id="tested">
|
| + // Copied from https://wicg.github.io/webusb/#idl-index minus the
|
| + // definitions related to Permissions API integration which is unstable.
|
| +
|
| + dictionary USBDeviceFilter {
|
| + unsigned short vendorId;
|
| + unsigned short productId;
|
| + octet classCode;
|
| + octet subclassCode;
|
| + octet protocolCode;
|
| + DOMString serialNumber;
|
| + };
|
| +
|
| + dictionary USBDeviceRequestOptions {
|
| + required sequence<USBDeviceFilter> filters;
|
| + };
|
| +
|
| + interface USB : EventTarget {
|
| + attribute EventHandler onconnect;
|
| + attribute EventHandler ondisconnect;
|
| + Promise<sequence<USBDevice>> getDevices();
|
| + Promise<USBDevice> requestDevice(USBDeviceRequestOptions options);
|
| + };
|
| +
|
| + [SecureContext]
|
| + partial interface Navigator {
|
| + [SameObject] readonly attribute USB usb;
|
| + };
|
| +
|
| + dictionary USBConnectionEventInit : EventInit {
|
| + required USBDevice device;
|
| + };
|
| +
|
| + [Constructor(DOMString type, USBConnectionEventInit eventInitDict)]
|
| + interface USBConnectionEvent : Event {
|
| + [SameObject] readonly attribute USBDevice device;
|
| + };
|
| +
|
| + interface USBDevice {
|
| + readonly attribute octet usbVersionMajor;
|
| + readonly attribute octet usbVersionMinor;
|
| + readonly attribute octet usbVersionSubminor;
|
| + readonly attribute octet deviceClass;
|
| + readonly attribute octet deviceSubclass;
|
| + readonly attribute octet deviceProtocol;
|
| + readonly attribute unsigned short vendorId;
|
| + readonly attribute unsigned short productId;
|
| + readonly attribute octet deviceVersionMajor;
|
| + readonly attribute octet deviceVersionMinor;
|
| + readonly attribute octet deviceVersionSubminor;
|
| + readonly attribute DOMString? manufacturerName;
|
| + readonly attribute DOMString? productName;
|
| + readonly attribute DOMString? serialNumber;
|
| + readonly attribute USBConfiguration? configuration;
|
| + readonly attribute FrozenArray<USBConfiguration> configurations;
|
| + readonly attribute boolean opened;
|
| + Promise<void> open();
|
| + Promise<void> close();
|
| + Promise<void> selectConfiguration(octet configurationValue);
|
| + Promise<void> claimInterface(octet interfaceNumber);
|
| + Promise<void> releaseInterface(octet interfaceNumber);
|
| + Promise<void> selectAlternateInterface(octet interfaceNumber, octet alternateSetting);
|
| + Promise<USBInTransferResult> controlTransferIn(USBControlTransferParameters setup, unsigned short length);
|
| + Promise<USBOutTransferResult> controlTransferOut(USBControlTransferParameters setup, optional BufferSource data);
|
| + Promise<void> clearHalt(USBDirection direction, octet endpointNumber);
|
| + Promise<USBInTransferResult> transferIn(octet endpointNumber, unsigned long length);
|
| + Promise<USBOutTransferResult> transferOut(octet endpointNumber, BufferSource data);
|
| + Promise<USBIsochronousInTransferResult> isochronousTransferIn(octet endpointNumber, sequence<unsigned long> packetLengths);
|
| + Promise<USBIsochronousOutTransferResult> isochronousTransferOut(octet endpointNumber, BufferSource data, sequence<unsigned long> packetLengths);
|
| + Promise<void> reset();
|
| + };
|
| +
|
| + enum USBRequestType {
|
| + "standard",
|
| + "class",
|
| + "vendor"
|
| + };
|
| +
|
| + enum USBRecipient {
|
| + "device",
|
| + "interface",
|
| + "endpoint",
|
| + "other"
|
| + };
|
| +
|
| + enum USBTransferStatus {
|
| + "ok",
|
| + "stall",
|
| + "babble"
|
| + };
|
| +
|
| + dictionary USBControlTransferParameters {
|
| + required USBRequestType requestType;
|
| + required USBRecipient recipient;
|
| + required octet request;
|
| + required unsigned short value;
|
| + required unsigned short index;
|
| + };
|
| +
|
| + [Constructor(USBTransferStatus status, optional DataView? data)]
|
| + interface USBInTransferResult {
|
| + readonly attribute DataView? data;
|
| + readonly attribute USBTransferStatus status;
|
| + };
|
| +
|
| + [Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0)]
|
| + interface USBOutTransferResult {
|
| + readonly attribute unsigned long bytesWritten;
|
| + readonly attribute USBTransferStatus status;
|
| + };
|
| +
|
| + [Constructor(USBTransferStatus status, optional DataView? data)]
|
| + interface USBIsochronousInTransferPacket {
|
| + readonly attribute DataView? data;
|
| + readonly attribute USBTransferStatus status;
|
| + };
|
| +
|
| + [Constructor(sequence<USBIsochronousInTransferPacket> packets, optional DataView? data)]
|
| + interface USBIsochronousInTransferResult {
|
| + readonly attribute DataView? data;
|
| + readonly attribute FrozenArray<USBIsochronousInTransferPacket> packets;
|
| + };
|
| +
|
| + [Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0)]
|
| + interface USBIsochronousOutTransferPacket {
|
| + readonly attribute unsigned long bytesWritten;
|
| + readonly attribute USBTransferStatus status;
|
| + };
|
| +
|
| + [Constructor(sequence<USBIsochronousOutTransferPacket> packets)]
|
| + interface USBIsochronousOutTransferResult {
|
| + readonly attribute FrozenArray<USBIsochronousOutTransferPacket> packets;
|
| + };
|
| +
|
| + [Constructor(USBDevice device, octet configurationValue)]
|
| + interface USBConfiguration {
|
| + readonly attribute octet configurationValue;
|
| + readonly attribute DOMString? configurationName;
|
| + readonly attribute FrozenArray<USBInterface> interfaces;
|
| + };
|
| +
|
| + [Constructor(USBConfiguration configuration, octet interfaceNumber)]
|
| + interface USBInterface {
|
| + readonly attribute octet interfaceNumber;
|
| + readonly attribute USBAlternateInterface alternate;
|
| + readonly attribute FrozenArray<USBAlternateInterface> alternates;
|
| + readonly attribute boolean claimed;
|
| + };
|
| +
|
| + [Constructor(USBInterface deviceInterface, octet alternateSetting)]
|
| + interface USBAlternateInterface {
|
| + readonly attribute octet alternateSetting;
|
| + readonly attribute octet interfaceClass;
|
| + readonly attribute octet interfaceSubclass;
|
| + readonly attribute octet interfaceProtocol;
|
| + readonly attribute DOMString? interfaceName;
|
| + readonly attribute FrozenArray<USBEndpoint> endpoints;
|
| + };
|
| +
|
| + enum USBDirection {
|
| + "in",
|
| + "out"
|
| + };
|
| +
|
| + enum USBEndpointType {
|
| + "bulk",
|
| + "interrupt",
|
| + "isochronous"
|
| + };
|
| +
|
| + [Constructor(USBAlternateInterface alternate, octet endpointNumber, USBDirection direction)]
|
| + interface USBEndpoint {
|
| + readonly attribute octet endpointNumber;
|
| + readonly attribute USBDirection direction;
|
| + readonly attribute USBEndpointType type;
|
| + readonly attribute unsigned long packetSize;
|
| + };
|
| + </script>
|
| + <script>
|
| + 'use strict';
|
| +
|
| + var idl_array = new IdlArray();
|
| + idl_array.add_untested_idls(document.querySelector('#untested').textContent);
|
| + idl_array.add_idls(document.querySelector('#tested').textContent);
|
| + idl_array.add_objects({
|
| + Navigator: ['navigator'],
|
| + USB: ['navigator.usb'],
|
| + USBInTransferResult: ['new USBInTransferResult("ok")'],
|
| + USBOutTransferResult: ['new USBOutTransferResult("ok")'],
|
| + USBIsochronousInTransferResult: ['new USBIsochronousInTransferResult([])'],
|
| + USBIsochronousOutTransferResult: ['new USBIsochronousOutTransferResult([])'],
|
| + USBIsochronousInTransferPacket: ['new USBIsochronousInTransferPacket("ok")'],
|
| + USBIsochronousOutTransferPacket: ['new USBIsochronousOutTransferPacket("ok")']
|
| + });
|
| +
|
| + // These types require a USBDevice instance to construct:
|
| + var usbAlternateInterface;
|
| + var usbConfiguration;
|
| + var usbConnectionEvent;
|
| + var usbDevice;
|
| + var usbEndpoint;
|
| + var usbInterface;
|
| +
|
| + idl_array.add_objects({
|
| + USBAlternateInterface: ['usbAlternateInterface'],
|
| + USBConfiguration: ['usbConfiguration'],
|
| + USBConnectionEvent: ['usbConnectionEvent'],
|
| + USBDevice: ['usbDevice'],
|
| + USBEndpoint: ['usbEndpoint'],
|
| + USBInterface: ['usbInterface']
|
| + });
|
| +
|
| + loadMojoModules('idlharness')
|
| + .then(mojo => usbMocks(mojo))
|
| + .then(usb => {
|
| + usb.mockDeviceManager.addMockDevice(usb.fakeDevices[0]);
|
| + return navigator.usb.getDevices().then(devices => {
|
| + usbDevice = devices[0];
|
| + usbConfiguration = usbDevice.configurations[0];
|
| + usbInterface = usbConfiguration.interfaces[0];
|
| + usbAlternateInterface = usbInterface.alternates[0];
|
| + usbEndpoint = usbAlternateInterface.endpoints[0];
|
| + usbConnectionEvent =
|
| + new USBConnectionEvent('connect', { device: usbDevice });
|
| + });
|
| + })
|
| + .then(() => idl_array.test());
|
| + </script>
|
| + </body>
|
| +</html>
|
|
|