tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

idlharness-manual.html (1184B)


      1 <!doctype html>
      2 <title>Manual Gamepad IDL tests</title>
      3 <link rel="help" href="https://w3c.github.io/gamepad/">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/WebIDLParser.js"></script>
      7 <script src="/resources/idlharness.js"></script>
      8 <p id="instructions">This test requires a gamepad. Connect one and press any button to start the test.</p>
      9 <script>
     10 'use strict';
     11 
     12 idl_test(
     13  ['gamepad'],
     14  ['dom', 'html'],
     15  (idl_array, t) => {
     16    idl_array.add_objects({
     17      Gamepad: ['gamepad'],
     18      GamepadButton: ['gamepadButton'],
     19      GamepadEvent: ['event'],
     20      Navigator: ['navigator']
     21    });
     22 
     23    const eventWatcher = new EventWatcher(t, window, "gamepadconnected");
     24    const gamepadConnected = eventWatcher.wait_for("gamepadconnected")
     25        .then(e => {
     26          self.event = e;
     27          self.gamepad = e.gamepad;
     28          self.gamepadButton = e.gamepad.buttons[0];
     29        });
     30 
     31    const timeout = new Promise((_, reject) => {
     32      t.step_timeout(() => { reject('Timed out waiting for gamepad'); }, 5000);
     33    });
     34    return Promise.race([gamepadConnected, timeout]);
     35  }
     36 );
     37 </script>