Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 90ef3d3

Browse files
committed
Bug 1733514 part 5: Add initial tests for a11y text caching. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D128035
1 parent ec36f1e commit 90ef3d3

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

accessible/tests/browser/e10s/browser.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ support-files =
2020
skip-if = (os == "linux" && bits == 64) || (debug && os == "mac") || (debug && os == "win") #Bug 1388256
2121
[browser_caching_relations.js]
2222
[browser_caching_states.js]
23+
[browser_caching_text.js]
2324
[browser_caching_value.js]
2425
[browser_caching_uniqueid.js]
2526
[browser_caching_interfaces.js]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
"use strict";
6+
7+
/* import-globals-from ../../mochitest/text.js */
8+
loadScripts({ name: "text.js", dir: MOCHITESTS_DIR });
9+
10+
const isCacheEnabled = Services.prefs.getBoolPref(
11+
"accessibility.cache.enabled",
12+
false
13+
);
14+
15+
/**
16+
* Test line and word offsets for various cases for both local and remote
17+
* Accessibles. There is more extensive coverage in ../../mochitest/text. These
18+
* tests don't need to duplicate all of that, since much of the underlying code
19+
* is unified. They should ensure that the cache works as expected and that
20+
* there is consistency between local and remote.
21+
*/
22+
addAccessibleTask(
23+
`
24+
<p id="br">ab cd<br>ef gh</p>
25+
<pre id="pre">ab cd
26+
ef gh</pre>
27+
<p id="linksStartEnd"><a href="https://example.com/">a</a>b<a href="https://example.com/">c</a></p>
28+
<p id="linksBreaking">a<a href="https://example.com/">b<br>c</a>d</p>
29+
`,
30+
async function(browser, docAcc) {
31+
for (const id of ["br", "pre"]) {
32+
const acc = findAccessibleChildByID(docAcc, id);
33+
if (!isCacheEnabled && AppConstants.platform == "win") {
34+
todo(
35+
false,
36+
"Cache disabled, so RemoteAccessible doesn't support CharacterCount on Windows"
37+
);
38+
} else {
39+
testCharacterCount([acc], 11);
40+
}
41+
testTextAtOffset(acc, BOUNDARY_LINE_START, [
42+
[0, 5, "ab cd\n", 0, 6],
43+
[6, 11, "ef gh", 6, 11],
44+
]);
45+
testTextAtOffset(acc, BOUNDARY_WORD_START, [
46+
[0, 2, "ab ", 0, 3],
47+
[3, 5, "cd\n", 3, 6],
48+
[6, 8, "ef ", 6, 9],
49+
[9, 11, "gh", 9, 11],
50+
]);
51+
}
52+
const linksStartEnd = findAccessibleChildByID(docAcc, "linksStartEnd");
53+
testTextAtOffset(linksStartEnd, BOUNDARY_LINE_START, [
54+
[0, 3, `${kEmbedChar}b${kEmbedChar}`, 0, 3],
55+
]);
56+
testTextAtOffset(linksStartEnd, BOUNDARY_WORD_START, [
57+
[0, 3, `${kEmbedChar}b${kEmbedChar}`, 0, 3],
58+
]);
59+
const linksBreaking = findAccessibleChildByID(docAcc, "linksBreaking");
60+
testTextAtOffset(linksBreaking, BOUNDARY_LINE_START, [
61+
[0, 0, `a${kEmbedChar}`, 0, 2],
62+
[1, 1, `a${kEmbedChar}d`, 0, 3],
63+
[2, 3, `${kEmbedChar}d`, 1, 3],
64+
]);
65+
if (isCacheEnabled) {
66+
testTextAtOffset(linksBreaking, BOUNDARY_WORD_START, [
67+
[0, 0, `a${kEmbedChar}`, 0, 2],
68+
[1, 1, `a${kEmbedChar}d`, 0, 3],
69+
[2, 3, `${kEmbedChar}d`, 1, 3],
70+
]);
71+
} else {
72+
todo(
73+
false,
74+
"TextLeafPoint disabled, so word boundaries are incorrect for linksBreaking"
75+
);
76+
}
77+
},
78+
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
79+
);

0 commit comments

Comments
 (0)