tor-browser

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

document-with-fragment-valid.html (2020B)


      1 <!DOCTYPE html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <script src="resources/utils.js"></script>
      5 
      6 <iframe src="resources/frame-with-anchor.html"></iframe>
      7 
      8 <script>
      9 'use strict';
     10 
     11 promise_test(async () => {
     12  await waitForLoad(window);
     13  const iframe = document.querySelector('iframe');
     14  iframe.contentWindow.location.hash = 'anchor1';
     15  await waitForEvent(iframe.contentWindow, 'hashchange');
     16  const doc = iframe.contentDocument;
     17  assert_true(!!doc.querySelector(':target'));
     18 
     19  let input = doc.createElement('input');
     20  input.autofocus = true;
     21  doc.body.appendChild(input);
     22  await waitUntilStableAutofocusState();
     23  assert_not_equals(doc.activeElement, input);
     24  iframe.remove();
     25 }, 'Autofocus elements in iframed documents with URL fragments should be skipped. (id matches)');
     26 
     27 promise_test(async () => {
     28  let iframe = await waitForIframeLoad("resources/frame-with-a.html");
     29  iframe.contentWindow.location.hash = 'anchor1';
     30  await waitForEvent(iframe.contentWindow, 'hashchange');
     31  const doc = iframe.contentDocument;
     32  assert_true(!!doc.querySelector(':target'));
     33 
     34  let input = doc.createElement('input');
     35  input.autofocus = true;
     36  doc.body.appendChild(input);
     37  await waitUntilStableAutofocusState();
     38  assert_not_equals(doc.activeElement, input);
     39  iframe.remove();
     40 }, 'Autofocus elements in iframed documents with URL fragments should be skipped.(a element)');
     41 
     42 promise_test(async () => {
     43  let w = window.open('resources/frame-with-anchor.html');
     44  await waitForLoad(w);
     45  w.location.hash = 'anchor1';
     46  await waitForEvent(w, 'hashchange');
     47  const doc = w.document;
     48  assert_true(!!doc.querySelector(':target'));
     49 
     50  let input = doc.createElement('input');
     51  input.autofocus = true;
     52  doc.body.appendChild(input);
     53  await waitUntilStableAutofocusState();
     54  assert_not_equals(doc.activeElement, input);
     55  w.close();
     56 }, 'Autofocus elements in top-level browsing context\'s documents with URL fragments should be skipped.');
     57 </script>