tor-browser

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

dialog-focusing-steps-inert.html (1539B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Test focusing steps when dialog is inert</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 </head>
      8 <body>
      9 <input id="outer-input">
     10 <dialog>
     11  <input autofocus>
     12 </dialog>
     13 <script>
     14 function test_focusing_steps_with_inert_dialog(test, isModal) {
     15  const outerInput = document.querySelector("#outer-input");
     16  outerInput.focus();
     17  assert_equals(document.activeElement, outerInput,
     18    "Focus should be on element we just focused");
     19 
     20  const dialog = document.querySelector("dialog");
     21  assert_false(dialog.open, "Dialog should initially be closed");
     22 
     23  dialog.inert = true;
     24  test.add_cleanup(() => { dialog.inert = false; });
     25 
     26  if (isModal) {
     27    dialog.showModal();
     28    test.add_cleanup(() => { dialog.close(); });
     29    assert_equals(document.activeElement, document.body,
     30      "dialog.showModal(): focusing steps should apply focus fixup rule when dialog is inert");
     31  } else {
     32    dialog.show();
     33    test.add_cleanup(() => { dialog.close(); });
     34    assert_equals(document.activeElement, outerInput,
     35      "dialog.show(): focusing steps should not change focus when dialog is inert");
     36  }
     37 }
     38 
     39 test(function() {
     40  test_focusing_steps_with_inert_dialog(this, false);
     41 }, "dialog.show(): focusing steps should not change focus when dialog is inert");
     42 
     43 test(function() {
     44  test_focusing_steps_with_inert_dialog(this, true);
     45 }, "dialog.showModal(): focusing steps should apply focus fixup rule when dialog is inert");
     46 </script>
     47 </body>
     48 </html>