forked from mirrors/gecko-dev
Bug 1888310: Verify a11y-announcement is a child of ChildView instead of mozRootAccessible r=eeejay
Previously we checked if the announcement was a child of the root acc directly, but it's not clear this worked reliably since we've done `GetObjectOrRepresentedView` for a while, which (should) return the view instead of the root acc. This patch also: - Dispatches the announcement from NSApp instead of NSWindow, since per chrome and safari notifs fired on non-main windows get dropped - Modifies the announcement priority from medium to high, so VO interrupts itself to speak this message (this makes the UX more consistent, since the text-inserted/text-deleted notifs from the URL bar seem to occasionally bookend the announcement) - Updates the browser_app.js test to NOT run in headless mode, since in headless mode NSApp isn't rendered to dispatch the notification. This test contains a task for AXAnnouncementRequested via a11yUtils.announce Differential Revision: https://phabricator.services.mozilla.com/D206083
This commit is contained in:
parent
6ffc34fe0a
commit
4e0ffe1a17
1 changed files with 15 additions and 11 deletions
|
|
@ -879,10 +879,13 @@ struct RoleDescrComparator {
|
||||||
// a random acc with the same ID) by checking:
|
// a random acc with the same ID) by checking:
|
||||||
// - The gecko acc is local, our a11y-announcement lives in browser.xhtml
|
// - The gecko acc is local, our a11y-announcement lives in browser.xhtml
|
||||||
// - The ID of the gecko acc is "a11y-announcement"
|
// - The ID of the gecko acc is "a11y-announcement"
|
||||||
// - The native acc is a direct descendent of the root
|
// - The native acc is a direct descendent of the chrome window (ChildView in
|
||||||
|
// a non-headless context, mozRootAccessible in a headless context).
|
||||||
if (mGeckoAccessible->IsLocal() &&
|
if (mGeckoAccessible->IsLocal() &&
|
||||||
[[self moxDOMIdentifier] isEqualToString:@"a11y-announcement"] &&
|
[[self moxDOMIdentifier] isEqualToString:@"a11y-announcement"] &&
|
||||||
[[self moxParent] isKindOfClass:[mozRootAccessible class]]) {
|
((gfxPlatform::IsHeadless() &&
|
||||||
|
[[self moxParent] isKindOfClass:[mozRootAccessible class]]) ||
|
||||||
|
[[self moxParent] isKindOfClass:[ChildView class]])) {
|
||||||
// Our actual announcement should be stored as a child of the alert,
|
// Our actual announcement should be stored as a child of the alert,
|
||||||
// so we verify a child exists, and then query that child below.
|
// so we verify a child exists, and then query that child below.
|
||||||
NSArray* children = [self moxChildren];
|
NSArray* children = [self moxChildren];
|
||||||
|
|
@ -896,23 +899,24 @@ struct RoleDescrComparator {
|
||||||
} else {
|
} else {
|
||||||
key = [announcement moxTitle];
|
key = [announcement moxTitle];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDictionary* info = @{
|
NSDictionary* info = @{
|
||||||
NSAccessibilityAnnouncementKey : key ? key : @(""),
|
NSAccessibilityAnnouncementKey : key ? key : @(""),
|
||||||
NSAccessibilityPriorityKey : @(NSAccessibilityPriorityMedium)
|
// High priority means VO will stop what it is currently speaking
|
||||||
|
// to speak our announcement.
|
||||||
|
NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh)
|
||||||
};
|
};
|
||||||
|
|
||||||
id window = [self moxWindow];
|
|
||||||
|
|
||||||
// This sends events via nsIObserverService to be consumed by our
|
// This sends events via nsIObserverService to be consumed by our
|
||||||
// mochitests. Normally we'd fire these events through moxPostNotification
|
// mochitests. Normally we'd fire these events through moxPostNotification
|
||||||
// which takes care of this, but because the window we fetch above isn't
|
// which takes care of this, but because NSApp isn't derived
|
||||||
// derrived from MOXAccessibleBase, we do this (and post the notification)
|
// from MOXAccessibleBase, we do this (and post the notification) manually.
|
||||||
// manually.
|
// We used to fire this on the window, but per Chrome and Safari these
|
||||||
|
// notifs get dropped if fired on any non-main window. We now fire on NSApp
|
||||||
|
// to avoid this.
|
||||||
xpcAccessibleMacEvent::FireEvent(
|
xpcAccessibleMacEvent::FireEvent(
|
||||||
window, NSAccessibilityAnnouncementRequestedNotification, info);
|
NSApp, NSAccessibilityAnnouncementRequestedNotification, info);
|
||||||
NSAccessibilityPostNotificationWithUserInfo(
|
NSAccessibilityPostNotificationWithUserInfo(
|
||||||
window, NSAccessibilityAnnouncementRequestedNotification, info);
|
NSApp, NSAccessibilityAnnouncementRequestedNotification, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue