Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <?xml version="1.0"?>
2 <html xmlns="http://www.w3.org/1999/xhtml"
3 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
4 <!--
5 https://bugzilla.mozilla.org/show_bug.cgi?id=547996
6 -->
7 <head>
8 <title>Test for Bug 547996</title>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
12 </head>
13 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=547996">Mozilla Bug 547996</a>
15 <p id="display"></p>
16 <div id="content" style="display: none"></div>
17 <pre id="test">
18 <script type="application/javascript"><![CDATA[
20 /** Test for Bug 547996 **/
21 /* mouseEvent.mozInputSource attribute */
23 var expectedInputSource = null;
25 function check(event) {
26 is(event.mozInputSource, expectedInputSource, ".mozInputSource");
27 }
29 function doTest() {
30 setup();
32 expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD;
33 testKeyboard();
35 expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
36 testMouse();
38 expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN;
39 testScriptedClicks();
41 cleanup();
42 SimpleTest.finish();
43 }
45 function testKeyboard() {
47 $("inputTarget").focus();
48 synthesizeKey("VK_SPACE", {});
49 synthesizeKey("VK_RETURN", {});
51 $("buttonTarget").focus();
52 synthesizeKey("VK_SPACE", {});
53 synthesizeKey("VK_RETURN", {});
55 //XUL buttons do not generate click on ENTER or SPACE,
56 //they do only on accessKey
58 $("anchorTarget").focus();
59 synthesizeKey("VK_RETURN", {});
61 synthesizeKey("VK_TAB", {});
62 synthesizeKey("VK_SPACE", {});
63 synthesizeKey("VK_RIGHT", {});
65 $("checkboxTarget").focus();
66 synthesizeKey("VK_SPACE", {});
68 var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ?
69 { ctrlKey : true } : { altKey : true, shiftKey: true };
71 synthesizeKey("o", accessKeyDetails);
72 synthesizeKey("t", accessKeyDetails);
73 }
75 function testMouse() {
76 synthesizeMouse($("inputTarget"), 0, 0, {});
77 synthesizeMouse($("buttonTarget"), 0, 0, {});
78 synthesizeMouse($("xulButtonTarget"), 0, 0, {});
79 synthesizeMouse($("anchorTarget"), 0, 0, {});
80 synthesizeMouse($("radioTarget1"), 0, 0, {});
81 synthesizeMouse($("radioTarget2"), 0, 0, {});
82 synthesizeMouse($("checkboxTarget"), 0, 0, {});
83 }
85 function testScriptedClicks() {
86 $("inputTarget").click();
87 $("buttonTarget").click();
88 $("xulButtonTarget").click();
89 }
91 function setup() {
92 $("inputTarget").addEventListener("click", check, false);
93 $("buttonTarget").addEventListener("click", check, false);
94 $("anchorTarget").addEventListener("click", check, false);
95 $("xulButtonTarget").addEventListener("click", check, false);
96 $("radioTarget1").addEventListener("click", check, false);
97 $("radioTarget2").addEventListener("click", check, false);
98 $("checkboxTarget").addEventListener("click", check, false);
100 }
102 function cleanup() {
103 $("inputTarget").removeEventListener("click", check, false);
104 $("buttonTarget").removeEventListener("click", check, false);
105 $("xulButtonTarget").removeEventListener("click", check, false);
106 $("anchorTarget").removeEventListener("click", check, false);
107 $("radioTarget1").removeEventListener("click", check, false);
108 $("radioTarget2").removeEventListener("click", check, false);
109 $("checkboxTarget").removeEventListener("click", check, false);
110 }
112 SimpleTest.waitForExplicitFinish();
113 SimpleTest.waitForFocus(doTest, window);
115 ]]></script>
116 </pre>
117 <input type="checkbox" id="checkboxTarget">Checkbox target</input>
118 <input id="inputTarget" type="button" value="HTML Input" accesskey="o"/>
119 <button id="buttonTarget">HTML Button</button>
120 <xul:button id="xulButtonTarget" accesskey="t">XUL Button</xul:button>
121 <a href="#" id="anchorTarget">Anchor</a>
122 <input type="radio" id="radioTarget1" name="group">Radio Target 1</input>
123 <input type="radio" id="radioTarget2" name="group">Radio Target 2</input>
124 </body>
125 </html>