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 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=265203
5 -->
6 <head>
7 <title>Test for Bug 265203</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=265203">Mozilla Bug 265203</a>
14 <p id="display">
15 <a id="a1" href="http://www.mozilla.org">Mozilla</a><a id="a2"
16 href="http://www.mozilla.org/products/firefox">Firefox</a><br>
17 <br>
18 <table cellpadding="2" cellspacing="2" border="1"
19 style="text-align: left; width: 100%;">
20 <tbody>
22 <tr>
23 <td style="vertical-align: top;"><a id="a3" href="http://www.mozilla.org">Mozilla</a></td>
24 <td style="vertical-align: top;"><a
25 href="http://www.mozilla.org/products/firefox">Firefox</a></td>
26 </tr>
27 <tr>
28 <td style="vertical-align: top;"><a href="http://www.mozilla.org">Mozilla</a></td>
29 <td style="vertical-align: top;"><a
30 href="http://www.mozilla.org/products/firefox">Firefox</a></td>
32 </tr>
33 </tbody>
34 </table>
35 </p>
36 <div id="content" style="display: none">
38 </div>
39 <pre id="test">
40 <script type="application/javascript">
42 /** Test for Bug 265203 **/
44 // Turn off spatial navigation because it hijacks VK_RIGHT and VK_LEFT keydown
45 // events
46 SpecialPowers.setBoolPref("snav.enabled", false);
48 var gTestStarted = false;
49 var expectedResult = [ null, 0, null ];
50 var nextTest;
51 var test = 0;
53 function testFocus() {
54 var selection = window.getSelection()
55 is(selection.focusNode, expectedResult[0],"test" + test + ": " + "caret node");
56 is(selection.focusOffset, expectedResult[1],"test" + test + ": " + "caret offset");
57 is(document.activeElement, expectedResult[2],"test" + test + ": " + "focused node");
58 ++test;
59 if (nextTest)
60 nextTest();
61 }
63 function test0() {
64 $("a1").focus();
65 expectedResult = [ $("a1"), 0, $("a1") ]
66 nextTest = test1;
67 testFocus();
68 }
69 function test1() {
70 synthesizeKey("VK_RIGHT", { });
71 synthesizeKey("VK_RIGHT", { });
72 synthesizeKey("VK_RIGHT", { });
73 synthesizeKey("VK_RIGHT", { });
74 synthesizeKey("VK_RIGHT", { });
75 synthesizeKey("VK_RIGHT", { });
76 synthesizeKey("VK_RIGHT", { });
77 expectedResult = [ $("a1").firstChild, 7, $("a2") ]
78 nextTest = test2;
79 testFocus();
80 }
81 function test2() {
82 $("a3").focus();
83 expectedResult = [ $("a3"), 0, $("a3") ]
84 nextTest = test3;
85 testFocus();
86 }
87 function test3() {
88 synthesizeKey("VK_RIGHT", { });
89 synthesizeKey("VK_RIGHT", { });
90 synthesizeKey("VK_RIGHT", { });
91 synthesizeKey("VK_RIGHT", { });
92 synthesizeKey("VK_RIGHT", { });
93 synthesizeKey("VK_RIGHT", { });
94 synthesizeKey("VK_RIGHT", { });
95 expectedResult = [ $("a3").firstChild, 7, $("a3") ]
96 nextTest = SimpleTest.finish;
97 testFocus();
98 }
100 function startTest() {
101 if (gTestStarted)
102 return;
103 gTestStarted = true;
105 SpecialPowers.pushPrefEnv({"set": [["accessibility.browsewithcaret", true]]}, test0);
106 }
108 SimpleTest.waitForExplicitFinish();
109 SimpleTest.waitForFocus(startTest);
111 </script>
112 </pre>
113 </body>
114 </html>