summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/attributes/test_listbox.html
blob: 5489e74b748a63ee262bc58f46e969b547232a86 (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
<html>

<head>
  <title>Listbox group attribute tests</title>
  <meta charset="utf-8" />
  <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="../attributes.js"></script>
  <script type="application/javascript"
          src="../promisified-events.js"></script>

  <script type="application/javascript">
    async function doTest() {
      // First test the whole lot.
      testGroupAttrs("a", 1, 6);
      testGroupAttrs("b", 2, 6);
      testGroupAttrs("c", 3, 6);
      testGroupAttrs("d", 4, 6);
      testGroupAttrs("e", 5, 6);
      testGroupAttrs("f", 6, 6);
      // Remove c, reducing the set to 5.
      let listbox = getAccessible("listbox");
      let updated = waitForEvent(EVENT_REORDER, listbox);
      c.remove();
      await updated;
      testGroupAttrs("a", 1, 5);
      testGroupAttrs("b", 2, 5);
      testGroupAttrs("d", 3, 5);
      testGroupAttrs("e", 4, 5);
      testGroupAttrs("f", 5, 5);
      // Now, remove the first element.
      updated = waitForEvent(EVENT_REORDER, listbox);
      a.remove();
      await updated;
      testGroupAttrs("b", 1, 4);
      testGroupAttrs("d", 2, 4);
      testGroupAttrs("e", 3, 4);
      testGroupAttrs("f", 4, 4);
      // Remove the last item.
      updated = waitForEvent(EVENT_REORDER, listbox);
      f.remove();
      await updated;
      testGroupAttrs("b", 1, 3);
      testGroupAttrs("d", 2, 3);
      testGroupAttrs("e", 3, 3);
      // Finally, remove the middle item.
      updated = waitForEvent(EVENT_REORDER, listbox);
      d.remove();
      await updated;
      testGroupAttrs("b", 1, 2);
      testGroupAttrs("e", 2, 2);

      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
</head>
<body>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <!-- Group information updated after removal of list items, bug 1515186 -->
  <div id="listbox" role="listbox">
    <div id="a" role="option">Option a</div>
    <div id="b" role="option">Option b</div>
    <div id="c" role="option">Option c</div>
    <div id="d" role="option">Option d</div>
    <div id="e" role="option">Option e</div>
    <div id="f" role="option">Option f</div>
  </div>

</body>
</html>