Backed out changeset f7afd5cab91c (bug 1960416) for causing bustages at TreeWalker.cpp.

This commit is contained in:
Butkovits Atila
2025-04-23 04:20:06 +03:00
parent c69f13365f
commit 5f164c40f8
4 changed files with 31 additions and 126 deletions

View File

@@ -1612,22 +1612,6 @@ bool aria::IsValidARIAHidden(nsIContent* aContent) {
!ShouldIgnoreARIAHidden(aContent);
}
bool aria::IsValidARIAHidden(DocAccessible* aDocAcc) {
nsCOMPtr<nsIContent> docContent = aDocAcc->GetContent();
// First, check if our Doc Accessible has aria-hidden set on its content
bool isValid = IsValidARIAHidden(docContent);
// If our Doc Accessible was created using an element other than the
// root element, we need to verify the validity of any aria-hidden on
// the root element as well.
auto* rootElement = aDocAcc->DocumentNode()->GetRootElement();
if (docContent != rootElement) {
isValid |= IsValidARIAHidden(rootElement);
}
return isValid;
}
bool aria::ShouldIgnoreARIAHidden(nsIContent* aContent) {
if (!aContent) {
return false;

View File

@@ -10,7 +10,6 @@
#include "ARIAStateMap.h"
#include "mozilla/a11y/AccTypes.h"
#include "mozilla/a11y/DocAccessible.h"
#include "mozilla/a11y/Role.h"
#include "nsAtom.h"
@@ -311,14 +310,6 @@ uint8_t AttrCharacteristicsFor(nsAtom* aAtom);
*/
bool IsValidARIAHidden(nsIContent* aContent);
/**
* This function calls into the function above. It verifies the validity
* of any `aria-hidden` specified on the given Doc Accessible's
* mContent, as well as on the root element of mContent's owner
* doc.
*/
bool IsValidARIAHidden(DocAccessible* aDocAcc);
/**
* Return true if the element should render its subtree
* regardless of the presence of aria-hidden.

View File

@@ -323,8 +323,7 @@ LocalAccessible* TreeWalker::AccessibleFor(nsIContent* aNode, uint32_t aFlags,
}
// Create an accessible if allowed.
if (!(aFlags & eWalkCache) && mContext->IsAcceptableChild(aNode) &&
!aria::IsValidARIAHidden(mDoc)) {
if (!(aFlags & eWalkCache) && mContext->IsAcceptableChild(aNode)) {
mDoc->RelocateARIAOwnedIfNeeded(aNode);
return GetAccService()->CreateAccessible(aNode, mContext, aSkipSubtree);
}

View File

@@ -7,75 +7,8 @@
loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
/**
* Verify loading an iframe document with aria-hidden specified on the root element
* correctly hides the root element and its content. This test is meaninfully
* different than testIframeDocument which tests aria-hidden specified on the
* body element.
*/
addAccessibleTask(
`hello world`,
async function testIframeRootDocument(browser) {
info("Loading iframe document");
const HIDDEN_IFRAME_URI =
"data:text/html,<html id='new_html' aria-hidden='true'><body id='iframeBody'><u>hello world</u></body></html>";
const loaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, "iframeBody");
await SpecialPowers.spawn(
browser,
[DEFAULT_IFRAME_ID, HIDDEN_IFRAME_URI],
(_id, _uri) => {
content.document.getElementById(_id).src = _uri;
}
);
await loaded;
const tree = {
INTERNAL_FRAME: [
{
DOCUMENT: [],
},
],
};
const root = getRootAccessible(document);
const iframeDoc = findAccessibleChildByID(root, DEFAULT_IFRAME_ID);
testAccessibleTree(iframeDoc, tree);
},
{
chrome: false,
topLevel: false,
iframe: true,
remoteIframe: true,
}
);
/**
* Verify loading a tab document with aria-hidden specified on the root element
* correctly renders the root element and its content. This test is meaninfully
* different than testTabDocument which tests aria-hidden specified on the
* body element.
*/
addAccessibleTask(
`<html aria-hidden="true"><u>hello world`,
async function testTabRootDocument(_, accDoc) {
const tree = {
DOCUMENT: [
{
TEXT_LEAF: [],
},
],
};
testAccessibleTree(accDoc, tree);
},
{
chrome: true,
topLevel: true,
iframe: false,
remoteIframe: false,
}
);
/**
* Verify loading a tab doc with aria-hidden on the body renders the document.
* Body elements inside of embedded iframes, should continue
* Verify loading a root doc with aria-hidden renders the document.
* Non-root doc elements, like embedded iframes, should continue
* to respect aria-hidden when present. This test ONLY tests
* tab documents, it should not run in iframes. There is a separate
* test for iframes below.
@@ -203,9 +136,9 @@ addAccessibleTask(
{ chrome: false, topLevel: false, iframe: true, remoteIframe: true }
);
///////////////////////////////
//////////////////// SVG Tests
//////////////////////////////
// // ///////////////////////////////
// // //////////////////// SVG Tests
// // //////////////////////////////
const SVG_DOCUMENT_ID = "rootSVG";
const HIDDEN_SVG_URI =
@@ -247,34 +180,32 @@ addAccessibleTask(
{ chrome: true, topLevel: true, iframe: false, remoteIframe: false }
);
/**
* Verify loading an SVG document with aria-hidden=true
* in an iframe does not render the document subtree.
*/
addAccessibleTask(
`hello world`,
async function testSVGIframeDocument(browser) {
info("Loading SVG");
const loaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, SVG_DOCUMENT_ID);
await SpecialPowers.spawn(
browser,
[DEFAULT_IFRAME_ID, HIDDEN_SVG_URI],
(_id, _uri) => {
content.document.getElementById(_id).src = _uri;
}
);
await loaded;
///////////
///// TODO: Bug 1960416
//////////
// /**
// * Verify loading an SVG document with aria-hidden=true
// * in an iframe does not render the document subtree.
// */
// addAccessibleTask(
// `hello world`,
// async function testSVGIframeDocument(browser) {
// info("Loading SVG");
// const loaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, SVG_DOCUMENT_ID);
// await SpecialPowers.spawn(browser, [DEFAULT_IFRAME_ID, HIDDEN_SVG_URI], (_id,_uri) => {
// content.document.getElementById(_id).src = _uri;
// });
// await loaded;
const tree = {
DOCUMENT: [],
};
const root = getRootAccessible(document);
const svgRoot = findAccessibleChildByID(root, SVG_DOCUMENT_ID);
testAccessibleTree(svgRoot, tree);
},
{ chrome: false, topLevel: false, iframe: true, remoteIframe: true }
);
// const tree = {
// DOCUMENT: [],
// };
// const root = getRootAccessible(document);
// const svgRoot = findAccessibleChildByID(root, SVG_DOCUMENT_ID);
// testAccessibleTree(svgRoot, tree);
// },
// { chrome: false, topLevel: false, iframe: true, remoteIframe: true }
// );
/**
* Verify adding aria-hidden to root svg elements has no effect.