summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/states/test_selects.html
blob: 0029fcbe492dffb932ee222bb81db1badb6e30db (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<html>

<head>
  <title>HTML selects accessible states tests</title>
  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <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="../role.js"></script>
  <script type="application/javascript"
          src="../states.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>

  <script type="application/javascript">
    function openComboboxNCheckStates(aID)
    {
      this.combobox = getAccessible(aID);
      this.comboboxList = this.combobox.firstChild;
      this.comboboxOption = this.comboboxList.firstChild;

      this.eventSeq = [
        new invokerChecker(EVENT_FOCUS, this.comboboxOption)
      ];

      this.invoke = function openComboboxNCheckStates_invoke()
      {
        getNode(aID).focus();
        synthesizeKey("VK_DOWN", { altKey: true });
      }

      this.finalCheck = function openComboboxNCheckStates_invoke()
      {
        // Expanded state on combobox.
        testStates(this.combobox, STATE_EXPANDED);

        // Floating state on combobox list.
        testStates(this.comboboxList, STATE_FLOATING);
      }

      this.getID = function openComboboxNCheckStates_getID()
      {
        return "open combobox and test states";
      }
    }

    //gA11yEventDumpToConsole = true;

    var gQueue = null;
    function doTest()
    {
      // combobox
      var combobox = getAccessible("combobox");
      testStates(combobox,
                 STATE_HASPOPUP | STATE_COLLAPSED | STATE_FOCUSABLE, 0,
                 STATE_FOCUSED, 0);

      var comboboxList = combobox.firstChild;
      testStates(comboboxList, STATE_INVISIBLE, 0, STATE_FOCUSABLE, 0);

      var opt1 = comboboxList.firstChild;
      testStates(opt1, STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
                 EXT_STATE_ACTIVE, STATE_FOCUSED, 0);

      var opt2 = comboboxList.lastChild;
      testStates(opt2, STATE_SELECTABLE | STATE_FOCUSABLE, 0, STATE_SELECTED, 0,
                 STATE_FOCUSED, EXT_STATE_ACTIVE);

      // collapsed combobox
      testStates("collapsedcombobox",
                 STATE_COLLAPSED | STATE_FOCUSABLE, 0,
                 STATE_FOCUSED, 0);

      testStates("collapsed-1",
                 STATE_FOCUSABLE | STATE_SELECTABLE, 0,
                 STATE_OFFSCREEN | STATE_INVISIBLE, 0);

      testStates("collapsed-2",
                 STATE_OFFSCREEN, 0,
                 STATE_INVISIBLE, 0);

      // listbox
      testStates("listbox",
                 STATE_FOCUSABLE, 0,
                 STATE_HASPOPUP | STATE_COLLAPSED | STATE_FOCUSED);

      testStates("listitem-active",
                 STATE_FOCUSABLE | STATE_SELECTABLE, EXT_STATE_ACTIVE,
                 STATE_SELECTED | STATE_FOCUSED);

      testStates("listitem",
                 STATE_FOCUSABLE | STATE_SELECTABLE, 0,
                 STATE_SELECTED | STATE_FOCUSED, EXT_STATE_ACTIVE);

      testStates("listitem-disabled",
                 STATE_UNAVAILABLE, 0,
                 STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
                 EXT_STATE_ACTIVE);

      testStates("listgroup",
                 0, 0,
                 STATE_UNAVAILABLE | STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
                 EXT_STATE_ACTIVE);

      testStates("listgroup-disabled",
                 STATE_UNAVAILABLE, 0,
                 STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
                 EXT_STATE_ACTIVE);

      todo(false, "no unavailable state on option in disabled group (bug 759666)");
//      testStates("listitem-disabledgroup",
//                 STATE_UNAVAILABLE, 0,
//                 STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
//                 EXT_STATE_ACTIVE);

      testStates("listbox-disabled",
                 STATE_UNAVAILABLE, 0,
                 STATE_FOCUSABLE);

      todo(false, "no unavailable state on option in disabled select (bug 759666)");
//      testStates("listitem-disabledlistbox",
//                 STATE_UNAVAILABLE, 0,
//                 STATE_SELECTABLE | STATE_SELECTED | STATE_FOCUSABLE,
//                 EXT_STATE_ACTIVE);

      // open combobox
      gQueue = new eventQueue();
      gQueue.push(new openComboboxNCheckStates("combobox"));
      gQueue.invoke(); // Will call */SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>

</head>

<body>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=443889"
     title="mochitest for selects and lists">
    Mozilla Bug 443889
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=640716"
     title="mochitest for selects and lists">
    Mozilla Bug 640716
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=689847"
     title="Expose active state on current item of selectable widgets">
    Mozilla Bug 689847
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=756983"
     title="Isolate focusable and unavailable states from State()">
    Mozilla Bug 756983
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=907682"
     title=" HTML:option group position is not correct when select is collapsed">
    Mozilla Bug 907682
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <select id="combobox">
    <option>item 1</option>
    <option>item 2</option>
  </select>

  <select id="collapsedcombobox">
    <option id="collapsed-1">item 1</option>
    <option id="collapsed-2">item 2</option>
  </select>

  <select id="listbox" name="component" size="3">
    <option id="listitem-active">Build</option>
    <option id="listitem">Disability Access APIs</option>
    <option id="listitem-disabled" disabled>General</option>
    <optgroup id="listgroup" label="group">
      <option>option</option>
    </optgroup>
    <optgroup id="listgroup-disabled" disabled label="group2">
      <option id="listitem-disabledgroup">UI</option>
    </optgroup>
  </select>

  <select id="listbox-disabled" size="3" disabled>
    <option id="listitem-disabledlistbox">option</option>
  </select>

</body>
</html>