зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1680176 [wpt PR 26713] - usb: Support composite devices using the WinUSB driver, a=testonly
Automatic update from web-platform-tests usb: Support composite devices using the WinUSB driver This adds support for an uncommon configuration in which a composite USB device has the WinUSB driver loaded for the whole device rather than using Microsoft's composite driver to create device nodes for each device function. A manual test which confirms that all calls to claimInterface() succeed or fail in a reasonable time has been added. Bug: 1150758 Change-Id: If86d2e21dbc575cadea943a9c319029a10c78b36 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568546 Reviewed-by: Matt Reynolds <mattreynolds@chromium.org> Commit-Queue: Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#833505} -- wpt-commits: 7f680aee5f41278be2b4146b7669b5cc8caec47f wpt-pr: 26713
This commit is contained in:
Родитель
989ab3c54c
Коммит
a94cf410aa
|
@ -0,0 +1,38 @@
|
|||
let manualTestDevice = null;
|
||||
|
||||
navigator.usb.addEventListener('disconnect', (e) => {
|
||||
if (e.device === manualTestDevice) {
|
||||
manualTestDevice = null;
|
||||
}
|
||||
})
|
||||
|
||||
async function getDeviceForManualTest() {
|
||||
if (manualTestDevice) {
|
||||
return manualTestDevice;
|
||||
}
|
||||
|
||||
const button = document.createElement('button');
|
||||
button.textContent = 'Click to select a device';
|
||||
button.style.display = 'block';
|
||||
button.style.fontSize = '20px';
|
||||
button.style.padding = '10px';
|
||||
|
||||
await new Promise((resolve) => {
|
||||
button.onclick = () => {
|
||||
document.body.removeChild(button);
|
||||
resolve();
|
||||
};
|
||||
document.body.appendChild(button);
|
||||
});
|
||||
|
||||
manualTestDevice = await navigator.usb.requestDevice({filters: []});
|
||||
assert_true(manualTestDevice instanceof USBDevice);
|
||||
|
||||
return manualTestDevice;
|
||||
}
|
||||
|
||||
function manual_usb_test(func, name, properties) {
|
||||
promise_test(async (test) => {
|
||||
await func(test, await getDeviceForManualTest());
|
||||
}, name, properties);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/manual.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
These tests require a USB device to be connected.
|
||||
</p>
|
||||
<script>
|
||||
manual_usb_test(async (t, device) => {
|
||||
await device.open();
|
||||
const interfacesClaimed = [];
|
||||
t.add_cleanup(async () => {
|
||||
for (const iface of interfacesClaimed) {
|
||||
await device.releaseInterface(iface.interfaceNumber);
|
||||
}
|
||||
await device.close();
|
||||
});
|
||||
|
||||
await device.selectConfiguration(1);
|
||||
|
||||
const promises = [];
|
||||
for (const iface of device.configuration.interfaces) {
|
||||
const promise = device.claimInterface(iface.interfaceNumber);
|
||||
promises.push(promise);
|
||||
|
||||
// Create a subtest for each interface so that success or failure to
|
||||
// claim the interface is visible but does not affect the result of
|
||||
// the overall test.
|
||||
promise_test(async (t) => {
|
||||
await promise;
|
||||
|
||||
interfacesClaimed.push(iface);
|
||||
}, `Can claim interface ${iface.interfaceNumber}`);
|
||||
}
|
||||
|
||||
await Promise.allSettled(promises);
|
||||
}, 'claimInterface() resolves or rejects for all interfaces');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче