summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/relations/test_bindings.xhtml
blob: 65a7a08752cb9dd4c69845bf188e9287a14afc8a (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>Accessible relations for bindings</title>

  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <style>
    .button {
      -moz-binding: url('#custombutton');
    }

    .button2 {
      -moz-binding: url('#custombutton2');
    }
  </style>

  <bindings xmlns="http://www.mozilla.org/xbl">
    <binding id="custombutton">
      <content aria-labelledby="button.label label">
        <label xmlns="http://www.w3.org/1999/xhtml" anonid="button.label">
          anon label
        </label>
        <button xmlns="http://www.w3.org/1999/xhtml" anonid="button.button"
                aria-labelledby="button.label label">
          a button
        </button>
        <div xmlns="http://www.w3.org/1999/xhtml"
             anonid="button.button2" class="button2"
             aria-labelledby="button.label"></div>
        <div xmlns="http://www.w3.org/1999/xhtml"
             anonid="button.button3" class="button2"></div>
      </content>
    </binding>
    <binding id="custombutton2">
      <content aria-labelledby="button2.label">
        <label xmlns="http://www.w3.org/1999/xhtml" anonid="button2.label">
          nested anon label
        </label>
      </content>
    </binding>
  </bindings>

  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>

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

  <script type="application/javascript">
    function doTests()
    {
      var button = document.getElementById("button");
      var anonLabel = document.
        getAnonymousElementByAttribute(button, "anonid", "button.label");
      var anonButton = document.
        getAnonymousElementByAttribute(button, "anonid", "button.button");
      var anonButton2 = document.
        getAnonymousElementByAttribute(button, "anonid", "button.button2");
      var anonButton3 = document.
        getAnonymousElementByAttribute(button, "anonid", "button.button3");
      var anonAnonLabel = document.
        getAnonymousElementByAttribute(anonButton3, "anonid", "button2.label");

      testRelation("label", RELATION_LABEL_FOR, button);
      testRelation(anonLabel, RELATION_LABEL_FOR, [button, anonButton, anonButton2]);
      testRelation(button, RELATION_LABELLED_BY, [anonLabel, "label"]);
      testRelation(anonButton, RELATION_LABELLED_BY, anonLabel);
      testRelation(anonButton2, RELATION_LABELLED_BY, anonLabel);
      testRelation(anonButton3, RELATION_LABELLED_BY, anonAnonLabel);
      testRelation(anonAnonLabel, RELATION_LABEL_FOR, anonButton3);

      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTests);
  </script>
</head>

<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=421242"
     title="Allow relations in anonymous content for binding parent">
    Mozilla Bug 421242
  </a>

  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>
  <div id="eventdump"></div>

  <label id="label">explicit label</label>
  <div id="button" class="button"></div>
</body>
</html>