mirror of
https://github.com/servo/servo.git
synced 2025-08-26 23:58:20 +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
|
@ -1,9 +1,9 @@
|
|||
// META: script=/resources/WebIDLParser.js
|
||||
// META: script=/resources/idlharness.js
|
||||
// META: script=/webusb/resources/fake-devices.js
|
||||
// META: script=/webusb/resources/usb-helpers.js
|
||||
// META: global=sharedworker
|
||||
'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;
|
||||
|
@ -37,8 +37,13 @@ usb_test(async () => {
|
|||
usbConnectionEvent =
|
||||
new USBConnectionEvent('connect', { device: usbDevice })
|
||||
|
||||
if (self.GLOBAL.isWindow()) {
|
||||
idl_array.add_objects({ Navigator: ['navigator'] });
|
||||
} else if (self.GLOBAL.isWorker()) {
|
||||
idl_array.add_objects({ WorkerNavigator: ['navigator'] });
|
||||
}
|
||||
|
||||
idl_array.add_objects({
|
||||
WorkerNavigator: ['navigator'],
|
||||
USB: ['navigator.usb'],
|
||||
USBAlternateInterface: ['usbAlternateInterface'],
|
||||
USBConfiguration: ['usbConfiguration'],
|
||||
|
@ -55,6 +60,6 @@ usb_test(async () => {
|
|||
});
|
||||
|
||||
idl_array.test();
|
||||
}, 'WebUSB on Workers IDL test');
|
||||
}, 'WebUSB IDL test');
|
||||
|
||||
done();
|
|
@ -1,71 +0,0 @@
|
|||
<!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/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;
|
||||
|
||||
usb_test(async () => {
|
||||
const idl = await fetch('/interfaces/webusb.idl').then(r => r.text());
|
||||
const html = await fetch('/interfaces/html.idl').then(r => r.text());
|
||||
const dom = await fetch('/interfaces/dom.idl').then(r => r.text());
|
||||
|
||||
const idl_array = new IdlArray();
|
||||
idl_array.add_idls(idl);
|
||||
idl_array.add_dependency_idls(html);
|
||||
idl_array.add_dependency_idls(dom);
|
||||
|
||||
// Untested IDL interfaces
|
||||
idl_array.add_untested_idls('dictionary PermissionDescriptor {};');
|
||||
idl_array.add_untested_idls('interface PermissionStatus {};');
|
||||
|
||||
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({
|
||||
Navigator: ['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 IDL test');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,19 +1,10 @@
|
|||
// META: script=/webusb/resources/fake-devices.js
|
||||
// META: script=/webusb/resources/usb-helpers.js
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
importScripts('/resources/testharness.js');
|
||||
importScripts('/webusb/resources/fake-devices.js');
|
||||
importScripts('/webusb/resources/usb-helpers.js');
|
||||
|
||||
let usbDevice, devicesFirstTime, fakeDevice, removedDevice;
|
||||
|
||||
test(() => {
|
||||
assert_true(navigator.usb instanceof USB,
|
||||
'navigator.usb should be defined as a USB object');
|
||||
assert_true(navigator.usb.getDevices instanceof Function,
|
||||
'navigator.usb.getDevices should be defined as a function');
|
||||
assert_equals(typeof navigator.usb.requestDevice, 'undefined',
|
||||
'navigator.usb.requestDevice should not be defined');
|
||||
}, 'Web workers should have the WebUSB API exposed as defined in the spec.');
|
||||
|
||||
usb_test(() => getFakeDevice()
|
||||
.then(_ => usbDevice = _.device)
|
||||
.then(() => navigator.usb.getDevices())
|
|
@ -1,34 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="resources/fake-devices.js"></script>
|
||||
<script src="resources/usb-helpers.js"></script>
|
||||
<script>
|
||||
// META: script=/resources/testdriver.js
|
||||
// META: script=/resources/testdriver-vendor.js
|
||||
// META: script=/webusb/resources/fake-devices.js
|
||||
// META: script=/webusb/resources/usb-helpers.js
|
||||
'use strict';
|
||||
|
||||
usb_test(() => {
|
||||
return getFakeDevice().then(({ device }) => {
|
||||
return navigator.usb.getDevices().then(devices => {
|
||||
assert_equals(devices.length, 1);
|
||||
assert_equals(device, devices[0]);
|
||||
assertDeviceInfoEquals(devices[0], fakeDeviceInit);
|
||||
});
|
||||
});
|
||||
}, 'getDevices returns devices that are connected');
|
||||
|
||||
usb_test(() => {
|
||||
return getFakeDevice().then(() => {
|
||||
return navigator.usb.getDevices().then(devicesFirstTime => {
|
||||
assert_equals(devicesFirstTime.length, 1);
|
||||
return navigator.usb.getDevices().then(devicesSecondTime => {
|
||||
assert_array_equals(devicesSecondTime, devicesFirstTime);
|
||||
});
|
||||
});
|
||||
});
|
||||
}, 'getDevices returns the same objects for each USB device');
|
||||
|
||||
usb_test(() => {
|
||||
return navigator.usb.requestDevice({ filters: [] })
|
||||
.then(device => {
|
||||
|
@ -55,7 +30,7 @@ usb_test(() => {
|
|||
navigator.usb.test.onrequestdevice = event => {
|
||||
navigator.usb.test.onrequestdevice = undefined;
|
||||
event.respondWith(fakeDevice);
|
||||
}
|
||||
};
|
||||
return callWithTrustedClick(() => {
|
||||
return navigator.usb.requestDevice({ filters: [] }).then(chosenDevice => {
|
||||
assert_equals(chosenDevice, device);
|
||||
|
@ -69,7 +44,7 @@ usb_test(() => {
|
|||
navigator.usb.test.onrequestdevice = event => {
|
||||
navigator.usb.test.onrequestdevice = undefined;
|
||||
event.respondWith(fakeDevice);
|
||||
}
|
||||
};
|
||||
return callWithTrustedClick(() => {
|
||||
return navigator.usb.requestDevice({ filters: [] }).then(chosenDevice => {
|
||||
assert_equals(chosenDevice, device);
|
||||
|
@ -97,7 +72,7 @@ usb_test(() => {
|
|||
}
|
||||
|
||||
event.respondWith(null);
|
||||
}
|
||||
};
|
||||
|
||||
return callWithTrustedClick(() => {
|
||||
return navigator.usb.requestDevice({ filters: expectedFilters })
|
||||
|
@ -110,32 +85,11 @@ usb_test(() => {
|
|||
});
|
||||
}, 'filters are sent correctly');
|
||||
|
||||
usb_test(() => {
|
||||
return getFakeDevice().then(({ device }) => {
|
||||
assertDeviceInfoEquals(device, fakeDeviceInit);
|
||||
return device.open().then(() => device.close());
|
||||
});
|
||||
}, 'onconnect event is trigged by adding a device');
|
||||
|
||||
usb_test(usb => {
|
||||
return getFakeDevice().then(({ device, fakeDevice }) => {
|
||||
return waitForDisconnect(fakeDevice).then(removedDevice => {
|
||||
assertDeviceInfoEquals(removedDevice, fakeDeviceInit);
|
||||
assert_equals(removedDevice, device);
|
||||
return 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');
|
||||
|
||||
usb_test(() => {
|
||||
return getFakeDevice().then(({ device, fakeDevice }) => {
|
||||
navigator.usb.test.onrequestdevice = event => {
|
||||
event.respondWith(fakeDevice);
|
||||
}
|
||||
};
|
||||
return callWithTrustedClick(() => {
|
||||
let first = navigator.usb.requestDevice({ filters: [] });
|
||||
let second = navigator.usb.requestDevice({ filters: [] });
|
||||
|
@ -150,4 +104,3 @@ usb_test(() => {
|
|||
});
|
||||
});
|
||||
}, 'multiple requestDevice calls are allowed per user activation');
|
||||
</script>
|
|
@ -6,7 +6,7 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
service_worker_test('/webusb/resources/usb.serviceworker.js',
|
||||
service_worker_test('/webusb/usb.serviceworker.js',
|
||||
'Ensure that WebUSB is inaccessible from a service worker.');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,22 @@
|
|||
// META: script=/webusb/resources/fake-devices.js
|
||||
// META: script=/webusb/resources/usb-helpers.js
|
||||
// META: global=sharedworker
|
||||
|
||||
'use strict';
|
||||
|
||||
usb_test(() => getFakeDevice()
|
||||
.then(({ device }) => {
|
||||
let evt = new USBConnectionEvent('connect', { device: device });
|
||||
assert_equals(evt.type, 'connect');
|
||||
assert_equals(evt.device, device);
|
||||
}),
|
||||
'Can construct a USBConnectionEvent with a device');
|
||||
|
||||
test(t => {
|
||||
assert_throws(TypeError(),
|
||||
() => new USBConnectionEvent('connect', { device: null }));
|
||||
assert_throws(TypeError(),
|
||||
() => new USBConnectionEvent('connect', {}));
|
||||
}, 'Cannot construct a USBConnectionEvent without a device');
|
||||
|
||||
done();
|
|
@ -1,22 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/fake-devices.js"></script>
|
||||
<script src="resources/usb-helpers.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
usb_test(() => {
|
||||
return getFakeDevice().then(({ device }) => {
|
||||
let evt = new USBConnectionEvent('connect', { device: device });
|
||||
assert_equals(evt.type, 'connect');
|
||||
assert_equals(evt.device, device);
|
||||
});
|
||||
}, 'Can construct a USBConnectionEvent with a device');
|
||||
|
||||
test(t => {
|
||||
assert_throws(TypeError(), () =>
|
||||
new USBConnectionEvent('connect', { device: null }));
|
||||
assert_throws(TypeError(), () => new USBConnectionEvent('connect', {}));
|
||||
}, 'Cannot construct a USBConnectionEvent without a device');
|
||||
</script>
|
|
@ -1,9 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/fake-devices.js"></script>
|
||||
<script src="resources/usb-helpers.js"></script>
|
||||
<script>
|
||||
// META: script=/webusb/resources/fake-devices.js
|
||||
// META: script=/webusb/resources/usb-helpers.js
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
function assertRejectsWithNotFoundError(promise) {
|
||||
|
@ -12,7 +9,7 @@ function assertRejectsWithNotFoundError(promise) {
|
|||
|
||||
function assertRejectsWithNotOpenError(promise) {
|
||||
return assertRejectsWithError(
|
||||
promise, 'InvalidStateError', 'The device must be opened first.')
|
||||
promise, 'InvalidStateError', 'The device must be opened first.');
|
||||
}
|
||||
|
||||
function assertRejectsWithNotConfiguredError(promise) {
|
||||
|
@ -340,7 +337,7 @@ usb_test(() => {
|
|||
assert_equals(result.status, 'ok');
|
||||
assert_equals(result.bytesWritten, 8);
|
||||
return device.close();
|
||||
})
|
||||
});
|
||||
});
|
||||
}, 'can issue OUT control transfer');
|
||||
|
||||
|
@ -651,4 +648,3 @@ usb_test(() => {
|
|||
.then(() => assertRejectsWithNotFoundError(device.reset()));
|
||||
});
|
||||
}, 'resetDevice rejects when called on a disconnected device');
|
||||
</script>
|
|
@ -1,7 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
// META: script=/webusb/resources/fake-devices.js
|
||||
// META: script=/webusb/resources/usb-helpers.js
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
test(t => {
|
||||
|
@ -28,4 +27,3 @@ test(t => {
|
|||
test(t => {
|
||||
assert_throws(TypeError(), () => new USBInTransferResult());
|
||||
}, 'Cannot construct USBInTransferResult without a status');
|
||||
</script>
|
|
@ -1,7 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
test(t => {
|
||||
|
@ -30,4 +27,3 @@ test(t => {
|
|||
test(t => {
|
||||
assert_throws(TypeError(), () => new USBIsochronousInTransferPacket());
|
||||
}, 'Cannot construct USBIsochronousInTransferPacket without a status');
|
||||
</script>
|
|
@ -1,7 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
test(t => {
|
||||
|
@ -38,4 +35,3 @@ test(t => {
|
|||
test(t => {
|
||||
assert_throws(TypeError(), () => new USBIsochronousInTransferResult());
|
||||
}, 'Cannot construct a USBIsochronousInTransferResult without packets');
|
||||
</script>
|
|
@ -1,7 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
test(t => {
|
||||
|
@ -23,4 +20,3 @@ test(t => {
|
|||
test(t => {
|
||||
assert_throws(TypeError(), () => new USBIsochronousOutTransferPacket());
|
||||
}, 'Cannot construct USBIsochronousOutTransferPacket without a status');
|
||||
</script>
|
|
@ -1,7 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
test(t => {
|
||||
|
@ -21,4 +18,3 @@ test(t => {
|
|||
test(t => {
|
||||
assert_throws(TypeError(), () => new USBIsochronousOutTransferResult());
|
||||
}, 'Cannot construct a USBIsochronousOutTransferResult without packets');
|
||||
</script>
|
|
@ -1,7 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
// META: global=sharedworker
|
||||
'use strict';
|
||||
|
||||
test(t => {
|
||||
|
@ -21,4 +18,3 @@ test(t => {
|
|||
test(t => {
|
||||
assert_throws(TypeError(), () => new USBOutTransferResult());
|
||||
}, 'Cannot construct USBOutTransferResult without a status');
|
||||
</script>
|
|
@ -1,11 +0,0 @@
|
|||
<!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>
|
|
@ -1,11 +0,0 @@
|
|||
<!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>
|
|
@ -1,11 +0,0 @@
|
|||
<!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/usb.dedicatedworker.sharedworker.js'));
|
||||
|
||||
</script>
|
|
@ -1,11 +0,0 @@
|
|||
<!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/usb.dedicatedworker.sharedworker.js'));
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue