зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1733514 part 5: Add initial tests for a11y text caching. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D128035
This commit is contained in:
Родитель
ec36f1e8b3
Коммит
90ef3d34d8
|
@ -20,6 +20,7 @@ support-files =
|
|||
skip-if = (os == "linux" && bits == 64) || (debug && os == "mac") || (debug && os == "win") #Bug 1388256
|
||||
[browser_caching_relations.js]
|
||||
[browser_caching_states.js]
|
||||
[browser_caching_text.js]
|
||||
[browser_caching_value.js]
|
||||
[browser_caching_uniqueid.js]
|
||||
[browser_caching_interfaces.js]
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* 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";
|
||||
|
||||
/* import-globals-from ../../mochitest/text.js */
|
||||
loadScripts({ name: "text.js", dir: MOCHITESTS_DIR });
|
||||
|
||||
const isCacheEnabled = Services.prefs.getBoolPref(
|
||||
"accessibility.cache.enabled",
|
||||
false
|
||||
);
|
||||
|
||||
/**
|
||||
* Test line and word offsets for various cases for both local and remote
|
||||
* Accessibles. There is more extensive coverage in ../../mochitest/text. These
|
||||
* tests don't need to duplicate all of that, since much of the underlying code
|
||||
* is unified. They should ensure that the cache works as expected and that
|
||||
* there is consistency between local and remote.
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`
|
||||
<p id="br">ab cd<br>ef gh</p>
|
||||
<pre id="pre">ab cd
|
||||
ef gh</pre>
|
||||
<p id="linksStartEnd"><a href="https://example.com/">a</a>b<a href="https://example.com/">c</a></p>
|
||||
<p id="linksBreaking">a<a href="https://example.com/">b<br>c</a>d</p>
|
||||
`,
|
||||
async function(browser, docAcc) {
|
||||
for (const id of ["br", "pre"]) {
|
||||
const acc = findAccessibleChildByID(docAcc, id);
|
||||
if (!isCacheEnabled && AppConstants.platform == "win") {
|
||||
todo(
|
||||
false,
|
||||
"Cache disabled, so RemoteAccessible doesn't support CharacterCount on Windows"
|
||||
);
|
||||
} else {
|
||||
testCharacterCount([acc], 11);
|
||||
}
|
||||
testTextAtOffset(acc, BOUNDARY_LINE_START, [
|
||||
[0, 5, "ab cd\n", 0, 6],
|
||||
[6, 11, "ef gh", 6, 11],
|
||||
]);
|
||||
testTextAtOffset(acc, BOUNDARY_WORD_START, [
|
||||
[0, 2, "ab ", 0, 3],
|
||||
[3, 5, "cd\n", 3, 6],
|
||||
[6, 8, "ef ", 6, 9],
|
||||
[9, 11, "gh", 9, 11],
|
||||
]);
|
||||
}
|
||||
const linksStartEnd = findAccessibleChildByID(docAcc, "linksStartEnd");
|
||||
testTextAtOffset(linksStartEnd, BOUNDARY_LINE_START, [
|
||||
[0, 3, `${kEmbedChar}b${kEmbedChar}`, 0, 3],
|
||||
]);
|
||||
testTextAtOffset(linksStartEnd, BOUNDARY_WORD_START, [
|
||||
[0, 3, `${kEmbedChar}b${kEmbedChar}`, 0, 3],
|
||||
]);
|
||||
const linksBreaking = findAccessibleChildByID(docAcc, "linksBreaking");
|
||||
testTextAtOffset(linksBreaking, BOUNDARY_LINE_START, [
|
||||
[0, 0, `a${kEmbedChar}`, 0, 2],
|
||||
[1, 1, `a${kEmbedChar}d`, 0, 3],
|
||||
[2, 3, `${kEmbedChar}d`, 1, 3],
|
||||
]);
|
||||
if (isCacheEnabled) {
|
||||
testTextAtOffset(linksBreaking, BOUNDARY_WORD_START, [
|
||||
[0, 0, `a${kEmbedChar}`, 0, 2],
|
||||
[1, 1, `a${kEmbedChar}d`, 0, 3],
|
||||
[2, 3, `${kEmbedChar}d`, 1, 3],
|
||||
]);
|
||||
} else {
|
||||
todo(
|
||||
false,
|
||||
"TextLeafPoint disabled, so word boundaries are incorrect for linksBreaking"
|
||||
);
|
||||
}
|
||||
},
|
||||
{ chrome: true, topLevel: true, iframe: true, remoteIframe: true }
|
||||
);
|
Загрузка…
Ссылка в новой задаче