From dbc30ace8463ce0b2cfb9c662d6695b3dbef3537 Mon Sep 17 00:00:00 2001 From: Morgan Reschenberg Date: Thu, 12 Nov 2020 23:40:02 +0000 Subject: [PATCH] Bug 1676878: Modify moxLabel to not strip first character for outlines r=eeejay Differential Revision: https://phabricator.services.mozilla.com/D96895 --- accessible/mac/mozTableAccessible.mm | 8 +++- .../tests/browser/mac/browser_outline.js | 38 ++++++++++++++++--- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/accessible/mac/mozTableAccessible.mm b/accessible/mac/mozTableAccessible.mm index 6568afa884af..87b69de6aba1 100644 --- a/accessible/mac/mozTableAccessible.mm +++ b/accessible/mac/mozTableAccessible.mm @@ -554,8 +554,12 @@ using namespace mozilla::a11y; } else { mGeckoAccessible.AsProxy()->Name(title); } - // remove listmarker for clean label - return nsCocoaUtils::ToNSString(Substring(title, 1, title.Length())); + // XXX: When parsing outlines built with ul/lu's, we + // include the bullet in this description even + // though webkit doesn't. Not all outlines are built with + // ul/lu's so we can't strip the first character here. + + return nsCocoaUtils::ToNSString(title); } @end diff --git a/accessible/tests/browser/mac/browser_outline.js b/accessible/tests/browser/mac/browser_outline.js index 09736fa6af47..5651e29f14c5 100644 --- a/accessible/tests/browser/mac/browser_outline.js +++ b/accessible/tests/browser/mac/browser_outline.js @@ -242,11 +242,6 @@ addAccessibleTask( is(outChildren[1].getAttributeValue("AXSubrole"), "AXOutlineRow"); const outRows = outline.getAttributeValue("AXRows"); - for (let i = 0; i < outRows.length; i++) { - console.log(i); - console.log(outRows[i].getAttributeValue("AXDescription")); - console.log("\n"); - } is(outRows.length, 9, "Outline has nine rows"); is( outRows[0].getAttributeValue("AXDisclosing"), @@ -374,3 +369,36 @@ addAccessibleTask( ); } ); + +// Test outline that isn't built with li/uls gets correct desc +addAccessibleTask( + ` +
+ + +
+ `, + async (browser, accDoc) => { + const tree = getNativeInterface(accDoc, "tree"); + is(tree.getAttributeValue("AXRole"), "AXOutline", "Correct role for tree"); + + const treeItems = tree.getAttributeValue("AXChildren"); + is(treeItems.length, 2, "Outline has two direct children"); + is(treeItems[0].getAttributeValue("AXSubrole"), "AXOutlineRow"); + is(treeItems[1].getAttributeValue("AXSubrole"), "AXOutlineRow"); + + const outRows = tree.getAttributeValue("AXRows"); + is(outRows.length, 2, "Outline has two rows"); + + is( + outRows[0].getAttributeValue("AXDescription"), + "My files", + "files labelled correctly" + ); + is( + outRows[1].getAttributeValue("AXDescription"), + "Shared items", + "shared items labelled correctly" + ); + } +);