From 1c31973d81e98d99cd300b34644cadd52e77a749 Mon Sep 17 00:00:00 2001 From: Morgan Reschenberg Date: Tue, 29 Sep 2020 18:48:34 +0000 Subject: [PATCH] Bug 1666356: Add support for AXCheckboxSearchKey to VO rotor r=eeejay Differential Revision: https://phabricator.services.mozilla.com/D91169 --- accessible/mac/MOXSearchInfo.mm | 8 +++ accessible/tests/browser/mac/browser_rotor.js | 69 +++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/accessible/mac/MOXSearchInfo.mm b/accessible/mac/MOXSearchInfo.mm index 6efca38c4b81..8267b6b8cd87 100644 --- a/accessible/mac/MOXSearchInfo.mm +++ b/accessible/mac/MOXSearchInfo.mm @@ -213,6 +213,14 @@ using namespace mozilla::a11y; : RotorRoleRule(roles::GRAPHIC); [matches addObjectsFromArray:[self getMatchesForRule:rule]]; } + + if ([key isEqualToString:@"AXCheckboxSearchKey"]) { + RotorRoleRule rule = + mImmediateDescendantsOnly + ? RotorRoleRule(roles::CHECKBUTTON, geckoStartAcc) + : RotorRoleRule(roles::CHECKBUTTON); + [matches addObjectsFromArray:[self getMatchesForRule:rule]]; + } } return matches; diff --git a/accessible/tests/browser/mac/browser_rotor.js b/accessible/tests/browser/mac/browser_rotor.js index d428992140ca..4452cda973c5 100644 --- a/accessible/tests/browser/mac/browser_rotor.js +++ b/accessible/tests/browser/mac/browser_rotor.js @@ -1049,6 +1049,75 @@ addAccessibleTask( } ); +/** + * Test rotor with checkboxes + */ +addAccessibleTask( + ` +
+ Checkboxes + Checkbox 1 + Checkbox 2 + + +
+ `, + async (browser, accDoc) => { + const searchPred = { + AXSearchKey: "AXCheckboxSearchKey", + AXImmediateDescendantsOnly: 0, + AXResultsLimit: -1, + AXDirection: "AXDirectionNext", + }; + + const webArea = accDoc.nativeInterface.QueryInterface( + Ci.nsIAccessibleMacInterface + ); + is( + webArea.getAttributeValue("AXRole"), + "AXWebArea", + "Got web area accessible" + ); + + const checkboxCount = webArea.getParameterizedAttributeValue( + "AXUIElementCountForSearchPredicate", + NSDictionary(searchPred) + ); + is(4, checkboxCount, "Found 4 checkboxes"); + + const checkboxes = webArea.getParameterizedAttributeValue( + "AXUIElementsForSearchPredicate", + NSDictionary(searchPred) + ); + + const checkbox1 = getNativeInterface(accDoc, "checkbox1"); + const checkbox2 = getNativeInterface(accDoc, "checkbox2"); + const checkbox3 = getNativeInterface(accDoc, "checkbox3"); + const checkbox4 = getNativeInterface(accDoc, "checkbox4"); + + is( + checkbox1.getAttributeValue("AXValue"), + checkboxes[0].getAttributeValue("AXValue"), + "Found correct checkbox 1" + ); + is( + checkbox2.getAttributeValue("AXValue"), + checkboxes[1].getAttributeValue("AXValue"), + "Found correct checkbox 2" + ); + is( + checkbox3.getAttributeValue("AXValue"), + checkboxes[2].getAttributeValue("AXValue"), + "Found correct checkbox 3" + ); + is( + checkbox4.getAttributeValue("AXValue"), + checkboxes[3].getAttributeValue("AXValue"), + "Found correct checkbox 4" + ); + } +); + /** * Test rotor with radiogroups */