Files
tubestation/testing/web-platform/tests/webusb/usbDevice-same-objecct.https.any.js
Jack Hsieh 4654f43016 Bug 1747449 [wpt PR 32185] - Make instances returned by the accessors on USBDevice === comparable., a=testonly
Automatic update from web-platform-tests
Make instances returned by the accessors on USBDevice `===` comparable.

Add new private HeapVector members in USBConfiguration, USBInterface,
and USBAlternateInterface to hold an array of related instances rather
than making a new instance each time the method is invoked, and the
array is constructed in the constructor. By doing this way to make
related instances within USBDevice `===` comparable.

On the WPT webusb side:
- Add new USBDevice SameObject test.
- Add new garbage collection test to improve code coverage.

Bug: 1274922
Change-Id: I96c928c4fef4692d8b74dbaa26b22a6c6ae60443
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3352679
Reviewed-by: Matt Reynolds <mattreynolds@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Jack Hsieh <chengweih@chromium.org>
Commit-Queue: Jack Hsieh <chengweih@chromium.org>
Cr-Commit-Position: refs/heads/main@{#975840}

--

wpt-commits: f856a80317a9d218569eae182e394f981a8464c2
wpt-pr: 32185
2022-03-21 06:51:26 +00:00

27 lines
955 B
JavaScript

// META: script=/resources/test-only-api.js
// META: script=/webusb/resources/fake-devices.js
// META: script=/webusb/resources/usb-helpers.js
'use strict';
usb_test(async () => {
const {device} = await getFakeDevice();
await device.open();
for (const configuration of device.configurations) {
await device.selectConfiguration(configuration.configurationValue);
assert_equals(device.configuration, configuration);
for (const interfaceObj of configuration.interfaces) {
await device.claimInterface(interfaceObj.interfaceNumber);
for (const alternate of interfaceObj.alternates) {
await device.selectAlternateInterface(
interfaceObj.interfaceNumber, alternate.alternateSetting);
assert_equals(interfaceObj.alternate, alternate);
}
await device.releaseInterface(interfaceObj.interfaceNumber);
}
}
await device.close();
}, '[SameObject] test for instances within USBDevice.');