blob: 321c9b2b0c3369cde89a55e526f92f52e9422692 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<!doctype html>
<html>
<head>
<title>Manual Gamepad events tests</title>
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#the-gamepadconnected-event">
<link rel="help" href="https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#the-gamepaddisconnected-event">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({explicit_timeout: true});
function set_instructions(text) {
document.getElementById("instructions").textContent = text;
}
var index = -1;
addEventListener("gamepadconnected", function (e) {
assert_equals(index, -1, "Too many connected events?");
assert_class_string(e, "GamepadEvent");
assert_class_string(e.gamepad, "Gamepad");
index = e.gamepad.index;
set_instructions("Found a gamepad. Now disconnect the gamepad.");
});
addEventListener("gamepaddisconnected", function (e) {
assert_class_string(e, "GamepadEvent");
assert_equals(e.gamepad.index, index);
done();
});
</script>
</head>
<body>
<p id="instructions">This test requires a gamepad. Connect one and press any button to start the test.</p>
</body>
</html>
|