tor-browser

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

supported-elements.html (3242B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script src="resources/utils.js"></script>
      6 <script>
      7 "use strict";
      8 
      9 promise_test(async t => {
     10  let w = window.open('/common/blank.html');
     11  await waitForLoad(w);
     12  t.add_cleanup(() => { w.close(); });
     13  w.document.body.innerHTML = '<div contenteditable=true autofocus></div>';
     14  await waitUntilStableAutofocusState(w);
     15  assert_equals(w.document.activeElement.tagName, 'DIV');
     16 }, 'Contenteditable element should support autofocus');
     17 
     18 promise_test(async t => {
     19  let w = window.open('/common/blank.html');
     20  await waitForLoad(w);
     21  t.add_cleanup(() => { w.close(); });
     22  w.document.body.innerHTML = '<span tabindex=0 autofocus></span>';
     23  await waitUntilStableAutofocusState(w);
     24  assert_equals(w.document.activeElement.tagName, 'SPAN');
     25 }, 'Element with tabindex should support autofocus');
     26 
     27 promise_test(async t => {
     28  let w = window.open('/common/blank.html');
     29  await waitForLoad(w);
     30  t.add_cleanup(() => { w.close(); });
     31  let element = w.document.createElementNS('uri1', 'prefix:local');
     32  element.setAttribute('autofocus', '');
     33  w.document.body.appendChild(element);
     34  await waitUntilStableAutofocusState(w);
     35  assert_equals(w.document.activeElement.tagName, 'BODY');
     36 }, 'Non-HTMLElement should not support autofocus');
     37 
     38 promise_test(async t => {
     39  let w = window.open('/common/blank.html');
     40  await waitForLoad(w);
     41  t.add_cleanup(() => { w.close(); });
     42  const host = w.document.createElement('div');
     43  host.autofocus = true;
     44  const shadow = host.attachShadow({mode:'closed', delegatesFocus:true});
     45  shadow.appendChild(w.document.createElement('input'));
     46  w.document.body.appendChild(host);
     47  await waitUntilStableAutofocusState(w);
     48  assert_equals(w.document.activeElement, host);
     49  assert_equals(shadow.activeElement.tagName, 'INPUT');
     50 }, 'Host element with delegatesFocus should support autofocus');
     51 
     52 promise_test(async t => {
     53  let w = window.open('/common/blank.html');
     54  await waitForLoad(w);
     55  t.add_cleanup(() => { w.close(); });
     56  const host = w.document.createElement('div');
     57  host.autofocus = true;
     58  host.attachShadow({mode:'closed', delegatesFocus:true});
     59  w.document.body.appendChild(host);
     60  const next = w.document.createElement('input');
     61  next.autofocus = true;
     62  w.document.body.appendChild(next);
     63  await waitUntilStableAutofocusState(w);
     64  assert_equals(w.document.activeElement, next);
     65 }, 'Host element with delegatesFocus including no focusable descendants should be skipped');
     66 
     67 promise_test(async t => {
     68  let w = window.open('./resources/imagemap.html');
     69  await waitForLoad(w);
     70  t.add_cleanup(() => { w.close(); });
     71  const area = w.document.createElement('area');
     72  area.autofocus = true;
     73  area.shape = 'rect';
     74  area.coords = '1,1,99,99';
     75  area.href = '/common/blank.html';
     76  w.document.querySelector('map').appendChild(area);
     77  await waitUntilStableAutofocusState(w);
     78  // According to the specification, DOM anchor for an AREA shape is an IMG
     79  // element, but major browsers don't follow it.
     80  // See https://github.com/whatwg/html/issues/5054
     81  assert_equals(w.document.activeElement, area);
     82 }, 'Area element should support autofocus');
     83 </script>