summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/treeupdate/test_list_style.html
blob: 1d9e1c00ca6ff2fe2652ac909301894b23350b09 (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
<html>

<head>
  <title>Test hide/show events for HTMLListBulletAccessibles on list restyle</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="../name.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>
  <script type="application/javascript"
          src="../promisified-events.js"></script>

  <script type="application/javascript">
    /**
     * Change list style type to none.
     */
    async function hideBullet() {
      info("Hide bullet by setting style to none");

      let liAcc = getAccessible("list_element");
      let bullet = liAcc.firstChild;

      let events = waitForEvents([
        [EVENT_HIDE, bullet],
        [EVENT_REORDER, liAcc]
      ]);

      getNode("list").style.setProperty("list-style-type", "none");

      await events;

      is(liAcc.name, "list element",
          "Check that first child of LI is not a bullet.");

      dumpTree("list");
    }

    /**
     * Change list style type to circles.
     */
    async function showBullet() {
      info("Show bullet by setting style to circle");
      let liAcc = getAccessible("list_element");

      let events = waitForEvents([
        [EVENT_SHOW, evt => evt.accessible.parent == liAcc],
        [EVENT_REORDER, liAcc]
      ]);

      getNode("list").style.setProperty("list-style-type", "circle");

      await events;

      is(liAcc.name, "◦ list element",
          "Check that first child of LI is a circle bullet.");

      dumpTree("list");
    }

    /**
     * Change list style position.
     */
     async function changeBulletPosition() {
      info("Change list style position");
      let liAcc = getAccessible("list_element");

      let events = waitForEvents([
        [EVENT_HIDE, evt => evt.accessible.role == ROLE_LISTITEM_MARKER],
        [EVENT_SHOW, evt => evt.accessible.role == ROLE_LISTITEM_MARKER],
        [EVENT_REORDER, liAcc]
      ]);

      getNode("list").style.setProperty("list-style-position", "inside");

      await events;

      is(liAcc.name, "◦ list element",
          "Check that first child of LI is a circle bullet.");
    }

    async function changeBulletPositionAndType() {
      let events = waitForEvents([
        [EVENT_HIDE, evt => evt.accessible.role == ROLE_LISTITEM_MARKER],
        [EVENT_REORDER, evt => evt.accessible.role == ROLE_LISTITEM]
      ]);

      let list = getNode("inside-marker-list");

      // Bug 1513447 - This changes the list type to "none" and the
      // position implicitly to "outside".
      list.style.setProperty("list-style", "none");
      list.offsetLeft
      list.style.setProperty("list-style-type", "telugu");

      await events;
    }

    async function doTest() {

      testAccessibleTree("list", { LIST: [ // ol
        { LISTITEM: [ // li
          { LISTITEM_MARKER: [ ] },
          { TEXT_LEAF: [] },
          ] },
      ] } );

      await hideBullet();

      testAccessibleTree("list", { LIST: [ // ol
        { LISTITEM: [ // li
          { TEXT_LEAF: [] },
          ] },
      ] } );

      await showBullet();

      testAccessibleTree("list", { LIST: [ // ol
        { LISTITEM: [ // li
          { LISTITEM_MARKER: [ ] },
          { TEXT_LEAF: [] },
          ] },
      ] } );

      await changeBulletPosition();

      testAccessibleTree("list", { LIST: [ // ol
        { LISTITEM: [ // li
          { LISTITEM_MARKER: [ ] },
          { TEXT_LEAF: [] },
          ] },
      ] } );

      testAccessibleTree("unmarked-list", { LIST: [ // ol
        { LISTITEM: [ // li
          { TEXT_LEAF: [] },
          ] },
      ] } );

      await changeBulletPositionAndType();

      SimpleTest.finish();
    }

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

</head>

<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1100602"
     title="[e10s] crash in mozilla::a11y::ProxyAccessible::Shutdown()">
    Mozilla Bug 1100602
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <ol id="list" style="list-style-type: circle;">
    <li id="list_element">list element</li>
  </ol>

  <ol id="unmarked-list" style="list-style: none;">
    <li>list element</li>
  </ol>

  <ol id="inside-marker-list" style="list-style-position: inside;">
    <li>list element</li>
  </ol>

</body>
</html>