toolkit/content/tests/chrome/test_tabindex.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 4 <!--
michael@0 5 XUL Widget Test for tabindex
michael@0 6 -->
michael@0 7 <window title="tabindex" width="500" height="600"
michael@0 8 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
michael@0 9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 11
michael@0 12 <!--
michael@0 13 Elements are navigated in the following order:
michael@0 14 1. tabindex > 0 in tree order
michael@0 15 2. tabindex = 0 in tree order
michael@0 16 Elements with tabindex = -1 are not in the tab order
michael@0 17 -->
michael@0 18 <hbox>
michael@0 19 <button id="t5" label="One"/>
michael@0 20 <checkbox id="no1" label="Two" tabindex="-1"/>
michael@0 21 <button id="t6" label="Three" tabindex="0"/>
michael@0 22 <checkbox id="t1" label="Four" tabindex="1"/>
michael@0 23 </hbox>
michael@0 24 <hbox>
michael@0 25 <textbox id="t7" idmod="t3" size="3"/>
michael@0 26 <textbox id="no2" size="3" tabindex="-1"/>
michael@0 27 <textbox id="t8" idmod="t4" size="3" tabindex="0"/>
michael@0 28 <textbox id="t2" idmod="t1" size="3" tabindex="1"/>
michael@0 29 </hbox>
michael@0 30 <hbox>
michael@0 31 <button id="no3" style="-moz-user-focus: ignore;" label="One"/>
michael@0 32 <checkbox id="no4" style="-moz-user-focus: ignore;" label="Two" tabindex="-1"/>
michael@0 33 <button id="t9" style="-moz-user-focus: ignore;" label="Three" tabindex="0"/>
michael@0 34 <checkbox id="t3" style="-moz-user-focus: ignore;" label="Four" tabindex="1"/>
michael@0 35 </hbox>
michael@0 36 <hbox>
michael@0 37 <textbox id="t10" idmod="t5" style="-moz-user-focus: ignore;" size="3"/>
michael@0 38 <textbox id="no5" style="-moz-user-focus: ignore;" size="3" tabindex="-1"/>
michael@0 39 <textbox id="t11" idmod="t6" style="-moz-user-focus: ignore;" size="3" tabindex="0"/>
michael@0 40 <textbox id="t4" idmod="t2" style="-moz-user-focus: ignore;" size="3" tabindex="1"/>
michael@0 41 </hbox>
michael@0 42 <listbox id="t12" idmod="t7">
michael@0 43 <listitem label="Item One"/>
michael@0 44 </listbox>
michael@0 45
michael@0 46 <hbox>
michael@0 47 <!-- the tabindex attribute does not apply to non-controls, so it
michael@0 48 should be treated as -1 for non-focusable dropmarkers, and 0
michael@0 49 for focusable dropmarkers. Thus, the first four dropmarkers
michael@0 50 are not in the tab order, and the last four dropmarkers should
michael@0 51 be in the tab order just after the listbox above.
michael@0 52 -->
michael@0 53 <dropmarker id="no6"/>
michael@0 54 <dropmarker id="no7" tabindex="-1"/>
michael@0 55 <dropmarker id="no8" tabindex="0"/>
michael@0 56 <dropmarker id="no9" tabindex="1"/>
michael@0 57 <dropmarker id="t13" style="-moz-user-focus: normal;"/>
michael@0 58 <dropmarker id="t14" style="-moz-user-focus: normal;" tabindex="-1"/>
michael@0 59 <dropmarker id="t15" style="-moz-user-focus: normal;" tabindex="0"/>
michael@0 60 <dropmarker id="t16" style="-moz-user-focus: normal;" tabindex="1"/>
michael@0 61 </hbox>
michael@0 62
michael@0 63 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 64 <p id="display"></p>
michael@0 65 <div id="content" style="display: none">
michael@0 66 </div>
michael@0 67 <pre id="test">
michael@0 68 </pre>
michael@0 69 </body>
michael@0 70
michael@0 71 <script>
michael@0 72 <![CDATA[
michael@0 73
michael@0 74 SimpleTest.waitForExplicitFinish();
michael@0 75
michael@0 76 var gAdjustedTabFocusModel = false;
michael@0 77 var gTestCount = 16;
michael@0 78 var gTestsOccurred = 0;
michael@0 79
michael@0 80 function runTests()
michael@0 81 {
michael@0 82 var t;
michael@0 83 window.addEventListener("focus", function (event) {
michael@0 84 if (t == 1 && event.target.id == "t2") {
michael@0 85 // looks to be using the MacOSX Full Keyboard Access set to Textboxes
michael@0 86 // and lists only so use the idmod attribute instead
michael@0 87 gAdjustedTabFocusModel = true;
michael@0 88 gTestCount = 7;
michael@0 89 }
michael@0 90
michael@0 91 var attrcompare = gAdjustedTabFocusModel ? "idmod" : "id";
michael@0 92
michael@0 93 // check for the last test which should wrap aorund to the first item
michael@0 94 // consider the focus event on the inner input of textboxes instead
michael@0 95 if (event.originalTarget.localName == "input") {
michael@0 96 is(document.getBindingParent(event.originalTarget).getAttribute(attrcompare),
michael@0 97 "t" + t, "tab " + t + " to inner input");
michael@0 98 gTestsOccurred++;
michael@0 99 }
michael@0 100 else {
michael@0 101 is(event.target.getAttribute(attrcompare), "t" + t, "tab " + t + " to " + event.target.localName)
michael@0 102 if (event.target.localName != "textbox")
michael@0 103 gTestsOccurred++;
michael@0 104 }
michael@0 105 }, true);
michael@0 106
michael@0 107 for (t = 1; t <= gTestCount; t++)
michael@0 108 synthesizeKey("VK_TAB", { });
michael@0 109
michael@0 110 is(gTestsOccurred, gTestCount, "test count");
michael@0 111 SimpleTest.finish();
michael@0 112 }
michael@0 113
michael@0 114 SimpleTest.waitForFocus(runTests);
michael@0 115
michael@0 116 ]]>
michael@0 117
michael@0 118 </script>
michael@0 119
michael@0 120 </window>

mercurial