summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/pivot/test_virtualcursor_text.html
blob: 23d46f3fe61ae7e19c8789b0f0f8a37e6b90641d (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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<!DOCTYPE html>
<html>
<head>
  <title>Tests pivot functionality in virtual cursors</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 src="chrome://mochikit/content/chrome-harness.js">
  </script>

  <script type="application/javascript" src="../common.js"></script>
  <script type="application/javascript" src="../text.js"></script>
  <script type="application/javascript" src="../browser.js"></script>
  <script type="application/javascript" src="../events.js"></script>
  <script type="application/javascript" src="../role.js"></script>
  <script type="application/javascript" src="../states.js"></script>
  <script type="application/javascript" src="../pivot.js"></script>
  <script type="application/javascript" src="../layout.js"></script>

  <script type="application/javascript">
    var gBrowserWnd = null;
    var gQueue = null;

    function doTest() {
      var doc = currentTabDocument();
      var docAcc = getAccessible(doc, [nsIAccessibleDocument]);

      gQueue = new eventQueue();

      gQueue.onFinish = function onFinish() {
        closeBrowserWindow();
      };

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("paragraph-1"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 4],
                  getAccessible(doc.getElementById("paragraph-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [4, 5],
                  getAccessible(doc.getElementById("paragraph-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", CHAR_BOUNDARY, [3, 4],
                  getAccessible(doc.getElementById("paragraph-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [5, 7],
                  getAccessible(doc.getElementById("paragraph-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 3],
                  getAccessible(doc.getElementById("p1-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [10, 14],
                  getAccessible(doc.getElementById("paragraph-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 3],
                  getAccessible(doc.getElementById("p1-link-1"), nsIAccessibleText)));
      // set user input to false, and see if it works
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [5, 7],
                  getAccessible(doc.getElementById("paragraph-1"), nsIAccessibleText)),
                  false);

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("section-1"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 1],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 9],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));
      // set user input to false, and see if it works
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [10, 14],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText),
                  false));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [4, 6],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [7, 12],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 2],
                  getAccessible(doc.getElementById("s1-link-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [15, 19],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [20, 28],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 5],
                  getAccessible(doc.getElementById("section-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [6, 10],
                  getAccessible(doc.getElementById("section-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 5],
                  getAccessible(doc.getElementById("section-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [20, 28],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [15, 19],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 2],
                  getAccessible(doc.getElementById("s1-link-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [7, 12],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [4, 6],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [10, 14],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 9],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 1],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));

      gQueue.push(new setVCRangeInvoker(docAcc, getAccessible(doc.getElementById("s1-link-1")), [0, 0]));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", CHAR_BOUNDARY, [1, 2],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", CHAR_BOUNDARY, [0, 1],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [1, 2],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [0, 1],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [1, 2],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [2, 9],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [10, 14],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [3, 4],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", CHAR_BOUNDARY, [13, 14],
                  getAccessible(doc.getElementById("s1-link-1"), nsIAccessibleText)));

      gQueue.push(new setVCRangeInvoker(docAcc, getAccessible(doc.getElementById("section-2")), [0, 0]));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", CHAR_BOUNDARY, [27, 28],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [0, 1],
                  getAccessible(doc.getElementById("section-2"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("paragraph-2"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 12],
                  getAccessible(doc.getElementById("paragraph-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 7],
                  getAccessible(doc.getElementById("cell-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 8],
                  getAccessible(doc.getElementById("cell-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 3],
                  getAccessible(doc.getElementById("cell-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [4, 11],
                  getAccessible(doc.getElementById("cell-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 6],
                  getAccessible(doc.getElementById("cell-4"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [7, 13],
                  getAccessible(doc.getElementById("cell-4"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 7],
                  getAccessible(doc.getElementById("section-3"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("section-3"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 7],
                  getAccessible(doc.getElementById("section-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [7, 13],
                  getAccessible(doc.getElementById("cell-4"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 6],
                  getAccessible(doc.getElementById("cell-4"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [4, 11],
                  getAccessible(doc.getElementById("cell-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 3],
                  getAccessible(doc.getElementById("cell-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 8],
                  getAccessible(doc.getElementById("cell-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 7],
                  getAccessible(doc.getElementById("cell-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 12],
                  getAccessible(doc.getElementById("paragraph-2"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("paragraph-3"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 7],
                  getAccessible(doc.getElementById("paragraph-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 8],
                  getAccessible(doc.getElementById("p3-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [8, 10],
                  getAccessible(doc.getElementById("paragraph-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 4],
                  getAccessible(doc.getElementById("p3-link-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 5],
                  getAccessible(doc.getElementById("p3-link-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [14, 20],
                  getAccessible(doc.getElementById("paragraph-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 5],
                  getAccessible(doc.getElementById("p3-link-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 4],
                  getAccessible(doc.getElementById("p3-link-2"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [8, 10],
                  getAccessible(doc.getElementById("paragraph-3"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 8],
                  getAccessible(doc.getElementById("p3-link-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 7],
                  getAccessible(doc.getElementById("paragraph-3"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("s1-link-2"))));
      // Start with the pivot in the middle of the paragraph
      gQueue.push(new setVCPosInvoker(docAcc, "moveNext", ObjectTraversalRule, " will traverse"));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [15, 19],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [0, 2],
                  getAccessible(doc.getElementById("s1-link-2"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("end-block"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 4],
                  getAccessible(doc.getElementById("end-block"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, null, false));
      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("start-block"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 4],
                  getAccessible(doc.getElementById("start-block"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, null, false));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, null, false));
      gQueue.push(new setVCRangeInvoker(docAcc, getAccessible(doc.getElementById("start-block")), [0, 0]));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, null, false));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                  getAccessible(doc.getElementById("paragraph-3")).firstChild));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [0, 7],
                  getAccessible(doc.getElementById("paragraph-3"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                  getAccessible(doc.getElementById("s1-link-1")).nextSibling));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [4, 6],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                  getAccessible(doc.getElementById("paragraph-4")).firstChild.nextSibling));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", WORD_BOUNDARY, [6, 10],
                  getAccessible(doc.getElementById("paragraph-4"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("section-1"))));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [20, 28],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("section-1")).lastChild));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", WORD_BOUNDARY, [20, 28],
                  getAccessible(doc.getElementById("section-1"), nsIAccessibleText)));

      gQueue.push(new setVCPosInvoker(docAcc, null, null,
                                      getAccessible(doc.getElementById("image-desc-link"))));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [0, 1],
                  getAccessible(doc.getElementById("image-desc-link"), nsIAccessibleText)));
      gQueue.push(new setVCTextInvoker(docAcc, "moveNextByText", CHAR_BOUNDARY, [1, 2],
                  getAccessible(doc.getElementById("image-desc-link"), nsIAccessibleText)));

      gQueue.push(new setVCRangeInvoker(docAcc, getAccessible(doc.getElementById("image-end-line")), [3, 3]));
      gQueue.push(new setVCTextInvoker(docAcc, "movePreviousByText", LINE_BOUNDARY, [0, 2],
                  getAccessible(doc.getElementById("image-end-line"), nsIAccessibleText)));

      gQueue.invoke();
    }

    SimpleTest.waitForExplicitFinish();
    addLoadEvent(function() {
      /* We open a new browser because we need to test with a top-level content
         document. */
      openBrowserWindow(
        doTest,
        getRootDirectory(window.location.href) + "doc_virtualcursor_text.html");
    });
  </script>
</head>
<body id="body">

  <a target="_blank"
     title="Support Movement By Granularity"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=886076">Mozilla Bug 886076</a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>
</body>
</html>