dom/events/test/test_bug226361.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/events/test/test_bug226361.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.5 +<!--
     1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=226361
     1.7 +-->
     1.8 +<head>
     1.9 +  <title>Test for Bug 226361</title>
    1.10 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.11 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.12 +</head>
    1.13 +<body id="body1">
    1.14 +<p id="display">
    1.15 +
    1.16 + <a id="b1" tabindex="1" href="http://home.mozilla.org">start</a><br />
    1.17 +<br />
    1.18 +
    1.19 +<iframe id="iframe" tabindex="2" src="bug226361_iframe.xhtml"></iframe>
    1.20 +
    1.21 + <a id="b2" tabindex="3" href="http://home.mozilla.org">end</a>
    1.22 +
    1.23 +</p>
    1.24 +<div id="content" style="display: none">
    1.25 +  
    1.26 +</div>
    1.27 +<pre id="test">
    1.28 +<script type="application/javascript">
    1.29 +<![CDATA[
    1.30 +
    1.31 +/** Test for Bug 226361 **/
    1.32 +
    1.33 +// accessibility.tabfocus must be set to value 7 before running test also
    1.34 +// on a mac.
    1.35 +function setOrRestoreTabFocus(newValue) {
    1.36 +  if (!newValue) {
    1.37 +      SpecialPowers.clearUserPref("accessibility.tabfocus");
    1.38 +  } else {
    1.39 +    SpecialPowers.setIntPref("accessibility.tabfocus", newValue);
    1.40 +  }
    1.41 +}
    1.42 +
    1.43 +// =================================
    1.44 +
    1.45 +var doc = document;
    1.46 +function tab_to(id) {
    1.47 +  var wu = SpecialPowers.DOMWindowUtils;
    1.48 +  wu.sendKeyEvent('keypress',  9, 0, 0);
    1.49 +  is(doc.activeElement.id, id, "element with id=" + id + " should have focus");
    1.50 +}
    1.51 +
    1.52 +function tab_iframe() {
    1.53 +  doc = document;
    1.54 +  tab_to('iframe');
    1.55 +
    1.56 +  // inside iframe
    1.57 +  doc = document.getElementById('iframe').contentDocument
    1.58 +  tab_to('a3');tab_to('a5');tab_to('a1');tab_to('a2');tab_to('a4');
    1.59 +}
    1.60 +
    1.61 +
    1.62 +function doTest() {
    1.63 +
    1.64 +  setOrRestoreTabFocus(7);
    1.65 +
    1.66 +  try {
    1.67 +    window.getSelection().removeAllRanges();
    1.68 +    document.getElementById('body1').focus();
    1.69 +    is(document.activeElement.id, document.body.id, "body element should be focused");
    1.70 +
    1.71 +    doc = document;
    1.72 +    tab_to('b1');
    1.73 +
    1.74 +    tab_iframe();
    1.75 +
    1.76 +    doc=document
    1.77 +    document.getElementById('iframe').focus()
    1.78 +    tab_to('b2');
    1.79 +    // Change tabindex so the next TAB goes back to the IFRAME
    1.80 +    document.getElementById('iframe').setAttribute('tabindex','4');
    1.81 +
    1.82 +    tab_iframe();
    1.83 +
    1.84 +  } finally {
    1.85 +    setOrRestoreTabFocus(0);
    1.86 +  }
    1.87 +
    1.88 +  SimpleTest.finish();
    1.89 +}
    1.90 +
    1.91 +SimpleTest.waitForExplicitFinish();
    1.92 +addLoadEvent(doTest);
    1.93 +
    1.94 +]]>
    1.95 +</script>
    1.96 +</pre>
    1.97 +</body>
    1.98 +</html>

mercurial