diff --git a/accessible/mac/MOXSearchInfo.mm b/accessible/mac/MOXSearchInfo.mm index 16f93df7663d..b4e191a343f2 100644 --- a/accessible/mac/MOXSearchInfo.mm +++ b/accessible/mac/MOXSearchInfo.mm @@ -329,6 +329,13 @@ using namespace mozilla::a11y; : RotorMacRoleRule(@"AXTextField"); [matches addObjectsFromArray:[self getMatchesForRule:rule]]; } + + if ([key isEqualToString:@"AXLiveRegionSearchKey"]) { + RotorLiveRegionRule rule = mImmediateDescendantsOnly + ? RotorLiveRegionRule(geckoRootAcc) + : RotorLiveRegionRule(); + [matches addObjectsFromArray:[self getMatchesForRule:rule]]; + } } return matches; diff --git a/accessible/mac/RotorRules.h b/accessible/mac/RotorRules.h index 536b84556bda..504ac9bf8a00 100644 --- a/accessible/mac/RotorRules.h +++ b/accessible/mac/RotorRules.h @@ -112,3 +112,12 @@ class RotorHeadingLevelRule : public RotorRoleRule { private: int32_t mLevel; }; + +class RotorLiveRegionRule : public RotorRule { + public: + explicit RotorLiveRegionRule(AccessibleOrProxy& aDirectDescendantsFrom) + : RotorRule(aDirectDescendantsFrom) {} + explicit RotorLiveRegionRule() : RotorRule() {} + + uint16_t Match(const AccessibleOrProxy& aAccOrProxy) override; +}; diff --git a/accessible/mac/RotorRules.mm b/accessible/mac/RotorRules.mm index 0b99334f4300..e8c97b850c7c 100644 --- a/accessible/mac/RotorRules.mm +++ b/accessible/mac/RotorRules.mm @@ -307,3 +307,15 @@ uint16_t RotorHeadingLevelRule::Match(const AccessibleOrProxy& aAccOrProxy) { return result; } + +uint16_t RotorLiveRegionRule::Match(const AccessibleOrProxy& aAccOrProxy) { + uint16_t result = RotorRule::Match(aAccOrProxy); + + if ((result & nsIAccessibleTraversalRule::FILTER_MATCH)) { + mozAccessible* nativeMatch = GetNativeFromGeckoAccessible(aAccOrProxy); + if (![nativeMatch moxIsLiveRegion]) { + result &= ~nsIAccessibleTraversalRule::FILTER_MATCH; + } + } + return result; +} diff --git a/accessible/tests/browser/mac/browser_live_regions.js b/accessible/tests/browser/mac/browser_live_regions.js index 43c125391b0b..1ac927968cd7 100644 --- a/accessible/tests/browser/mac/browser_live_regions.js +++ b/accessible/tests/browser/mac/browser_live_regions.js @@ -99,22 +99,22 @@ addAccessibleTask(
`; }); - await loadComplete; + let webArea = (await loadComplete)[0]; - liveRegionRemoved = waitForEvent(EVENT_LIVE_REGION_REMOVED, "status"); - await SpecialPowers.spawn(browser, [], () => { - content.document - .getElementById("status") - .setAttribute("aria-live", "off"); - }); - await liveRegionRemoved; - - liveRegionRemoved = waitForEvent(EVENT_LIVE_REGION_REMOVED, "output"); - await SpecialPowers.spawn(browser, [], () => { - content.document - .getElementById("output") - .setAttribute("aria-live", "off"); - }); - await liveRegionRemoved; + is(webArea.getAttributeValue("AXRole"), "AXWebArea", "web area yeah"); + const searchPred = { + AXSearchKey: "AXLiveRegionSearchKey", + AXResultsLimit: -1, + AXDirection: "AXDirectionNext", + }; + const liveRegions = webArea.getParameterizedAttributeValue( + "AXUIElementsForSearchPredicate", + NSDictionary(searchPred) + ); + Assert.deepEqual( + liveRegions.map(r => r.getAttributeValue("AXDOMIdentifier")), + ["region-1", "region-2", "status", "output"], + "SearchPredicate returned all live regions" + ); } );