1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_tabindex.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,120 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?> 1.7 +<!-- 1.8 + XUL Widget Test for tabindex 1.9 + --> 1.10 +<window title="tabindex" width="500" height="600" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.14 + 1.15 +<!-- 1.16 + Elements are navigated in the following order: 1.17 + 1. tabindex > 0 in tree order 1.18 + 2. tabindex = 0 in tree order 1.19 + Elements with tabindex = -1 are not in the tab order 1.20 + --> 1.21 +<hbox> 1.22 + <button id="t5" label="One"/> 1.23 + <checkbox id="no1" label="Two" tabindex="-1"/> 1.24 + <button id="t6" label="Three" tabindex="0"/> 1.25 + <checkbox id="t1" label="Four" tabindex="1"/> 1.26 +</hbox> 1.27 +<hbox> 1.28 + <textbox id="t7" idmod="t3" size="3"/> 1.29 + <textbox id="no2" size="3" tabindex="-1"/> 1.30 + <textbox id="t8" idmod="t4" size="3" tabindex="0"/> 1.31 + <textbox id="t2" idmod="t1" size="3" tabindex="1"/> 1.32 +</hbox> 1.33 +<hbox> 1.34 + <button id="no3" style="-moz-user-focus: ignore;" label="One"/> 1.35 + <checkbox id="no4" style="-moz-user-focus: ignore;" label="Two" tabindex="-1"/> 1.36 + <button id="t9" style="-moz-user-focus: ignore;" label="Three" tabindex="0"/> 1.37 + <checkbox id="t3" style="-moz-user-focus: ignore;" label="Four" tabindex="1"/> 1.38 +</hbox> 1.39 +<hbox> 1.40 + <textbox id="t10" idmod="t5" style="-moz-user-focus: ignore;" size="3"/> 1.41 + <textbox id="no5" style="-moz-user-focus: ignore;" size="3" tabindex="-1"/> 1.42 + <textbox id="t11" idmod="t6" style="-moz-user-focus: ignore;" size="3" tabindex="0"/> 1.43 + <textbox id="t4" idmod="t2" style="-moz-user-focus: ignore;" size="3" tabindex="1"/> 1.44 +</hbox> 1.45 +<listbox id="t12" idmod="t7"> 1.46 + <listitem label="Item One"/> 1.47 +</listbox> 1.48 + 1.49 +<hbox> 1.50 + <!-- the tabindex attribute does not apply to non-controls, so it 1.51 + should be treated as -1 for non-focusable dropmarkers, and 0 1.52 + for focusable dropmarkers. Thus, the first four dropmarkers 1.53 + are not in the tab order, and the last four dropmarkers should 1.54 + be in the tab order just after the listbox above. 1.55 + --> 1.56 + <dropmarker id="no6"/> 1.57 + <dropmarker id="no7" tabindex="-1"/> 1.58 + <dropmarker id="no8" tabindex="0"/> 1.59 + <dropmarker id="no9" tabindex="1"/> 1.60 + <dropmarker id="t13" style="-moz-user-focus: normal;"/> 1.61 + <dropmarker id="t14" style="-moz-user-focus: normal;" tabindex="-1"/> 1.62 + <dropmarker id="t15" style="-moz-user-focus: normal;" tabindex="0"/> 1.63 + <dropmarker id="t16" style="-moz-user-focus: normal;" tabindex="1"/> 1.64 +</hbox> 1.65 + 1.66 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.67 +<p id="display"></p> 1.68 +<div id="content" style="display: none"> 1.69 +</div> 1.70 +<pre id="test"> 1.71 +</pre> 1.72 +</body> 1.73 + 1.74 +<script> 1.75 +<![CDATA[ 1.76 + 1.77 +SimpleTest.waitForExplicitFinish(); 1.78 + 1.79 +var gAdjustedTabFocusModel = false; 1.80 +var gTestCount = 16; 1.81 +var gTestsOccurred = 0; 1.82 + 1.83 +function runTests() 1.84 +{ 1.85 + var t; 1.86 + window.addEventListener("focus", function (event) { 1.87 + if (t == 1 && event.target.id == "t2") { 1.88 + // looks to be using the MacOSX Full Keyboard Access set to Textboxes 1.89 + // and lists only so use the idmod attribute instead 1.90 + gAdjustedTabFocusModel = true; 1.91 + gTestCount = 7; 1.92 + } 1.93 + 1.94 + var attrcompare = gAdjustedTabFocusModel ? "idmod" : "id"; 1.95 + 1.96 + // check for the last test which should wrap aorund to the first item 1.97 + // consider the focus event on the inner input of textboxes instead 1.98 + if (event.originalTarget.localName == "input") { 1.99 + is(document.getBindingParent(event.originalTarget).getAttribute(attrcompare), 1.100 + "t" + t, "tab " + t + " to inner input"); 1.101 + gTestsOccurred++; 1.102 + } 1.103 + else { 1.104 + is(event.target.getAttribute(attrcompare), "t" + t, "tab " + t + " to " + event.target.localName) 1.105 + if (event.target.localName != "textbox") 1.106 + gTestsOccurred++; 1.107 + } 1.108 + }, true); 1.109 + 1.110 + for (t = 1; t <= gTestCount; t++) 1.111 + synthesizeKey("VK_TAB", { }); 1.112 + 1.113 + is(gTestsOccurred, gTestCount, "test count"); 1.114 + SimpleTest.finish(); 1.115 +} 1.116 + 1.117 +SimpleTest.waitForFocus(runTests); 1.118 + 1.119 +]]> 1.120 + 1.121 +</script> 1.122 + 1.123 +</window>