|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <!-- |
|
3 https://bugzilla.mozilla.org/show_bug.cgi?id=226361 |
|
4 --> |
|
5 <head> |
|
6 <title>Test for Bug 226361</title> |
|
7 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
9 </head> |
|
10 <body id="body1"> |
|
11 <p id="display"> |
|
12 |
|
13 <a id="b1" tabindex="1" href="http://home.mozilla.org">start</a><br /> |
|
14 <br /> |
|
15 |
|
16 <iframe id="iframe" tabindex="2" src="bug226361_iframe.xhtml"></iframe> |
|
17 |
|
18 <a id="b2" tabindex="3" href="http://home.mozilla.org">end</a> |
|
19 |
|
20 </p> |
|
21 <div id="content" style="display: none"> |
|
22 |
|
23 </div> |
|
24 <pre id="test"> |
|
25 <script type="application/javascript"> |
|
26 <![CDATA[ |
|
27 |
|
28 /** Test for Bug 226361 **/ |
|
29 |
|
30 // accessibility.tabfocus must be set to value 7 before running test also |
|
31 // on a mac. |
|
32 function setOrRestoreTabFocus(newValue) { |
|
33 if (!newValue) { |
|
34 SpecialPowers.clearUserPref("accessibility.tabfocus"); |
|
35 } else { |
|
36 SpecialPowers.setIntPref("accessibility.tabfocus", newValue); |
|
37 } |
|
38 } |
|
39 |
|
40 // ================================= |
|
41 |
|
42 var doc = document; |
|
43 function tab_to(id) { |
|
44 var wu = SpecialPowers.DOMWindowUtils; |
|
45 wu.sendKeyEvent('keypress', 9, 0, 0); |
|
46 is(doc.activeElement.id, id, "element with id=" + id + " should have focus"); |
|
47 } |
|
48 |
|
49 function tab_iframe() { |
|
50 doc = document; |
|
51 tab_to('iframe'); |
|
52 |
|
53 // inside iframe |
|
54 doc = document.getElementById('iframe').contentDocument |
|
55 tab_to('a3');tab_to('a5');tab_to('a1');tab_to('a2');tab_to('a4'); |
|
56 } |
|
57 |
|
58 |
|
59 function doTest() { |
|
60 |
|
61 setOrRestoreTabFocus(7); |
|
62 |
|
63 try { |
|
64 window.getSelection().removeAllRanges(); |
|
65 document.getElementById('body1').focus(); |
|
66 is(document.activeElement.id, document.body.id, "body element should be focused"); |
|
67 |
|
68 doc = document; |
|
69 tab_to('b1'); |
|
70 |
|
71 tab_iframe(); |
|
72 |
|
73 doc=document |
|
74 document.getElementById('iframe').focus() |
|
75 tab_to('b2'); |
|
76 // Change tabindex so the next TAB goes back to the IFRAME |
|
77 document.getElementById('iframe').setAttribute('tabindex','4'); |
|
78 |
|
79 tab_iframe(); |
|
80 |
|
81 } finally { |
|
82 setOrRestoreTabFocus(0); |
|
83 } |
|
84 |
|
85 SimpleTest.finish(); |
|
86 } |
|
87 |
|
88 SimpleTest.waitForExplicitFinish(); |
|
89 addLoadEvent(doTest); |
|
90 |
|
91 ]]> |
|
92 </script> |
|
93 </pre> |
|
94 </body> |
|
95 </html> |