diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/events/test/test_bug547996-2.xhtml | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/events/test/test_bug547996-2.xhtml')
-rw-r--r-- | dom/events/test/test_bug547996-2.xhtml | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/dom/events/test/test_bug547996-2.xhtml b/dom/events/test/test_bug547996-2.xhtml new file mode 100644 index 0000000000..e3f45bdb97 --- /dev/null +++ b/dom/events/test/test_bug547996-2.xhtml @@ -0,0 +1,120 @@ +<?xml version="1.0"?> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=547996 +--> +<head> + <title>Test for Bug 547996</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=547996">Mozilla Bug 547996</a> +<p id="display"></p> +<div id="content" style="display: none"></div> +<pre id="test"> +<script type="application/javascript"><![CDATA[ + +/** Test for Bug 547996 **/ +/* mouseEvent.mozInputSource attribute */ + +var expectedInputSource = null; + +function check(event) { + is(event.mozInputSource, expectedInputSource, ".mozInputSource"); +} + +function doTest() { + setup(); + + expectedInputSource = MouseEvent.MOZ_SOURCE_KEYBOARD; + testKeyboard(); + + expectedInputSource = MouseEvent.MOZ_SOURCE_MOUSE; + testMouse(); + + expectedInputSource = MouseEvent.MOZ_SOURCE_UNKNOWN; + testScriptedClicks(); + + cleanup(); + SimpleTest.finish(); +} + +function testKeyboard() { + + $("inputTarget").focus(); + synthesizeKey("VK_SPACE", {}); + synthesizeKey("VK_RETURN", {}); + + $("buttonTarget").focus(); + synthesizeKey("VK_SPACE", {}); + synthesizeKey("VK_RETURN", {}); + + //XUL buttons do not generate click on ENTER or SPACE, + //they do only on accessKey + + $("anchorTarget").focus(); + synthesizeKey("VK_RETURN", {}); + + synthesizeKey("VK_TAB", {}); + synthesizeKey("VK_SPACE", {}); + synthesizeKey("VK_RIGHT", {}); + + $("checkboxTarget").focus(); + synthesizeKey("VK_SPACE", {}); + + var accessKeyDetails = (navigator.platform.includes("Mac")) ? + { ctrlKey : true } : { altKey : true, shiftKey: true }; + + synthesizeKey("o", accessKeyDetails); + synthesizeKey("t", accessKeyDetails); +} + +function testMouse() { + synthesizeMouse($("inputTarget"), 0, 0, {}); + synthesizeMouse($("buttonTarget"), 0, 0, {}); + synthesizeMouse($("anchorTarget"), 0, 0, {}); + synthesizeMouse($("radioTarget1"), 0, 0, {}); + synthesizeMouse($("radioTarget2"), 0, 0, {}); + synthesizeMouse($("checkboxTarget"), 0, 0, {}); +} + +function testScriptedClicks() { + $("inputTarget").click(); + $("buttonTarget").click(); +} + +function setup() { + $("inputTarget").addEventListener("click", check); + $("buttonTarget").addEventListener("click", check); + $("anchorTarget").addEventListener("click", check); + $("radioTarget1").addEventListener("click", check); + $("radioTarget2").addEventListener("click", check); + $("checkboxTarget").addEventListener("click", check); + +} + +function cleanup() { + $("inputTarget").removeEventListener("click", check); + $("buttonTarget").removeEventListener("click", check); + $("anchorTarget").removeEventListener("click", check); + $("radioTarget1").removeEventListener("click", check); + $("radioTarget2").removeEventListener("click", check); + $("checkboxTarget").removeEventListener("click", check); +} + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(doTest, window); + +]]></script> +</pre> +<input type="checkbox" id="checkboxTarget">Checkbox target</input> +<input id="inputTarget" type="button" value="HTML Input" accesskey="o"/> +<button id="buttonTarget">HTML Button</button> +<a href="#" id="anchorTarget">Anchor</a> +<input type="radio" id="radioTarget1" name="group">Radio Target 1</input> +<input type="radio" id="radioTarget2" name="group">Radio Target 2</input> +</body> +</html> |