tor-browser

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

restriction-focus.https.html (1372B)


      1 <!DOCTYPE html>
      2 <title>Prerendering documents are not focused</title>
      3 <meta name="timeout" content="long">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/common/utils.js"></script>
      7 <script src="/common/dispatcher/dispatcher.js"></script>
      8 <script src="../resources/utils.js"></script>
      9 <script src="resources/utils.js"></script>
     10 
     11 <body>
     12 <input type="text" id = "prerenderTextField">
     13 <script>
     14 setup(() => assertSpeculationRulesIsSupported());
     15 
     16 promise_test(async t => {
     17  document.getElementById('prerenderTextField').focus();
     18  assert_true(
     19      document.hasFocus(),
     20      'Initial document should have focus.');
     21 
     22  const {exec} = await create_prerendered_page(t);
     23  const result = await exec(() => {
     24    const element = document.createElement('input');
     25    element.setAttribute('type', 'text');
     26    document.body.appendChild(element);
     27    element.focus();
     28 
     29    // Post the focus and active states to the initiator page.
     30    return {
     31      activeElementUpdated: document.activeElement === element,
     32      documentHasFocus: document.hasFocus()
     33    };
     34  })
     35 
     36  assert_true(result.activeElementUpdated, 'Active element has been updated');
     37  assert_false(result.documentHasFocus, 'Document should not have focus');
     38 }, 'Prerendering document should update the active element but not have focus');
     39 </script>