tor-browser

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

dialog-focusing-steps-disconnected.html (1274B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Test focusing steps when dialog is disconnected</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 </head>
      8 <body>
      9 <input>
     10 <script>
     11 test(function() {
     12  const outerInput = document.querySelector("input");
     13  outerInput.focus();
     14  assert_equals(document.activeElement, outerInput,
     15    "Focus should be on element we just focused");
     16 
     17  const dialog = document.createElement("dialog");
     18  assert_false(dialog.open, "Dialog should initially be closed");
     19  assert_false(dialog.hasAttribute('open'), "Dialog should initially be closed");
     20 
     21  const innerInput = document.createElement("input");
     22  innerInput.autofocus = true;
     23  dialog.append(innerInput);
     24 
     25  dialog.show();
     26  this.add_cleanup(() => { dialog.close(); });
     27  assert_true(dialog.open, "Disconnected dialog can still be open");
     28 
     29 
     30  assert_equals(document.activeElement, outerInput, "Focusing steps should not change focus");
     31 }, "dialog.show(): focusing steps should not change focus on disconnected <dialog>");
     32 
     33 test(function() {
     34  assert_throws_dom("InvalidStateError", () => {
     35    document.createElement("dialog").showModal();
     36  });
     37 }, "dialog.showModal() should throw on disconnected <dialog>");
     38 </script>
     39 </body>
     40 </html>