Bug 1462454 [wpt PR 11050] - Create WebUSB idlharness test for workers, a=testonly

Automatic update from web-platform-testsCreate WebUSB idlharness test for workers

This change creates an idlharness test for the workers to ensure that
all the interfaces are exposed in the worker. This change also updates
the webusb.idl file to match the exposure of the interfaces.

Bug: 841510
Change-Id: Iad72f242ee0cdbf9a3057828bd4bd5542f6fe063
Reviewed-on: https://chromium-review.googlesource.com/1053063
Commit-Queue: Ovidio Henriquez <odejesush@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Chong Zhang <chongz@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Hitoshi Yoshida <peria@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560399}

--

wpt-commits: 76c0092916ee8a9171396e62c472d85a0f2623fb
wpt-pr: 11050
This commit is contained in:
Ovidio Henriquez 2018-05-23 17:16:00 +00:00 committed by moz-wptsync-bot
parent 0686b1b4d0
commit 744035d1c7
6 changed files with 168 additions and 15 deletions

View File

@ -299835,6 +299835,11 @@
{} {}
] ]
], ],
"webusb/resources/idlharness.dedicatedworker.sharedworker.js": [
[
{}
]
],
"webusb/resources/open-in-iframe.html": [ "webusb/resources/open-in-iframe.html": [
[ [
{} {}
@ -376909,6 +376914,18 @@
{} {}
] ]
], ],
"webusb/worker/idlharness.dedicatedworker.https.html": [
[
"/webusb/worker/idlharness.dedicatedworker.https.html",
{}
]
],
"webusb/worker/idlharness.sharedworker.https.html": [
[
"/webusb/worker/idlharness.sharedworker.https.html",
{}
]
],
"webusb/worker/usb.dedicatedworker.https.html": [ "webusb/worker/usb.dedicatedworker.https.html": [
[ [
"/webusb/worker/usb.dedicatedworker.https.html", "/webusb/worker/usb.dedicatedworker.https.html",
@ -583919,7 +583936,7 @@
"support" "support"
], ],
"interfaces/webusb.idl": [ "interfaces/webusb.idl": [
"7b5749e1fece69552e0a8bfac7af401fac15394d", "e609a866d40f70f59f682a1a5ec82cf713863969",
"support" "support"
], ],
"interfaces/webvtt.idl": [ "interfaces/webvtt.idl": [
@ -617463,13 +617480,17 @@
"support" "support"
], ],
"webusb/idlharness.https.html": [ "webusb/idlharness.https.html": [
"135ae431cdac90d34b85fe1ea355abaf9a9fb732", "5a97c893eb0e23e3cba14501de9955cfbb0b385a",
"testharness" "testharness"
], ],
"webusb/resources/fake-devices.js": [ "webusb/resources/fake-devices.js": [
"2cfce7b35b9441529946c4bcea9427e261808c36", "2cfce7b35b9441529946c4bcea9427e261808c36",
"support" "support"
], ],
"webusb/resources/idlharness.dedicatedworker.sharedworker.js": [
"2a847fbeded0fe0b895cb5675f90b685f749f40a",
"support"
],
"webusb/resources/open-in-iframe.html": [ "webusb/resources/open-in-iframe.html": [
"6e6050f742e0da58fc94a5c0a0aa75f16dfcede9", "6e6050f742e0da58fc94a5c0a0aa75f16dfcede9",
"support" "support"
@ -617554,6 +617575,14 @@
"f08a98a927d57cda8b780a8304a0fa6cf727cc81", "f08a98a927d57cda8b780a8304a0fa6cf727cc81",
"testharness" "testharness"
], ],
"webusb/worker/idlharness.dedicatedworker.https.html": [
"159ede02aac087e0409632c2fcbac3a597ec4c45",
"testharness"
],
"webusb/worker/idlharness.sharedworker.https.html": [
"4dc8b85f2590397f6e8bcbf63dc64381b1f95559",
"testharness"
],
"webusb/worker/usb.dedicatedworker.https.html": [ "webusb/worker/usb.dedicatedworker.https.html": [
"556e26de5f184609e0e49f02795f96aef524a7c2", "556e26de5f184609e0e49f02795f96aef524a7c2",
"testharness" "testharness"

View File

@ -14,27 +14,37 @@ dictionary USBDeviceRequestOptions {
required sequence<USBDeviceFilter> filters; required sequence<USBDeviceFilter> filters;
}; };
[Exposed=(DedicatedWorker, SharedWorker, Window), SecureContext]
interface USB : EventTarget { interface USB : EventTarget {
attribute EventHandler onconnect; attribute EventHandler onconnect;
attribute EventHandler ondisconnect; attribute EventHandler ondisconnect;
Promise<sequence<USBDevice>> getDevices(); Promise<sequence<USBDevice>> getDevices();
Promise<USBDevice> requestDevice(USBDeviceRequestOptions options); [Exposed=Window] Promise<USBDevice> requestDevice(USBDeviceRequestOptions options);
}; };
[SecureContext] [Exposed=Window, SecureContext]
partial interface Navigator { partial interface Navigator {
[SameObject] readonly attribute USB usb; [SameObject] readonly attribute USB usb;
}; };
[Exposed=(DedicatedWorker, SharedWorker), SecureContext]
partial interface WorkerNavigator {
[SameObject] readonly attribute USB usb;
};
dictionary USBConnectionEventInit : EventInit { dictionary USBConnectionEventInit : EventInit {
required USBDevice device; required USBDevice device;
}; };
[Constructor(DOMString type, USBConnectionEventInit eventInitDict)] [
Constructor(DOMString type, USBConnectionEventInit eventInitDict),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBConnectionEvent : Event { interface USBConnectionEvent : Event {
[SameObject] readonly attribute USBDevice device; [SameObject] readonly attribute USBDevice device;
}; };
[Exposed=(DedicatedWorker, SharedWorker, Window)]
interface USBDevice { interface USBDevice {
readonly attribute octet usbVersionMajor; readonly attribute octet usbVersionMajor;
readonly attribute octet usbVersionMinor; readonly attribute octet usbVersionMinor;
@ -96,49 +106,73 @@ dictionary USBControlTransferParameters {
required unsigned short index; required unsigned short index;
}; };
[Constructor(USBTransferStatus status, optional DataView? data)] [
Constructor(USBTransferStatus status, optional DataView? data),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBInTransferResult { interface USBInTransferResult {
readonly attribute DataView? data; readonly attribute DataView? data;
readonly attribute USBTransferStatus status; readonly attribute USBTransferStatus status;
}; };
[Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0)] [
Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBOutTransferResult { interface USBOutTransferResult {
readonly attribute unsigned long bytesWritten; readonly attribute unsigned long bytesWritten;
readonly attribute USBTransferStatus status; readonly attribute USBTransferStatus status;
}; };
[Constructor(USBTransferStatus status, optional DataView? data)] [
Constructor(USBTransferStatus status, optional DataView? data),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBIsochronousInTransferPacket { interface USBIsochronousInTransferPacket {
readonly attribute DataView? data; readonly attribute DataView? data;
readonly attribute USBTransferStatus status; readonly attribute USBTransferStatus status;
}; };
[Constructor(sequence<USBIsochronousInTransferPacket> packets, optional DataView? data)] [
Constructor(sequence<USBIsochronousInTransferPacket> packets, optional DataView? data),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBIsochronousInTransferResult { interface USBIsochronousInTransferResult {
readonly attribute DataView? data; readonly attribute DataView? data;
readonly attribute FrozenArray<USBIsochronousInTransferPacket> packets; readonly attribute FrozenArray<USBIsochronousInTransferPacket> packets;
}; };
[Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0)] [
Constructor(USBTransferStatus status, optional unsigned long bytesWritten = 0),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBIsochronousOutTransferPacket { interface USBIsochronousOutTransferPacket {
readonly attribute unsigned long bytesWritten; readonly attribute unsigned long bytesWritten;
readonly attribute USBTransferStatus status; readonly attribute USBTransferStatus status;
}; };
[Constructor(sequence<USBIsochronousOutTransferPacket> packets)] [
Constructor(sequence<USBIsochronousOutTransferPacket> packets),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBIsochronousOutTransferResult { interface USBIsochronousOutTransferResult {
readonly attribute FrozenArray<USBIsochronousOutTransferPacket> packets; readonly attribute FrozenArray<USBIsochronousOutTransferPacket> packets;
}; };
[Constructor(USBDevice device, octet configurationValue)] [
Constructor(USBDevice device, octet configurationValue),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBConfiguration { interface USBConfiguration {
readonly attribute octet configurationValue; readonly attribute octet configurationValue;
readonly attribute DOMString? configurationName; readonly attribute DOMString? configurationName;
readonly attribute FrozenArray<USBInterface> interfaces; readonly attribute FrozenArray<USBInterface> interfaces;
}; };
[Constructor(USBConfiguration configuration, octet interfaceNumber)] [
Constructor(USBConfiguration configuration, octet interfaceNumber),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBInterface { interface USBInterface {
readonly attribute octet interfaceNumber; readonly attribute octet interfaceNumber;
readonly attribute USBAlternateInterface alternate; readonly attribute USBAlternateInterface alternate;
@ -146,7 +180,10 @@ interface USBInterface {
readonly attribute boolean claimed; readonly attribute boolean claimed;
}; };
[Constructor(USBInterface deviceInterface, octet alternateSetting)] [
Constructor(USBInterface deviceInterface, octet alternateSetting),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBAlternateInterface { interface USBAlternateInterface {
readonly attribute octet alternateSetting; readonly attribute octet alternateSetting;
readonly attribute octet interfaceClass; readonly attribute octet interfaceClass;
@ -167,7 +204,10 @@ enum USBEndpointType {
"isochronous" "isochronous"
}; };
[Constructor(USBAlternateInterface alternate, octet endpointNumber, USBDirection direction)] [
Constructor(USBAlternateInterface alternate, octet endpointNumber, USBDirection direction),
Exposed=(DedicatedWorker, SharedWorker, Window)
]
interface USBEndpoint { interface USBEndpoint {
readonly attribute octet endpointNumber; readonly attribute octet endpointNumber;
readonly attribute USBDirection direction; readonly attribute USBDirection direction;

View File

@ -35,6 +35,7 @@
idl_array.add_untested_idls('dictionary EventInit {};'); idl_array.add_untested_idls('dictionary EventInit {};');
idl_array.add_untested_idls('interface EventTarget {};'); idl_array.add_untested_idls('interface EventTarget {};');
idl_array.add_untested_idls('interface Navigator {};'); idl_array.add_untested_idls('interface Navigator {};');
idl_array.add_untested_idls('interface WorkerNavigator {};');
let {device} = await getFakeDevice(); let {device} = await getFakeDevice();

View File

@ -0,0 +1,61 @@
'use strict';
importScripts('/resources/testharness.js');
importScripts('/resources/WebIDLParser.js');
importScripts('/resources/idlharness.js');
importScripts('/webusb/resources/fake-devices.js');
importScripts('/webusb/resources/usb-helpers.js');
// Object instances used by the IDL test.
var usbDevice;
var usbConfiguration;
var usbInterface;
var usbAlternateInterface;
var usbEndpoint;
var usbConnectionEvent;
usb_test(async () => {
let webUSBResponse = await fetch('/interfaces/webusb.idl');
let domResponse = await fetch('/interfaces/dom.idl');
let webusb_idl_text = await webUSBResponse.text();
let dom_idl_text = await domResponse.text();
let idl_array = new IdlArray();
idl_array.add_idls(webusb_idl_text);
// Untested IDL interfaces
idl_array.add_untested_idls(dom_idl_text, { only: ['Event', 'EventTarget'] });
idl_array.add_untested_idls('interface EventHandler {};');
idl_array.add_untested_idls('dictionary EventInit {};');
idl_array.add_untested_idls('interface Navigator {};');
idl_array.add_untested_idls('interface WorkerNavigator {};');
let {device} = await getFakeDevice();
usbDevice = 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({
WorkerNavigator: ['navigator'],
USB: ['navigator.usb'],
USBAlternateInterface: ['usbAlternateInterface'],
USBConfiguration: ['usbConfiguration'],
USBConnectionEvent: ['usbConnectionEvent'],
USBDevice: ['usbDevice'],
USBEndpoint: ['usbEndpoint'],
USBInterface: ['usbInterface'],
USBInTransferResult: ['new USBInTransferResult("ok")'],
USBOutTransferResult: ['new USBOutTransferResult("ok")'],
USBIsochronousInTransferResult: ['new USBIsochronousInTransferResult([])'],
USBIsochronousOutTransferResult: ['new USBIsochronousOutTransferResult([])'],
USBIsochronousInTransferPacket: ['new USBIsochronousInTransferPacket("ok")'],
USBIsochronousOutTransferPacket: ['new USBIsochronousOutTransferPacket("ok")'],
});
idl_array.test();
}, 'WebUSB on Workers IDL test');
done();

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
'use strict';
fetch_tests_from_worker(new Worker(
'/webusb/resources/idlharness.dedicatedworker.sharedworker.js'));
</script>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
'use strict';
fetch_tests_from_worker(new SharedWorker(
'/webusb/resources/idlharness.dedicatedworker.sharedworker.js'));
</script>