Bug 1790435: Don't apply rotor post-filter if AXSearchText is empty r=eeejay

Differential Revision: https://phabricator.services.mozilla.com/D160836
This commit is contained in:
Morgan Rae Reschenberg 2022-11-02 17:12:47 +00:00
parent 6efb8ce4cf
commit 5318c8b0a3
2 changed files with 51 additions and 1 deletions

View File

@ -123,7 +123,9 @@ using namespace mozilla::a11y;
- (BOOL)shouldApplyPostFilter {
// We currently only support AXSearchText as a post-search filter.
return !!mSearchText;
// In some cases, VO passes a non-null, empty string for AXSearchText.
// In that case, we should act as if no AXSearchText was given.
return !!mSearchText && [mSearchText length] > 0;
}
- (NSArray<mozAccessible*>*)applyPostFilter:(NSArray<mozAccessible*>*)matches {

View File

@ -58,6 +58,54 @@ addAccessibleTask(
}
);
/**
* Test rotor with heading and empty search text
*/
addAccessibleTask(
`<h1 id="hello">hello</h1><br><h2 id="world">world</h2><br>goodbye`,
async (browser, accDoc) => {
const searchPred = {
AXSearchKey: "AXHeadingSearchKey",
AXImmediateDescendantsOnly: 1,
AXResultsLimit: -1,
AXDirection: "AXDirectionNext",
AXSearchText: "",
};
const webArea = accDoc.nativeInterface.QueryInterface(
Ci.nsIAccessibleMacInterface
);
is(
webArea.getAttributeValue("AXRole"),
"AXWebArea",
"Got web area accessible"
);
const headingCount = webArea.getParameterizedAttributeValue(
"AXUIElementCountForSearchPredicate",
NSDictionary(searchPred)
);
is(headingCount, 2, "Found two headings");
const headings = webArea.getParameterizedAttributeValue(
"AXUIElementsForSearchPredicate",
NSDictionary(searchPred)
);
const hello = getNativeInterface(accDoc, "hello");
const world = getNativeInterface(accDoc, "world");
is(
headings[0].getAttributeValue("AXTitle"),
hello.getAttributeValue("AXTitle"),
"Found correct first heading"
);
is(
headings[1].getAttributeValue("AXTitle"),
world.getAttributeValue("AXTitle"),
"Found correct second heading"
);
}
);
/**
* Test rotor with articles
*/