test_bug226361.xhtml (1907B)
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 src="/tests/SimpleTest/SimpleTest.js"></script> 8 <script src="/tests/SimpleTest/EventUtils.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body id="body1"> 12 <p id="display"> 13 14 <a id="b1" tabindex="1" href="http://home.mozilla.org">start</a><br /> 15 <br /> 16 17 <iframe id="iframe" tabindex="2" src="bug226361_iframe.xhtml"></iframe> 18 19 <a id="b2" tabindex="3" href="http://home.mozilla.org">end</a> 20 21 </p> 22 <div id="content" style="display: none"> 23 24 </div> 25 <pre id="test"> 26 <script type="application/javascript"> 27 <![CDATA[ 28 29 /** Test for Bug 226361 */ 30 31 // accessibility.tabfocus must be set to value 7 before running test also 32 // on a mac. 33 function setTabFocus() { 34 SpecialPowers.pushPrefEnv({ set: [[ "accessibility.tabfocus", 7 ]] }, doTest); 35 } 36 37 // ================================= 38 39 var doc = document; 40 function tab_to(id) { 41 synthesizeKey("KEY_Tab", {}); 42 is(doc.activeElement.id, id, "element with id=" + id + " should have focus"); 43 } 44 45 function tab_iframe() { 46 // inside iframe 47 doc = document.getElementById('iframe').contentDocument 48 tab_to('a3');tab_to('a5');tab_to('a1');tab_to('a2');tab_to('a4'); 49 } 50 51 52 function doTest() { 53 window.getSelection().removeAllRanges(); 54 document.getElementById('body1').focus(); 55 is(document.activeElement.id, document.body.id, "body element should be focused"); 56 57 doc = document; 58 tab_to('b1'); 59 60 tab_iframe(); 61 62 doc=document 63 document.getElementById('iframe').focus() 64 tab_to('b2'); 65 // Change tabindex so the next TAB goes back to the IFRAME 66 document.getElementById('iframe').setAttribute('tabindex','4'); 67 68 tab_iframe(); 69 SimpleTest.finish(); 70 } 71 72 SimpleTest.waitForExplicitFinish(); 73 addLoadEvent(setTabFocus); 74 75 ]]> 76 </script> 77 </pre> 78 </body> 79 </html>