зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1819799: In a11y browser tests, treat a timeout in untilCacheCondition as a failure. r=eeejay
Otherwise, tests can take a very long time to run due to a bug without us realising that this is due to cache condition timeouts. This patch also notifies observers of a cache update when state change events are received, as those do update the cache but aren't handled by RecvCache. Some Mac tests depend on cache notifications for these instead of state change events, so these were hitting cache condition timeouts. Differential Revision: https://phabricator.services.mozilla.com/D171417
This commit is contained in:
Родитель
5ec432103b
Коммит
427da13d9e
|
@ -414,6 +414,10 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvStateChangeEvent(
|
|||
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
target->UpdateStateCache(aState, aEnabled);
|
||||
if (nsCOMPtr<nsIObserverService> obsService =
|
||||
services::GetObserverService()) {
|
||||
obsService->NotifyObservers(nullptr, NS_ACCESSIBLE_CACHE_TOPIC, nullptr);
|
||||
}
|
||||
}
|
||||
ProxyStateChangeEvent(target, aState, aEnabled);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ addAccessibleTask(
|
|||
{
|
||||
chrome: false,
|
||||
topLevel: false,
|
||||
iframe: true,
|
||||
iframe: isCacheEnabled /* works, but timing is tricky with no cache */,
|
||||
remoteIframe: isCacheEnabled /* works, but timing is tricky with no cache */,
|
||||
iframeAttrs: { style: "width: 0;" },
|
||||
}
|
||||
|
|
|
@ -13,12 +13,17 @@ addAccessibleTask(
|
|||
const div = findAccessibleChildByID(accDoc, "div");
|
||||
ok(div, "Got accessible with 'div' ID.");
|
||||
|
||||
// We don't await for content task to return because
|
||||
// we want to exercise the untilCacheIs function and
|
||||
// demonstrate that it can await for a passing `is` test.
|
||||
let contentPromise = invokeContentTask(browser, [], () => {
|
||||
content.document.getElementById("div").id = "foo";
|
||||
});
|
||||
// When the cache is enabled, we don't await for content task to return
|
||||
// because we want to exercise the untilCacheIs function and
|
||||
// demonstrate that it can await for a passing `is` test.
|
||||
if (!isCacheEnabled) {
|
||||
// However, when the cache is disabled, we must await it because there
|
||||
// will never be a cache update.
|
||||
await contentPromise;
|
||||
}
|
||||
|
||||
await untilCacheIs(
|
||||
() => div.id,
|
||||
|
@ -26,8 +31,10 @@ addAccessibleTask(
|
|||
"ID is correct and updated in cache"
|
||||
);
|
||||
|
||||
// Don't leave test without the content task promise resolved.
|
||||
await contentPromise;
|
||||
if (isCacheEnabled) {
|
||||
// Don't leave test without the content task promise resolved.
|
||||
await contentPromise;
|
||||
}
|
||||
},
|
||||
{ iframe: true, remoteIframe: true }
|
||||
);
|
||||
|
|
|
@ -282,6 +282,7 @@ addAccessibleTask(
|
|||
let styleChanged = waitForEvent(EVENT_TABLE_STYLING_CHANGED, layout);
|
||||
await invokeContentTask(browser, [], () => {
|
||||
content.document.getElementById("cell").style.border = "1px solid black";
|
||||
content.document.body.offsetTop; // Flush layout.
|
||||
});
|
||||
if (!isCacheEnabled) {
|
||||
// this event doesn't get fired when the cache is on, so we can't await it
|
||||
|
|
|
@ -126,14 +126,17 @@ addAccessibleTask(
|
|||
"Correct checked value"
|
||||
);
|
||||
|
||||
evt = waitForMacEvent("AXValueChanged", "checkbox");
|
||||
// Changing from checked to mixed fires two events. Make sure we wait until
|
||||
// the second so we're asserting based on the latest state.
|
||||
evt = waitForMacEvent("AXValueChanged", (iface, data) => {
|
||||
return (
|
||||
iface.getAttributeValue("AXDOMIdentifier") == "checkbox" &&
|
||||
iface.getAttributeValue("AXValue") == 2
|
||||
);
|
||||
});
|
||||
checkbox.performAction("AXPress");
|
||||
await evt;
|
||||
await untilCacheIs(
|
||||
() => checkbox.getAttributeValue("AXValue"),
|
||||
2,
|
||||
"Correct checked value"
|
||||
);
|
||||
is(checkbox.getAttributeValue("AXValue"), 2, "Correct checked value");
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -851,6 +851,7 @@ function untilCacheCondition(conditionFunc, argsFunc) {
|
|||
},
|
||||
|
||||
timeout() {
|
||||
ok(false, "Timeout while waiting for cache update");
|
||||
Services.obs.removeObserver(this, "accessible-cache");
|
||||
args = argsFunc();
|
||||
resolve(args);
|
||||
|
|
Загрузка…
Ссылка в новой задаче