dom/events/test/test_bug226361.xhtml

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial