diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/gamepad/test_gamepad_connect_events.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/gamepad/test_gamepad_connect_events.html')
-rw-r--r-- | dom/tests/mochitest/gamepad/test_gamepad_connect_events.html | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/dom/tests/mochitest/gamepad/test_gamepad_connect_events.html b/dom/tests/mochitest/gamepad/test_gamepad_connect_events.html new file mode 100644 index 000000000..e8102c24f --- /dev/null +++ b/dom/tests/mochitest/gamepad/test_gamepad_connect_events.html @@ -0,0 +1,76 @@ +<!-- Any copyright is dedicated to the Public Domain. + - http://creativecommons.org/publicdomain/zero/1.0/ --> +<!-- bug 893785 - Test that sending a gamepadconnected event to a new window + doesn't result in a gamepadconnected event being sent to existing + windows that have already received it. --> +<!DOCTYPE HTML> +<html> +<head> + <title>Test hidden frames</title> + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<script type="text/javascript" src="mock_gamepad.js"></script> +<script class="testbody" type="text/javascript"> +SimpleTest.waitForExplicitFinish(); + +var gamepad_index; + +function pressButton() { + GamepadService.newButtonEvent(gamepad_index, 0, true); + GamepadService.newButtonEvent(gamepad_index, 0, false); +} + + // Add a gamepad +function startTests() { + window.addEventListener("gamepadbuttondown", function() { + // Wait to ensure that all frames received the button press as well. + SpecialPowers.executeSoon(tests[testNum++]); + }); + + GamepadService.addGamepad("test gamepad", // id + GamepadService.standardMapping, + 4, // buttons + 2).then(function(i) { + gamepad_index = i; + gamepad_connected() + }); +} + +var f1, f2; +function gamepad_connected() { + f1 = document.getElementById('f1'); + pressButton(); +} + +var testNum = 0; +var tests = [ + test1, + test2, +]; + +function test1() { + is(f1.contentWindow.connectedEvents, 1, "right number of connection events in frame 1"); + + // Now add another frame. + f2 = document.createElement("iframe"); + f2.addEventListener("load", function() { + // When the frame is loaded, press a button again. + pressButton(); + }); + f2.src = "gamepad_frame.html"; + document.body.appendChild(f2); +} + +function test2() { + is(f1.contentWindow.connectedEvents, 1, "right number of connection events in frame 1"); + is(f2.contentWindow.connectedEvents, 1, "right number of connection events in frame 2"); + GamepadService.removeGamepad(gamepad_index); + SimpleTest.finish(); +} + +</script> +<iframe id="f1" src="gamepad_frame.html" onload="runGamepadTest(startTests)"></iframe> +</body> +</html> |