summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/relations/test_shadowdom.html
blob: adb9490d99d10cc400b6fdbe97d704ad27ccd89f (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
55
56
57
58
<html>

<head>
  <title>Explicit content and shadow DOM content relations tests</title>
  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../relations.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>

  <script type="application/javascript">
    function doTest() {
      // explicit content
      let label = document.getElementById("label");
      let element = document.getElementById("element");
      testRelation(label, RELATION_LABEL_FOR, element);
      testRelation(element, RELATION_LABELLED_BY, label);

      // shadow DOM content
      let shadowRoot = document.getElementById("shadowcontainer").shadowRoot;
      let shadowLabel = shadowRoot.getElementById("label");
      let shadowElement = shadowRoot.getElementById("element");

      testRelation(shadowLabel, RELATION_LABEL_FOR, shadowElement);
      testRelation(shadowElement, RELATION_LABELLED_BY, shadowLabel);

      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();

    addA11yLoadEvent(doTest, window);
  </script>
</head>

<body>
  <p id="display"></p>
  <div id="content">
    <div id="label"></div>
    <div id="element" aria-labelledby="label"></div>
    <div id="shadowcontainer"></div>
    <script>
      let shadowRoot = document.getElementById("shadowcontainer").
        attachShadow({mode: "open"});
      shadowRoot.innerHTML =
        `<div id="label"></div><div id="element" aria-labelledby="label"></div>`;
    </script>
  </div>
  <pre id="test">
  </pre>
</body>
</html>