summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/focus/delegatesFocus-tabindex-change.html
blob: f159c22164bb62064b62bc089faf5bd05cba555f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>
test(() => {
  const host = document.createElement('div');
  document.body.appendChild(host);

  const shadowRoot = host.attachShadow({mode: 'open', delegatesFocus: true});

  const shadowInput = document.createElement('input');
  shadowRoot.appendChild(shadowInput);

  host.focus();
  assert_equals(document.activeElement, host, 'The shadow host should be focused.');

  host.setAttribute('tabindex', '0');
  assert_equals(document.activeElement, host, 'The shadow host should remain focused after changing tabindex.');
}, 'Setting tabindex on the shadow host of a focused element with delegatesFocus should not change focus.');
</script>