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

     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">
    13  <a id="b1" tabindex="1" href="http://home.mozilla.org">start</a><br />
    14 <br />
    16 <iframe id="iframe" tabindex="2" src="bug226361_iframe.xhtml"></iframe>
    18  <a id="b2" tabindex="3" href="http://home.mozilla.org">end</a>
    20 </p>
    21 <div id="content" style="display: none">
    23 </div>
    24 <pre id="test">
    25 <script type="application/javascript">
    26 <![CDATA[
    28 /** Test for Bug 226361 **/
    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 }
    40 // =================================
    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 }
    49 function tab_iframe() {
    50   doc = document;
    51   tab_to('iframe');
    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 }
    59 function doTest() {
    61   setOrRestoreTabFocus(7);
    63   try {
    64     window.getSelection().removeAllRanges();
    65     document.getElementById('body1').focus();
    66     is(document.activeElement.id, document.body.id, "body element should be focused");
    68     doc = document;
    69     tab_to('b1');
    71     tab_iframe();
    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');
    79     tab_iframe();
    81   } finally {
    82     setOrRestoreTabFocus(0);
    83   }
    85   SimpleTest.finish();
    86 }
    88 SimpleTest.waitForExplicitFinish();
    89 addLoadEvent(doTest);
    91 ]]>
    92 </script>
    93 </pre>
    94 </body>
    95 </html>

mercurial