gecko-dev/testing/web-platform/tests/gamepad/timestamp-manual.html
James Graham 2dc7a68af1 Bug 1386604 - Update web-platform-tests to revision 8b5316ad93c6c1238eea26a3d8052e32b34bbabd, a=testonly
MozReview-Commit-ID: 3HXcvTYpAkA


--HG--
rename : testing/web-platform/tests/fonts/matching/README.md => testing/web-platform/tests/css-fonts/matching/README.md
rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight-ref.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight-ref.html
rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight.html
rename : testing/web-platform/tests/fonts/matching/font-matching.css => testing/web-platform/tests/css-fonts/matching/font-matching.css
rename : testing/web-platform/tests/fonts/matching/resources/variabletest_matching.ttf => testing/web-platform/tests/css-fonts/matching/resources/variabletest_matching.ttf
rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance-ref.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance-ref.html
rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance.html
rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction-ref.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction-ref.html
rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction.html
rename : testing/web-platform/tests/payment-request/OWNERS => testing/web-platform/tests/payment-method-id/OWNERS
rename : testing/web-platform/tests/storage/interfaces.worker.js => testing/web-platform/tests/storage/interfaces.https.worker.js
rename : testing/web-platform/tests/tools/browserutils/requirements.txt => testing/web-platform/tests/tools/wpt/requirements.txt
rename : testing/web-platform/tests/tools/browserutils/utils.py => testing/web-platform/tests/tools/wpt/utils.py
rename : testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait.js => testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait_marionette.js
rename : testing/web-platform/tests/uievents/keyboard/key-manual.css => testing/web-platform/tests/uievents/keyboard/key.css
rename : testing/web-platform/tests/uievents/keyboard/key-manual.js => testing/web-platform/tests/uievents/keyboard/key.js
2017-08-03 11:31:54 +01:00

59 lines
1.9 KiB
HTML

<!doctype html>
<html>
<head>
<title>Manual Gamepad timestamp tests</title>
<link rel="help" href="https://w3c.github.io/gamepad/#dom-gamepad-timestamp">
<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;
var lastTimestamp = performance.now();
var id = -1;
addEventListener("gamepadconnected", function (e) {
assert_equals(index, -1, "Too many connected events?");
index = e.gamepad.index;
assert_greater_than(e.gamepad.timestamp, lastTimestamp, "timestamp should be increasing");
lastTimestamp = e.gamepad.timestamp;
set_instructions("Found a gamepad. Now release the button you pressed and press it again.");
// There may not be a button pressed here, so handle it cleanly either way.
if (e.gamepad.buttons.some(function (b) { return b.pressed; })) {
id = setInterval(waitForButtonRelease, 15);
} else {
id = setInterval(waitForButtonPress, 15);
}
});
function waitForButtonRelease() {
var gamepad = navigator.getGamepads()[index];
assert_true(!!gamepad);
if (gamepad.buttons.every(function (b) { return !b.pressed; })) {
assert_greater_than(gamepad.timestamp, lastTimestamp, "timestamp should be increasing");
lastTimestamp = gamepad.timestamp;
clearInterval(id);
id = setInterval(waitForButtonPress, 15);
}
}
function waitForButtonPress() {
var gamepad = navigator.getGamepads()[index];
assert_true(!!gamepad);
if (gamepad.buttons.some(function (b) { return b.pressed; })) {
assert_greater_than(gamepad.timestamp, lastTimestamp, "timestamp should be increasing");
clearInterval(id);
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>