summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/focus-navigation/focus-nested-slots.html
blob: 747a8a1262fad5ad9e06bc6b1f7d547009df0344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1209217">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="resources/shadow-dom.js"></script>
<script src="resources/focus-utils.js"></script>

<button id=button1>one</button>
<span>
  <template shadowroot=open>
    <slot name=myslot></slot>
  </template>
  <slot slot=myslot>
    <button id=button2>two</button>
    <button id=button3>three</button>
    <button id=button4>four</button>
  </slot>
</span>
<button id=button5>five</button>

<script>

promise_test(async () => {
  convertDeclarativeTemplatesToShadowRootsWithin(document);
  button1.focus();
  assert_equals(document.activeElement, button1);

  await navigateFocusForward();
  assert_equals(document.activeElement, button2);
  await navigateFocusForward();
  assert_equals(document.activeElement, button3);
  await navigateFocusForward();
  assert_equals(document.activeElement, button4);
  await navigateFocusForward();
  assert_equals(document.activeElement, button5);
  await navigateFocusBackward();
  assert_equals(document.activeElement, button4);
  await navigateFocusBackward();
  assert_equals(document.activeElement, button3);
  await navigateFocusBackward();
  assert_equals(document.activeElement, button2);
  await navigateFocusBackward();
  assert_equals(document.activeElement, button1);
}, `Verifies that focus order goes in flat tree order with buttons inside nested slots which have a mixture of assigned and unassigned states.`);

</script>