summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/e10s/browser_treeupdate_visibility.js
blob: 65a55c9149d539e579ac106377a6dee15eaba05e (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict';

/* global EVENT_REORDER */

loadScripts({ name: 'role.js', dir: MOCHITESTS_DIR });

function* testTreeOnHide(browser, accDoc, containerID, id, before, after) {
  let acc = findAccessibleChildByID(accDoc, containerID);
  testAccessibleTree(acc, before);

  let onReorder = waitForEvent(EVENT_REORDER, containerID);
  yield invokeSetStyle(browser, id, 'visibility', 'hidden');
  yield onReorder;

  testAccessibleTree(acc, after);
}

function* test3(browser, accessible) {
  let tree = {
    SECTION: [ // container
      { SECTION: [ // parent
        { SECTION: [ // child
          { TEXT_LEAF: [] }
        ] }
      ] },
      { SECTION: [ // parent2
        { SECTION: [ // child2
          { TEXT_LEAF: [] }
        ] }
      ] }
    ] };
  testAccessibleTree(accessible, tree);

  let onReorder = waitForEvent(EVENT_REORDER, 't3_container');
  yield ContentTask.spawn(browser, {}, () => {
    let doc = content.document;
    doc.getElementById('t3_container').style.color = 'red';
    doc.getElementById('t3_parent').style.visibility = 'hidden';
    doc.getElementById('t3_parent2').style.visibility = 'hidden';
  });
  yield onReorder;

  tree = {
    SECTION: [ // container
      { SECTION: [ // child
        { TEXT_LEAF: [] }
      ] },
      { SECTION: [ // child2
        { TEXT_LEAF: [] }
      ] }
    ] };
  testAccessibleTree(accessible, tree);
}

function* test4(browser, accessible) {
  let tree = {
    SECTION: [
      { TABLE: [
        { ROW: [
          { CELL: [ ] }
        ] }
      ] }
    ] };
  testAccessibleTree(accessible, tree);

  let onReorder = waitForEvent(EVENT_REORDER, 't4_parent');
  yield ContentTask.spawn(browser, {}, () => {
    let doc = content.document;
    doc.getElementById('t4_container').style.color = 'red';
    doc.getElementById('t4_child').style.visibility = 'visible';
  });
  yield onReorder;

  tree = {
    SECTION: [{
      TABLE: [{
        ROW: [{
          CELL: [{
            SECTION: [{
              TEXT_LEAF: []
            }]
          }]
        }]
      }]
    }]
  };
  testAccessibleTree(accessible, tree);
}

addAccessibleTask('doc_treeupdate_visibility.html', function*(browser, accDoc) {
  let t3Container = findAccessibleChildByID(accDoc, 't3_container');
  let t4Container = findAccessibleChildByID(accDoc, 't4_container');

  yield testTreeOnHide(browser, accDoc, 't1_container', 't1_parent', {
    SECTION: [{
      SECTION: [{
        SECTION: [ { TEXT_LEAF: [] } ]
      }]
    }]
  }, {
    SECTION: [ {
      SECTION: [ { TEXT_LEAF: [] } ]
    } ]
  });

  yield testTreeOnHide(browser, accDoc, 't2_container', 't2_grandparent', {
    SECTION: [{ // container
      SECTION: [{ // grand parent
        SECTION: [{
          SECTION: [{ // child
            TEXT_LEAF: []
          }]
        }, {
          SECTION: [{ // child2
            TEXT_LEAF: []
          }]
        }]
      }]
    }]
  }, {
    SECTION: [{ // container
      SECTION: [{ // child
        TEXT_LEAF: []
      }]
    }, {
      SECTION: [{ // child2
        TEXT_LEAF: []
      }]
    }]
  });

  yield test3(browser, t3Container);
  yield test4(browser, t4Container);

  yield testTreeOnHide(browser, accDoc, 't5_container', 't5_subcontainer', {
    SECTION: [{ // container
      SECTION: [{ // subcontainer
        TABLE: [{
          ROW: [{
            CELL: [{
              SECTION: [{ // child
                TEXT_LEAF: []
              }]
            }]
          }]
        }]
      }]
    }]
  }, {
    SECTION: [{ // container
      SECTION: [{ // child
        TEXT_LEAF: []
      }]
    }]
  });

  yield testTreeOnHide(browser, accDoc, 't6_container', 't6_subcontainer', {
    SECTION: [{ // container
      SECTION: [{ // subcontainer
        TABLE: [{
          ROW: [{
            CELL: [{
              TABLE: [{ // nested table
                ROW: [{
                  CELL: [{
                    SECTION: [{ // child
                      TEXT_LEAF: []
                    }]
                  }]
                }]
              }]
            }]
          }]
        }]
      }, {
        SECTION: [{ // child2
          TEXT_LEAF: []
        }]
      }]
    }]
  }, {
    SECTION: [{ // container
      SECTION: [{ // child
        TEXT_LEAF: []
      }]
    }, {
      SECTION: [{ // child2
        TEXT_LEAF: []
      }]
    }]
  });
});