From a94cf410aa67f8e8318f73a6f7ba357124d356c6 Mon Sep 17 00:00:00 2001 From: Reilly Grant Date: Fri, 4 Dec 2020 03:55:19 +0000 Subject: [PATCH] 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 Commit-Queue: Reilly Grant Cr-Commit-Position: refs/heads/master@{#833505} -- wpt-commits: 7f680aee5f41278be2b4146b7669b5cc8caec47f wpt-pr: 26713 --- .../tests/webusb/resources/manual.js | 38 +++++++++++++++ ...usbDevice_claimInterface-manual.https.html | 46 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 testing/web-platform/tests/webusb/resources/manual.js create mode 100644 testing/web-platform/tests/webusb/usbDevice_claimInterface-manual.https.html diff --git a/testing/web-platform/tests/webusb/resources/manual.js b/testing/web-platform/tests/webusb/resources/manual.js new file mode 100644 index 000000000000..869ac450acf1 --- /dev/null +++ b/testing/web-platform/tests/webusb/resources/manual.js @@ -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); +} diff --git a/testing/web-platform/tests/webusb/usbDevice_claimInterface-manual.https.html b/testing/web-platform/tests/webusb/usbDevice_claimInterface-manual.https.html new file mode 100644 index 000000000000..991c1a9f31f0 --- /dev/null +++ b/testing/web-platform/tests/webusb/usbDevice_claimInterface-manual.https.html @@ -0,0 +1,46 @@ + + + + + + + + + + +

+ These tests require a USB device to be connected. +

+ + + \ No newline at end of file