summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webusb/idlharness.https.any.js
blob: 0c8cb322a086024b209f620ddc9a7ed1c2c1a226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// META: timeout=long
// META: script=/resources/WebIDLParser.js
// META: script=/resources/idlharness.js
// META: script=/resources/test-only-api.js
// META: script=/webusb/resources/fake-devices.js
// META: script=/webusb/resources/usb-helpers.js

'use strict';

idl_test(
  ['webusb'],
  ['permissions', 'html', 'dom'],
  async idl_array => {
    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({
      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")'],
    });

    return usb_test(async () => {
      // Ignored errors are surfaced in idlharness.js's test_object below.
      self.usbDevice = await getFakeDevice().device;
      self.usbConfiguration = usbDevice.configurations[0];
      self.usbInterface = usbConfiguration.interfaces[0];
      self.usbAlternateInterface = usbInterface.alternates[0];
      self.usbEndpoint = usbAlternateInterface.endpoints[0];
      self.usbConnectionEvent =
          new USBConnectionEvent('connect', { device: usbDevice });
    }, 'USB device setup');
  }
);