зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1681909 - P3: Implement e10s post search filter and test. r=morgan
The test adds fission testing as well. Differential Revision: https://phabricator.services.mozilla.com/D100732
This commit is contained in:
Родитель
4537ab3655
Коммит
9e19999a57
|
@ -216,6 +216,23 @@ DocAccessiblePlatformExtChild::RecvApplyPostSearchFilter(
|
|||
const nsTArray<uint64_t>& aAccessibles, const int32_t& aLimit,
|
||||
const EWhichPostFilter& aSearchKey, const nsString& aSearchText,
|
||||
nsTArray<uint64_t>* aMatches) {
|
||||
if (aSearchKey != EWhichPostFilter::eContainsText) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
DocAccessibleChild* ipcDoc = static_cast<DocAccessibleChild*>(Manager());
|
||||
for (size_t i = 0; i < aAccessibles.Length(); i++) {
|
||||
AccessibleWrap* acc = static_cast<AccessibleWrap*>(
|
||||
ipcDoc->IdToAccessible(aAccessibles.ElementAt(i)));
|
||||
if (!acc) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (acc->ApplyPostFilter(aSearchKey, aSearchText)) {
|
||||
aMatches->AppendElement(UNIQUE_ID(acc));
|
||||
}
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,9 @@ using namespace mozilla::a11y;
|
|||
nsString searchText;
|
||||
nsCocoaUtils::GetStringForNSString(mSearchText, searchText);
|
||||
|
||||
__block DocAccessibleParent* ipcDoc = nullptr;
|
||||
__block nsTArray<uint64_t> accIds;
|
||||
|
||||
[matches enumerateObjectsUsingBlock:^(mozAccessible* match, NSUInteger idx,
|
||||
BOOL* stop) {
|
||||
AccessibleOrProxy geckoAcc = [match geckoAccessible];
|
||||
|
@ -175,9 +178,45 @@ using namespace mozilla::a11y;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// XXX: Proxy implementation in next patch.
|
||||
ProxyAccessible* proxy = geckoAcc.AsProxy();
|
||||
if (ipcDoc &&
|
||||
((ipcDoc != proxy->Document()) || (idx + 1 == [matches count]))) {
|
||||
// If the ipcDoc doesn't match the current proxy's doc, we crossed into a
|
||||
// new document. ..or this is the last match. Apply the filter on the list
|
||||
// of the current ipcDoc.
|
||||
nsTArray<uint64_t> matchIds;
|
||||
Unused << ipcDoc->GetPlatformExtension()->SendApplyPostSearchFilter(
|
||||
accIds, mResultLimit, EWhichPostFilter::eContainsText, searchText,
|
||||
&matchIds);
|
||||
for (size_t i = 0; i < matchIds.Length(); i++) {
|
||||
if (ProxyAccessible* postMatch =
|
||||
ipcDoc->GetAccessible(matchIds.ElementAt(i))) {
|
||||
if (mozAccessible* nativePostMatch =
|
||||
GetNativeFromGeckoAccessible(postMatch)) {
|
||||
[postMatches addObject:nativePostMatch];
|
||||
if (mResultLimit > 0 &&
|
||||
[postMatches count] >= static_cast<NSUInteger>(mResultLimit)) {
|
||||
// If we reached the result limit, alter the `stop` pointer to YES
|
||||
// to stop iteration.
|
||||
*stop = YES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ipcDoc = nullptr;
|
||||
accIds.Clear();
|
||||
}
|
||||
|
||||
if (!ipcDoc) {
|
||||
ipcDoc = proxy->Document();
|
||||
}
|
||||
accIds.AppendElement(proxy->ID());
|
||||
}];
|
||||
|
||||
return postMatches;
|
||||
|
|
|
@ -1641,3 +1641,57 @@ addAccessibleTask(
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test search text
|
||||
*/
|
||||
addAccessibleTask(
|
||||
`
|
||||
<p>It's about the future, isn't it?</p>
|
||||
<p>Okay, alright, Saturday is good, Saturday's good, I could spend a week in 1955.</p>
|
||||
<ul>
|
||||
<li>I could hang out, you could show me around.</li>
|
||||
<li>There's that word again, heavy.</li>
|
||||
</ul>
|
||||
`,
|
||||
async (browser, f, accDoc) => {
|
||||
let searchPred = {
|
||||
AXSearchKey: "AXAnyTypeSearchKey",
|
||||
AXResultsLimit: -1,
|
||||
AXDirection: "AXDirectionNext",
|
||||
AXSearchText: "could",
|
||||
};
|
||||
|
||||
const webArea = accDoc.nativeInterface.QueryInterface(
|
||||
Ci.nsIAccessibleMacInterface
|
||||
);
|
||||
is(
|
||||
webArea.getAttributeValue("AXRole"),
|
||||
"AXWebArea",
|
||||
"Got web area accessible"
|
||||
);
|
||||
|
||||
const textSearchCount = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementCountForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
is(textSearchCount, 2, "Found 2 matching items in text search");
|
||||
|
||||
const results = webArea.getParameterizedAttributeValue(
|
||||
"AXUIElementsForSearchPredicate",
|
||||
NSDictionary(searchPred)
|
||||
);
|
||||
|
||||
info(results.map(r => r.getAttributeValue("AXMozDebugDescription")));
|
||||
|
||||
Assert.deepEqual(
|
||||
results.map(r => r.getAttributeValue("AXValue")),
|
||||
[
|
||||
"Okay, alright, Saturday is good, Saturday's good, I could spend a week in 1955.",
|
||||
"I could hang out, you could show me around.",
|
||||
],
|
||||
"Correct text search results"
|
||||
);
|
||||
},
|
||||
{ topLevel: false, iframe: true, remoteIframe: true }
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче