tor-browser

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

focus-tabindex-order-shadow-varying-tabindex-2.html (2316B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML Test: focus - the sequential focus navigation order with shadow dom with varying tabindex values</title>
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/resources/testdriver.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 <script src="resources/shadow-utils.js"></script>
     10 <body>
     11 <script>
     12 promise_test(async () => {
     13  function createButtonInShadowDOM(host) {
     14    const root = host.attachShadow({mode: "open"});
     15    root.innerHTML = "<input>";
     16    document.body.appendChild(host);
     17    return root;
     18  }
     19  const host1 = document.createElement("div");
     20  const root1 = createButtonInShadowDOM(host1);
     21 
     22  const forwarder = document.createElement("div");
     23  forwarder.setAttribute("tabindex", 0);
     24  document.body.appendChild(forwarder);
     25 
     26  const host2 = document.createElement("div");
     27  host2.setAttribute("tabindex", -1);
     28  const root2 = createButtonInShadowDOM(host2);
     29 
     30  const host3 = document.createElement("div");
     31  const root3 = createButtonInShadowDOM(host3);
     32 
     33  root1.querySelector("input").focus();
     34 
     35  let forwarderFocused = false;
     36  forwarder.addEventListener("focus", () => {
     37    forwarderFocused = true;
     38    root2.querySelector("input").focus();
     39  });
     40 
     41  // Structure:
     42  // <div #host1></div>
     43  //   #ShadowRoot
     44  //     <button>Button</button>
     45  // <div #forwarder tabindex=0></div>
     46  // <div #host2 tabindex=-1></div>
     47  //   #ShadowRoot
     48  //     <button>Button</button>
     49  // <div #host3></div>
     50  //   #ShadowRoot
     51  //     <button>Button</button>
     52  assert_equals(document.activeElement, host1);
     53  assert_equals(root1.activeElement, root1.querySelector("input"));
     54 
     55  await navigateFocusForward();
     56  assert_true(forwarderFocused);
     57  assert_equals(document.activeElement, host2);
     58  assert_equals(root2.activeElement, root2.querySelector("input"));
     59 
     60  // In buggy Firefox build, the following focus navigation will
     61  // move the focus back to #host1's button.
     62  await navigateFocusForward();
     63  assert_equals(document.activeElement, host3);
     64  assert_equals(root3.activeElement, root3.querySelector("input"));
     65 }, "Order with different tabindex on host")
     66 </script>