dom/events/test/test_bug547996-2.xhtml

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:3b4eb77ef243
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[
19
20 /** Test for Bug 547996 **/
21 /* mouseEvent.mozInputSource attribute */
22
23 var expectedInputSource = null;
24
25 function check(event) {
26 is(event.mozInputSource, expectedInputSource, ".mozInputSource");
27 }
28
29 function doTest() {
30 setup();
31
32 expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD;
33 testKeyboard();
34
35 expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
36 testMouse();
37
38 expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN;
39 testScriptedClicks();
40
41 cleanup();
42 SimpleTest.finish();
43 }
44
45 function testKeyboard() {
46
47 $("inputTarget").focus();
48 synthesizeKey("VK_SPACE", {});
49 synthesizeKey("VK_RETURN", {});
50
51 $("buttonTarget").focus();
52 synthesizeKey("VK_SPACE", {});
53 synthesizeKey("VK_RETURN", {});
54
55 //XUL buttons do not generate click on ENTER or SPACE,
56 //they do only on accessKey
57
58 $("anchorTarget").focus();
59 synthesizeKey("VK_RETURN", {});
60
61 synthesizeKey("VK_TAB", {});
62 synthesizeKey("VK_SPACE", {});
63 synthesizeKey("VK_RIGHT", {});
64
65 $("checkboxTarget").focus();
66 synthesizeKey("VK_SPACE", {});
67
68 var accessKeyDetails = (navigator.platform.indexOf("Mac") >= 0) ?
69 { ctrlKey : true } : { altKey : true, shiftKey: true };
70
71 synthesizeKey("o", accessKeyDetails);
72 synthesizeKey("t", accessKeyDetails);
73 }
74
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 }
84
85 function testScriptedClicks() {
86 $("inputTarget").click();
87 $("buttonTarget").click();
88 $("xulButtonTarget").click();
89 }
90
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);
99
100 }
101
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 }
111
112 SimpleTest.waitForExplicitFinish();
113 SimpleTest.waitForFocus(doTest, window);
114
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>

mercurial