Adapt gampad IDL tests to latest spec
and move IDL to a standalone file
diff --git a/gamepad/idlharness-manual.html b/gamepad/idlharness-manual.html
index 3b96073..8bb740a 100644
--- a/gamepad/idlharness-manual.html
+++ b/gamepad/idlharness-manual.html
@@ -1,78 +1,32 @@
<!doctype html>
-<html>
-<head>
<title>Manual Gamepad IDL tests</title>
-<link rel="help" href="https://w3c.github.io/gamepad/#gamepad-interface">
-<link rel="help" href="https://w3c.github.io/gamepad/#gamepadbutton-interface">
-<link rel="help" href="https://w3c.github.io/gamepad/#gamepadevent-interface">
-<link rel="help" href="https://w3c.github.io/gamepad/#navigator-interface-extension">
+<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>
-setup({explicit_done: true, explicit_timeout: true});
+"use strict";
-addEventListener("gamepadconnected", function (e) {
- var idl_array = new IdlArray();
- idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
- idl_array.add_idls(document.getElementById("idl").textContent);
+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"],
+ Navigator: ["navigator"]
});
idl_array.test();
- done();
-});
+}, "Test IDL implementation of Gamepad API");
</script>
-</head>
-<body>
-<pre id="untested_idl" style="display: none">
-interface Navigator {
-};
-
-interface Event {
-};
-</pre>
-<pre id="idl" style="display: none">
-interface Gamepad {
- readonly attribute DOMString id;
- readonly attribute long index;
- readonly attribute boolean connected;
- readonly attribute DOMHighResTimeStamp timestamp;
- readonly attribute GamepadMappingType mapping;
- readonly attribute FrozenArray<double> axes;
- readonly attribute FrozenArray<GamepadButton> buttons;
-};
-
-enum GamepadMappingType {
- "",
- "standard"
-};
-
-interface GamepadButton {
- readonly attribute boolean pressed;
- readonly attribute double value;
-};
-
-[Constructor(DOMString type, optional GamepadEventInit eventInitDict)]
-interface GamepadEvent : Event
-{
- readonly attribute Gamepad? gamepad;
-};
-
-dictionary GamepadEventInit : EventInit
-{
- Gamepad? gamepad = null;
-};
-
-partial interface Navigator {
- Gamepad[] getGamepads();
-};
-</pre>
-<p id="instructions">This test requires a gamepad. Connect one and press any button to start the test.</p>
-<div id="log"></div>
-</body>
-</html>
diff --git a/gamepad/idlharness.html b/gamepad/idlharness.html
index e78a56b..833449d 100644
--- a/gamepad/idlharness.html
+++ b/gamepad/idlharness.html
@@ -1,6 +1,4 @@
<!doctype html>
-<html>
-<head>
<title>Gamepad IDL tests</title>
<link rel="help" href="https://w3c.github.io/gamepad/#gamepad-interface">
<link rel="help" href="https://w3c.github.io/gamepad/#gamepadbutton-interface">
@@ -10,61 +8,21 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>
-</head>
-<body>
-<pre id="untested_idl" style="display: none">
-interface Navigator {
-};
-
-interface Event {
-};
-</pre>
-<pre id="idl" style="display: none">
-interface Gamepad {
- readonly attribute DOMString id;
- readonly attribute long index;
- readonly attribute boolean connected;
- readonly attribute DOMHighResTimeStamp timestamp;
- readonly attribute GamepadMappingType mapping;
- readonly attribute FrozenArray<double> axes;
- readonly attribute FrozenArray<GamepadButton> buttons;
-};
-
-enum GamepadMappingType {
- "",
- "standard"
-};
-
-interface GamepadButton {
- readonly attribute boolean pressed;
- readonly attribute double value;
-};
-
-[Constructor(DOMString type, optional GamepadEventInit eventInitDict)]
-interface GamepadEvent : Event
-{
- readonly attribute Gamepad? gamepad;
-};
-
-dictionary GamepadEventInit : EventInit
-{
- Gamepad? gamepad = null;
-};
-
-partial interface Navigator {
- sequence<Gamepad?> getGamepads();
-};
-</pre>
<script>
-var idl_array = new IdlArray();
-idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
-idl_array.add_idls(document.getElementById("idl").textContent);
-idl_array.add_objects({
+"use strict";
+
+promise_test(async () => {
+ 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: [new GamepadEvent("something")],
- Navigator: ["navigator"],
+ Navigator: ["navigator"]
});
-idl_array.test();
+ idl_array.test();
+}, "Test IDL implementation of Gamepad API");
</script>
-<div id="log"></div>
-</body>
-</html>
diff --git a/interfaces/gamepad.idl b/interfaces/gamepad.idl
new file mode 100644
index 0000000..0f7ca2c
--- /dev/null
+++ b/interfaces/gamepad.idl
@@ -0,0 +1,33 @@
+interface Gamepad {
+ readonly attribute DOMString id;
+ readonly attribute long index;
+ readonly attribute boolean connected;
+ readonly attribute DOMHighResTimeStamp timestamp;
+ readonly attribute GamepadMappingType mapping;
+ readonly attribute FrozenArray<double> axes;
+ readonly attribute FrozenArray<GamepadButton> buttons;
+};
+
+interface GamepadButton {
+ readonly attribute boolean pressed;
+ readonly attribute boolean touched;
+ readonly attribute double value;
+};
+
+enum GamepadMappingType {
+ "",
+ "standard",
+};
+
+partial interface Navigator {
+ sequence<Gamepad?> getGamepads();
+};
+
+[Constructor(GamepadEventInit eventInitDict)]
+interface GamepadEvent : Event {
+ readonly attribute Gamepad gamepad;
+};
+
+dictionary GamepadEventInit : EventInit {
+ required Gamepad gamepad;
+};