tor-browser

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

change-focus-back-to-origial-during-intercept.html (1202B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <body>
      5 <script>
      6 promise_test(async t => {
      7  let intercept_resolve;
      8  navigation.addEventListener("navigate", e => {
      9    e.intercept({ handler: () => new Promise(resolve => intercept_resolve = resolve),
     10                  focusReset: "after-transition" });
     11  }, { once: true });
     12 
     13  const button = document.body.appendChild(document.createElement("button"));
     14  const button2 = document.body.appendChild(document.createElement("button"));
     15  button2.tabIndex = 0;
     16  t.add_cleanup(() => {
     17    button.remove();
     18    button2.remove();
     19  });
     20 
     21  assert_equals(document.activeElement, document.body, "Start on body");
     22  button.focus();
     23  assert_equals(document.activeElement, button, "focus() worked");
     24 
     25  const finished = navigation.navigate("#1").finished;
     26  button2.focus();
     27  assert_equals(document.activeElement, button2, "focus() worked");
     28  button.focus();
     29  assert_equals(document.activeElement, button, "focus() worked");
     30 
     31  intercept_resolve();
     32  await finished;
     33  assert_equals(document.activeElement, button, "Focus was not reset after the transition");
     34 }, "");
     35 </script>
     36 </body>