mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Update web-platform-tests to revision 4333a1d2f109795547fc5e22ebfc8481fa649de7
This commit is contained in:
parent
728ebcc932
commit
8c46b67f8e
456 changed files with 10561 additions and 5108 deletions
50
tests/wpt/web-platform-tests/webusb/usb.https.any.js
Normal file
50
tests/wpt/web-platform-tests/webusb/usb.https.any.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
// META: script=/webusb/resources/fake-devices.js
|
||||
// META: script=/webusb/resources/usb-helpers.js
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
let usbDevice, devicesFirstTime, fakeDevice, removedDevice;
|
||||
|
||||
usb_test(() => getFakeDevice()
|
||||
.then(_ => usbDevice = _.device)
|
||||
.then(() => navigator.usb.getDevices())
|
||||
.then(devices => {
|
||||
assert_equals(devices.length, 1);
|
||||
assert_equals(usbDevice, devices[0]);
|
||||
assertDeviceInfoEquals(devices[0], fakeDeviceInit);
|
||||
}), 'getDevices returns devices that are connected');
|
||||
|
||||
usb_test(() => getFakeDevice()
|
||||
.then(() => navigator.usb.getDevices())
|
||||
.then(_ => devicesFirstTime = _)
|
||||
.then(() => assert_equals(devicesFirstTime.length, 1))
|
||||
.then(() => navigator.usb.getDevices())
|
||||
.then(devicesSecondTime => assert_array_equals(devicesSecondTime,
|
||||
devicesFirstTime)),
|
||||
'getDevices returns the same objects for each USB device');
|
||||
|
||||
usb_test(() => getFakeDevice()
|
||||
.then(_ => usbDevice = _.device)
|
||||
.then(() => assertDeviceInfoEquals(usbDevice, fakeDeviceInit))
|
||||
.then(() => usbDevice.open())
|
||||
.then(() => usbDevice.close()),
|
||||
'onconnect event is trigged by adding a device');
|
||||
|
||||
usb_test(() => getFakeDevice()
|
||||
.then(_ => {
|
||||
usbDevice = _.device;
|
||||
fakeDevice = _.fakeDevice;
|
||||
})
|
||||
.then(() => waitForDisconnect(fakeDevice))
|
||||
.then(_ => removedDevice = _)
|
||||
.then(() => {
|
||||
assertDeviceInfoEquals(removedDevice, fakeDeviceInit);
|
||||
assert_equals(removedDevice, usbDevice);
|
||||
})
|
||||
.then(() => removedDevice.open())
|
||||
.then(() =>
|
||||
assert_unreachable('should not be able to open a disconnected device'),
|
||||
error => assert_equals(error.code, DOMException.NOT_FOUND_ERR)),
|
||||
'ondisconnect event is triggered by removing a device');
|
||||
|
||||
done();
|
Loading…
Add table
Add a link
Reference in a new issue