зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1672700 - Refactor mac input test. r=morgan
This also irons out some event syncing issues. We need to wait for selection changes in the future patch in order to take advantage of selection caching. Differential Revision: https://phabricator.services.mozilla.com/D97628
This commit is contained in:
Родитель
425edf7c9d
Коммит
e3785d17c1
|
@ -4,88 +4,98 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
async function testInput(browser, accDoc) {
|
||||||
|
let input = getNativeInterface(accDoc, "input");
|
||||||
|
|
||||||
|
is(input.getAttributeValue("AXDescription"), "Name", "Correct input label");
|
||||||
|
is(input.getAttributeValue("AXTitle"), "", "Correct input title");
|
||||||
|
is(input.getAttributeValue("AXValue"), "Elmer Fudd", "Correct input value");
|
||||||
|
is(
|
||||||
|
input.getAttributeValue("AXNumberOfCharacters"),
|
||||||
|
10,
|
||||||
|
"Correct length of value"
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(input.attributeNames.includes("AXSelectedText"), "Has AXSelectedText");
|
||||||
|
ok(
|
||||||
|
input.attributeNames.includes("AXSelectedTextRange"),
|
||||||
|
"Has AXSelectedTextRange"
|
||||||
|
);
|
||||||
|
|
||||||
|
let evt = Promise.all([
|
||||||
|
waitForMacEvent("AXFocusedUIElementChanged", "input"),
|
||||||
|
waitForMacEvent("AXSelectedTextChanged", "body"),
|
||||||
|
waitForMacEvent("AXSelectedTextChanged", "input"),
|
||||||
|
]);
|
||||||
|
await SpecialPowers.spawn(browser, [], () => {
|
||||||
|
content.document.getElementById("input").focus();
|
||||||
|
});
|
||||||
|
await evt;
|
||||||
|
|
||||||
|
evt = Promise.all([
|
||||||
|
waitForMacEvent("AXSelectedTextChanged", "body"),
|
||||||
|
waitForMacEvent("AXSelectedTextChanged", "input"),
|
||||||
|
]);
|
||||||
|
await SpecialPowers.spawn(browser, [], () => {
|
||||||
|
let elm = content.document.getElementById("input");
|
||||||
|
elm.setSelectionRange(6, 9);
|
||||||
|
});
|
||||||
|
await evt;
|
||||||
|
|
||||||
|
is(
|
||||||
|
input.getAttributeValue("AXSelectedText"),
|
||||||
|
"Fud",
|
||||||
|
"Correct text is selected"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.deepEqual(
|
||||||
|
input.getAttributeValue("AXSelectedTextRange"),
|
||||||
|
[6, 3],
|
||||||
|
"correct range selected"
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(
|
||||||
|
input.isAttributeSettable("AXSelectedTextRange"),
|
||||||
|
"AXSelectedTextRange is settable"
|
||||||
|
);
|
||||||
|
|
||||||
|
evt = Promise.all([
|
||||||
|
waitForMacEvent("AXSelectedTextChanged"),
|
||||||
|
waitForMacEvent("AXSelectedTextChanged"),
|
||||||
|
]);
|
||||||
|
input.setAttributeValue("AXSelectedTextRange", NSRange(1, 7));
|
||||||
|
await evt;
|
||||||
|
|
||||||
|
Assert.deepEqual(
|
||||||
|
input.getAttributeValue("AXSelectedTextRange"),
|
||||||
|
[1, 7],
|
||||||
|
"correct range selected"
|
||||||
|
);
|
||||||
|
|
||||||
|
is(
|
||||||
|
input.getAttributeValue("AXSelectedText"),
|
||||||
|
"lmer Fu",
|
||||||
|
"Correct text is selected"
|
||||||
|
);
|
||||||
|
|
||||||
|
let domSelection = await SpecialPowers.spawn(browser, [], () => {
|
||||||
|
let elm = content.document.querySelector("input#input");
|
||||||
|
return elm.value.substring(elm.selectionStart, elm.selectionEnd);
|
||||||
|
});
|
||||||
|
|
||||||
|
is(domSelection, "lmer Fu", "correct DOM selection");
|
||||||
|
|
||||||
|
is(
|
||||||
|
input.getParameterizedAttributeValue("AXStringForRange", NSRange(3, 5)),
|
||||||
|
"er Fu",
|
||||||
|
"AXStringForRange works"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input selection test
|
* Input selection test
|
||||||
*/
|
*/
|
||||||
addAccessibleTask(
|
addAccessibleTask(
|
||||||
`<input aria-label="Name" id="input" value="Elmer Fudd">`,
|
`<input aria-label="Name" id="input" value="Elmer Fudd">`,
|
||||||
async (browser, accDoc) => {
|
testInput
|
||||||
let input = getNativeInterface(accDoc, "input");
|
|
||||||
|
|
||||||
is(input.getAttributeValue("AXDescription"), "Name", "Correct input label");
|
|
||||||
is(input.getAttributeValue("AXTitle"), "", "Correct input title");
|
|
||||||
is(
|
|
||||||
input.getAttributeValue("AXNumberOfCharacters"),
|
|
||||||
10,
|
|
||||||
"Correct length of value"
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(input.attributeNames.includes("AXSelectedText"), "Has AXSelecetdText");
|
|
||||||
ok(
|
|
||||||
input.attributeNames.includes("AXSelectedTextRange"),
|
|
||||||
"Has AXSelecetdTextRange"
|
|
||||||
);
|
|
||||||
|
|
||||||
// XXX: Need to look into why we send so many AXSelectedTextChanged notifications.
|
|
||||||
let evt = Promise.all([
|
|
||||||
waitForMacEvent("AXFocusedUIElementChanged"),
|
|
||||||
waitForMacEvent("AXSelectedTextChanged"),
|
|
||||||
waitForMacEvent("AXSelectedTextChanged"),
|
|
||||||
waitForMacEvent("AXSelectedTextChanged"),
|
|
||||||
]);
|
|
||||||
await SpecialPowers.spawn(browser, [], () => {
|
|
||||||
let elm = content.document.getElementById("input");
|
|
||||||
elm.focus();
|
|
||||||
elm.setSelectionRange(6, 9);
|
|
||||||
});
|
|
||||||
await evt;
|
|
||||||
|
|
||||||
is(
|
|
||||||
input.getAttributeValue("AXSelectedText"),
|
|
||||||
"Fud",
|
|
||||||
"Correct text is selected"
|
|
||||||
);
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
input.getAttributeValue("AXSelectedTextRange"),
|
|
||||||
[6, 3],
|
|
||||||
"correct range selected"
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
|
||||||
input.isAttributeSettable("AXSelectedTextRange"),
|
|
||||||
"AXSelectedTextRange is settable"
|
|
||||||
);
|
|
||||||
|
|
||||||
evt = Promise.all([
|
|
||||||
waitForMacEvent("AXSelectedTextChanged"),
|
|
||||||
waitForMacEvent("AXSelectedTextChanged"),
|
|
||||||
]);
|
|
||||||
input.setAttributeValue("AXSelectedTextRange", NSRange(1, 7));
|
|
||||||
|
|
||||||
Assert.deepEqual(
|
|
||||||
input.getAttributeValue("AXSelectedTextRange"),
|
|
||||||
[1, 7],
|
|
||||||
"correct range selected"
|
|
||||||
);
|
|
||||||
|
|
||||||
is(
|
|
||||||
input.getAttributeValue("AXSelectedText"),
|
|
||||||
"lmer Fu",
|
|
||||||
"Correct text is selected"
|
|
||||||
);
|
|
||||||
|
|
||||||
let domSelection = await SpecialPowers.spawn(browser, [], () => {
|
|
||||||
let elm = content.document.getElementById("input");
|
|
||||||
return [elm.selectionStart, elm.selectionEnd];
|
|
||||||
});
|
|
||||||
|
|
||||||
Assert.deepEqual(domSelection, [1, 8], "correct DOM selection");
|
|
||||||
|
|
||||||
is(
|
|
||||||
input.getParameterizedAttributeValue("AXStringForRange", NSRange(3, 5)),
|
|
||||||
"er Fu",
|
|
||||||
"AXStringForRange works"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче