https://github.com/web-platform-tests/wpt
Raw File
Tip revision: ea1a9c736686a73256cd23b5531cd10f123ad468 authored by kritisingh1 on 15 March 2018, 16:30:55 UTC
updating changes
Tip revision: ea1a9c7
idlharness-manual.html
<!doctype html>
<title>Manual Gamepad IDL tests</title>
<link rel="help" href="https://w3c.github.io/gamepad/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
<p id="instructions">This test requires a gamepad. Connect one and press any button to start the test.</p>
<script>
"use strict";

setup({explicit_timeout: true});

promise_test(async t => {
  const eventWatcher = new EventWatcher(t, window, "gamepadconnected");
  let e = await eventWatcher.wait_for("gamepadconnected");
  const idl_array = new IdlArray();
  const gamepad_idl = await fetch("/interfaces/gamepad.idl").then(r => r.text());

  idl_array.add_untested_idls('interface Event {};');
  idl_array.add_untested_idls('interface Navigator {};');
  idl_array.add_idls(gamepad_idl);

  idl_array.add_objects({
    GamepadEvent: [e],
    Gamepad: [e.gamepad],
    GamepadButton: [e.gamepad.buttons[0]],
    Navigator: ["navigator"]
  });
  idl_array.test();
}, "Test IDL implementation of Gamepad API");
</script>
back to top