tor-browser

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

first-when-later.html (940B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>The first autofocus in the document wins, even if elements are inserted later</title>
      4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#autofocusing-a-form-control:-the-autofocus-attribute">
      5 <link rel="author" title="Domenic Denicola" href="d@domenic.me">
      6 
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <script src="resources/utils.js"></script>
     10 
     11 <input autofocus>
     12 
     13 <script>
     14 "use strict";
     15 
     16 promise_test(async () => {
     17  const input1 = document.querySelector("input");
     18  const input2 = document.createElement("input");
     19  input2.autofocus = true;
     20  document.body.appendChild(input2);
     21 
     22  await waitUntilStableAutofocusState();
     23  assert_equals(document.activeElement, input1);
     24  assert_not_equals(document.activeElement, input2);
     25 }, 'The first autofocus in the document wins, even if elements are inserted later.');
     26 </script>