Commit f609ae8e authored by James Teh's avatar James Teh
Browse files

Bug 1642258: Allow role="alert" on the body of chrome documents (but not...

Bug 1642258: Allow role="alert" on the body of chrome documents (but not content documents). r=MarcoZ, a=jcristau

Also fixes a typo in an existing test that meant we weren't actually testing as intended.

Differential Revision: https://phabricator.services.mozilla.com/D77628
parent 2e776f8f
......@@ -2652,7 +2652,11 @@ void DocAccessible::ARIAActiveDescendantIDMaybeMoved(dom::Element* aElm) {
void DocAccessible::SetRoleMapEntryForDoc(dom::Element* aElement) {
const nsRoleMapEntry* entry = aria::GetRoleMap(aElement);
if (!entry || entry->role == roles::APPLICATION ||
entry->role == roles::DIALOG) {
entry->role == roles::DIALOG ||
// Role alert isn't valid on the body element according to the ARIA spec,
// but it's useful for our UI; e.g. the WebRTC sharing indicator.
(entry->role == roles::ALERT &&
!nsCoreUtils::IsContentDocument(mDocumentNode))) {
SetRoleMapEntry(entry);
return;
}
......
[DEFAULT]
support-files =
chrome_body_role_alert.xhtml
!/accessible/tests/mochitest/*.js
!/accessible/tests/mochitest/moz.png
......
<?xml version="1.0"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<body role="alert">
</body>
</html>
......@@ -22,7 +22,7 @@
testRole(docAcc, role);
}
function doTest() {
async function doTest() {
// ARIA role map.
testRole("aria_alert", ROLE_ALERT);
testRole("aria_alertdialog", ROLE_DIALOG);
......@@ -190,10 +190,23 @@
// Test initial ARIA roles on the body element.
testBodyRole("iframe_aria_application", ROLE_APPLICATION);
testBodyRole("iframe_aria_dialog", ROLE_DIALOG);
// role="alert" is valid on the body of chrome documents.
let win = Services.ww.openWindow(
null,
"chrome://mochitests/content/a11y/accessible/tests/mochitest/role/chrome_body_role_alert.xhtml",
"_blank",
"chrome",
[]
);
await SimpleTest.promiseFocus(win);
testRole(win.document, ROLE_ALERT);
win.close();
// Other roles aren't valid on body elements.
testBodyRole("iframe_aria_document", ROLE_DOCUMENT);
testBodyRole("iframe_aria_button", ROLE_DOCUMENT);
testBodyRole("iframe_aria_button", ROLE_DOCUMENT);
testBodyRole("iframe_aria_main", ROLE_DOCUMENT);
// role="alert" is not valid on the body of content documents.
testBodyRole("iframe_aria_alert", ROLE_DOCUMENT);
SimpleTest.finish();
}
......@@ -420,5 +433,7 @@
src="data:text/html,<body role='button'>"></iframe>
<iframe id="iframe_aria_main"
src="data:text/html,<body role='main'>"></iframe>
<iframe id="iframe_aria_alert"
src="data:text/html,<body role='alert'>"></iframe>
</body>
</html>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment