tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_xul_tabindex_focus.xhtml (1403B)


      1 <?xml version="1.0"?>
      2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
      3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
      4 <!--
      5 https://bugzilla.mozilla.org/show_bug.cgi?id=1128054
      6 -->
      7 <window title="Mozilla Bug 1128054"
      8        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
      9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     10 <body>
     11 <!-- Test default focusability -->
     12 <label></label>
     13 <!-- Test tabindex=0 focusability -->
     14 <label tabindex="0"></label>
     15 <!-- Test tabindex=-1 focusability -->
     16 <label tabindex="-1"></label>
     17 <!-- Test tabindex=invalid focusability -->
     18 <label tabindex="invalid"></label>
     19 <!-- Tests code -->
     20 <script type="application/javascript">
     21 <![CDATA[
     22 
     23 /** Test for Bug 1128054 */
     24 
     25 add_task(function test_xul_tabindex_focus() {
     26  for (let element of document.querySelectorAll("label")) {
     27    let desc = "xul element";
     28    let focusable = false;
     29    if (element.hasAttribute("tabindex")) {
     30      let attr = element.getAttribute("tabindex");
     31      focusable = Number.isInteger(Number.parseInt(attr));
     32      desc += ` with tabindex=${attr}`;
     33    }
     34 
     35    element.focus();
     36    focusable ? is(document.activeElement, element, desc + " should focusable")
     37              : isnot(document.activeElement, element, desc + " should not focusable");
     38  }
     39 });
     40 
     41 ]]>
     42 </script>
     43 </body>
     44 </window>