From 7fabfd3b747c416f138306dd5ff5db19c15c7a91 Mon Sep 17 00:00:00 2001 From: James Teh Date: Tue, 26 Apr 2022 23:15:01 +0000 Subject: [PATCH] Bug 1766142: Expose explicit-name object attribute for cached RemoteAccessibles. r=morgan The cache already includes this info. We just needed to use it when exposing attributes to clients. Differential Revision: https://phabricator.services.mozilla.com/D144684 --- accessible/ipc/RemoteAccessibleBase.cpp | 5 ++++ .../e10s/browser_caching_attributes.js | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/accessible/ipc/RemoteAccessibleBase.cpp b/accessible/ipc/RemoteAccessibleBase.cpp index 2b54358b9478..d72de72b934f 100644 --- a/accessible/ipc/RemoteAccessibleBase.cpp +++ b/accessible/ipc/RemoteAccessibleBase.cpp @@ -641,6 +641,11 @@ already_AddRefed RemoteAccessibleBase::Attributes() { } } + nsAutoString name; + if (Name(name) != eNameFromSubtree && !name.IsVoid()) { + attributes->SetAttribute(nsGkAtoms::explicit_name, true); + } + return attributes.forget(); } diff --git a/accessible/tests/browser/e10s/browser_caching_attributes.js b/accessible/tests/browser/e10s/browser_caching_attributes.js index 880320c92219..915524c131fc 100644 --- a/accessible/tests/browser/e10s/browser_caching_attributes.js +++ b/accessible/tests/browser/e10s/browser_caching_attributes.js @@ -231,3 +231,31 @@ addAccessibleTask( }, { chrome: true, topLevel: true, iframe: true, remoteIframe: true } ); + +/** + * Test caching of the explicit-name attribute. + */ +addAccessibleTask( + ` +

content

+ + + `, + async function(browser, docAcc) { + const h1 = findAccessibleChildByID(docAcc, "h1"); + testAbsentAttrs(h1, { "explicit-name": "" }); + const buttonContent = findAccessibleChildByID(docAcc, "buttonContent"); + testAbsentAttrs(buttonContent, { "explicit-name": "" }); + const buttonLabel = findAccessibleChildByID(docAcc, "buttonLabel"); + testAttrs(buttonLabel, { "explicit-name": "true" }, true); + + info("Setting aria-label on h1"); + let nameChanged = waitForEvent(EVENT_NAME_CHANGE, h1); + await invokeContentTask(browser, [], () => { + content.document.getElementById("h1").setAttribute("aria-label", "label"); + }); + await nameChanged; + testAttrs(h1, { "explicit-name": "true" }, true); + }, + { chrome: true, topLevel: true, iframe: true, remoteIframe: true } +);