Bug 1869966 part 1: Add tests for existing IAccessibleSelectionContainer behaviour. r=eeejay

We did have support for IA2 testing when this was added.
However, because this interface is a relatively recent addition to the IA2 spec, it isn't included in the COM proxy dll included in Windows.
This means we can't run these tests without building and installing our own proxy DLL.
This has to be integrated into the Windows CI images, so we can't run these tests on CI for now and thus they're disabled on CI.
Even so, it's better to have local-only tests for this than no tests at all.

Differential Revision: https://phabricator.services.mozilla.com/D247871
This commit is contained in:
James Teh
2025-05-06 22:13:58 +00:00
committed by jteh@mozilla.com
parent e0dcd0eed6
commit 7f3da64a12
3 changed files with 83 additions and 5 deletions

View File

@@ -24,3 +24,6 @@ prefs = [
["browser_scrolling.js"]
["browser_text.js"]
["browser_textSelectionContainer.js"]
skip-if = ["true"] # Bug 1857116

View File

@@ -9,11 +9,11 @@
*/
addAccessibleTask(`<p id="cluster">a🤦c`, async function testChar() {
await runPython(`
doc = getDocIa2()
global cluster
cluster = findIa2ByDomId(doc, "cluster")
cluster = cluster.QueryInterface(IAccessibleText)
`);
doc = getDocIa2()
global cluster
cluster = findIa2ByDomId(doc, "cluster")
cluster = cluster.QueryInterface(IAccessibleText)
`);
SimpleTest.isDeeply(
await runPython(`cluster.textAtOffset(0, IA2_TEXT_BOUNDARY_CHAR)`),
[0, 1, "a"],

View File

@@ -0,0 +1,75 @@
/* 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 });
function checkSelection(root, ranges) {
const selRanges = root.selectionRanges;
is(selRanges.length, ranges.length, "Correct number of selection ranges");
for (let r = 0; r < ranges.length; ++r) {
const selRange = selRanges.queryElementAt(r, nsIAccessibleTextRange);
testTextRange(selRange, root.id, ...ranges[r]);
}
}
/**
* Test IAccessibleTextSelectionContainer::setSelections.
*/
addAccessibleTask(
`<p id="p">ab<a id="link" href="/">cd</a>ef</p>`,
async function testSetSelections(browser, docAcc) {
docAcc.QueryInterface(nsIAccessibleText);
await runPython(`
global doc, docSel, p, link
doc = getDocIa2()
docSel = doc.QueryInterface(IAccessibleTextSelectionContainer)
p = findIa2ByDomId(doc, "p").QueryInterface(IAccessibleText)
link = findIa2ByDomId(doc, "link").QueryInterface(IAccessibleText)
`);
info("Selecting ab, end at link 0");
const p = findAccessibleChildByID(docAcc, "p");
let selected = waitForEvent(EVENT_TEXT_SELECTION_CHANGED, p);
await runPython(`
docSel.setSelections(1, byref(IA2TextSelection(p, 0, link, 0, False)))
`);
await selected;
const link = findAccessibleChildByID(docAcc, "link");
checkSelection(docAcc, [[p, 0, link, 0]]);
info("Selecting bc");
selected = waitForEvent(EVENT_TEXT_SELECTION_CHANGED, p);
await runPython(`
docSel.setSelections(1, byref(IA2TextSelection(p, 1, link, 1, False)))
`);
await selected;
checkSelection(docAcc, [[p, 1, link, 1]]);
info("Selecting de");
selected = waitForEvent(EVENT_TEXT_SELECTION_CHANGED, p);
await runPython(`
docSel.setSelections(1, byref(IA2TextSelection(link, 1, p, 4, False)))
`);
await selected;
checkSelection(docAcc, [[link, 1, p, 4]]);
info("Selecting a, c");
selected = waitForEvent(EVENT_TEXT_SELECTION_CHANGED, link);
await runPython(`
docSel.setSelections(2, (IA2TextSelection * 2)(
IA2TextSelection(p, 0, p, 1, False),
IA2TextSelection(link, 0, link, 1, False)
))
`);
await selected;
checkSelection(docAcc, [
[p, 0, p, 1],
[link, 0, link, 1],
]);
}
);