https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 6af27ec2961eab2855c6d9b88972ed25a9aaaf12 authored by Yutaka Hirano on 24 April 2018, 03:27:42 UTC
fix
Tip revision: 6af27ec
idlharness.https.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8>
    <title>WebUSB IDL test</title>
    <link rel="help" href="https://wicg.github.io/webusb/">
    <script src=/resources/testharness.js></script>
    <script src=/resources/testharnessreport.js></script>
    <script src=/resources/WebIDLParser.js></script>
    <script src=/resources/idlharness.js></script>
    <script src=resources/fake-devices.js></script>
    <script src=resources/usb-helpers.js></script>
  </head>
  <body>
    <script>
      'use strict';

      // Object instances used by the IDL test.
      var usbDevice;
      var usbConfiguration;
      var usbInterface;
      var usbAlternateInterface;
      var usbEndpoint;
      var usbConnectionEvent;

      usb_test(async () => {
        let response = await fetch('/interfaces/webusb.idl');
        let idl_text = await response.text();
        let idl_array = new IdlArray();
        idl_array.add_idls(idl_text);

        // Untested IDL interfaces
        idl_array.add_untested_idls('interface Event {};');
        idl_array.add_untested_idls('interface EventHandler {};');
        idl_array.add_untested_idls('dictionary EventInit {};');
        idl_array.add_untested_idls('interface EventTarget {};');
        idl_array.add_untested_idls('interface Navigator {};');

        let {device} = await getFakeDevice();

        usbDevice = device;
        usbConfiguration = usbDevice.configurations[0];
        usbInterface = usbConfiguration.interfaces[0];
        usbAlternateInterface = usbInterface.alternates[0];
        usbEndpoint = usbAlternateInterface.endpoints[0];
        usbConnectionEvent =
            new USBConnectionEvent('connect', { device: usbDevice })

        idl_array.add_objects({
          Navigator: ['navigator'],
          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")'],
        });

        idl_array.test();
      }, 'WebUSB IDL test');
    </script>
  </body>
</html>
back to top