Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / gamepad / gamepad-api.html
blob5eb03436ecf700499854495db67ca2034cc29b42
1 <!DOCTYPE html>
2 <body>
3 <script src="../resources/js-test.js"></script>
4 <script>
5 description("Validates the exposed Gamepad API.")
7 shouldBeDefined("navigator.getGamepads");
8 shouldBeDefined("GamepadEvent");
10 gamepads = navigator.getGamepads();
11 shouldBe("gamepads.length", "4");
12 shouldBeUndefined("gamepads[0]");
13 shouldBe("gamepads.item.__proto__", "Function.prototype")
14 shouldBeNull("gamepads.item(0)");
16 if (window.gamepadController)
18 gamepadController.connect(0);
19 gamepadController.setId(0, "MockStick 3000");
20 gamepadController.setButtonCount(0, 1);
21 gamepadController.setAxisCount(0, 1);
23 gamepad = navigator.getGamepads()[0];
24 shouldBeNonNull("gamepad");
25 shouldBeTrue("gamepad.connected");
26 shouldBe("gamepad.__proto__", "Gamepad.prototype");
27 shouldBe("gamepad.id.__proto__", "String.prototype");
28 shouldBe("gamepad.connected.__proto__", "Boolean.prototype");
29 shouldBe("gamepad.index.__proto__", "Number.prototype");
30 shouldBe("gamepad.timestamp.__proto__", "Number.prototype");
31 shouldBe("gamepad.axes.__proto__", "Array.prototype");
32 shouldBe("gamepad.axes[0].__proto__", "Number.prototype");
33 shouldBe("gamepad.buttons.__proto__", "Array.prototype");
34 shouldBe("gamepad.buttons[0].pressed.__proto__", "Boolean.prototype");
35 shouldBe("gamepad.buttons[0].value.__proto__", "Number.prototype");
36 shouldBe("gamepad.mapping.__proto__", "String.prototype");
38 else
40 testFailed("no gamepadController available.");
42 </script>
43 </body>