summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-toggle/toggle-trigger-focus.tentative.html
blob: bc93ba3631bd348848d621b00c43f41a412d358d (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
52
53
54
<!DOCTYPE HTML>
<meta charset="UTF-8">
<title>CSS Toggles: focusability of elements with toggle-trigger</title>
<link rel="author" title="L. David Baron" href="https://dbaron.org/">
<link rel="author" title="Google" href="http://www.google.com/">
<link rel="help" href="https://tabatkins.github.io/css-toggle/#toggle-trigger-property">
<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="support/toggle-helpers.js"></script>

<div id="test"></div>

<script>

// From shadow-dom/focus/resources/shadow-utils.js
function navigateFocusForward() {
  // TAB = '\ue004'
  return test_driver.send_keys(document.body, "\ue004");
}

let container = document.getElementById("test");

promise_test(async test => {
  container.innerHTML = `
    <input id="input" type="text">
    <div id="e1" style="toggle-root: tab"></div>
    <div id="e2" style="toggle-trigger: tab"></div>
    <div id="e3" style="toggle-trigger: tab"></div>
    <div id="e4" style="toggle-trigger: nonexistent"></div>
  `;

  let input = document.getElementById("input");
  let e1 = document.getElementById("e1");
  let e2 = document.getElementById("e2");
  let e3 = document.getElementById("e3");
  let e4 = document.getElementById("e4");

  await wait_for_toggle_creation(e1);
  input.focus();
  assert_equals(document.activeElement, input);

  await navigateFocusForward();
  assert_equals(document.activeElement, e2);

  await navigateFocusForward();
  assert_equals(document.activeElement, e3);

  await navigateFocusForward();
  assert_equals(document.activeElement, e4);
}, "elements with toggle-trigger are tabbable");

</script>