https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 3fee9e181e7c97c517c0b36b6387c04e74a02181 authored by Andy Paicu on 02 October 2018, 04:21:46 UTC
Fixed securityviolationevent not containing the full src and path
Tip revision: 3fee9e1
usbAlternateInterface.https.any.js
// META: script=/webusb/resources/fake-devices.js
// META: script=/webusb/resources/usb-helpers.js
'use strict';

usb_test(async () => {
  let { device } = await getFakeDevice();
  let configuration = new USBConfiguration(
      device, device.configurations[1].configurationValue);
  let usbInterface = new USBInterface(
      configuration, configuration.interfaces[0].interfaceNumber);
  let alternateInterface = new USBAlternateInterface(
      usbInterface, usbInterface.alternates[1].alternateSetting);
  assertDeviceInfoEquals(
      alternateInterface,
      fakeDeviceInit.configurations[1].interfaces[0].alternates[1]);
}, 'Can construct a USBAlternateInterface.');

usb_test(async () => {
  let { device } = await getFakeDevice();
  let configuration = new USBConfiguration(
      device, device.configurations[1].configurationValue);
  let usbInterface = new USBInterface(
      configuration, configuration.interfaces[0].interfaceNumber);
  try {
    let alternateInterface = new USBAlternateInterface(
        usbInterface, usbInterface.alternates.length);
    assert_unreached(
        'USBAlternateInterface should reject an invalid alternate setting');
  } catch (error) {
    assert_equals(error.name, 'RangeError');
  }
}, 'Constructing a USBAlternateInterface with an invalid alternate setting ' +
    'throws a range error.');
back to top