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:
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))) {
support-files =
<?xml version="1.0"?>
<!DOCTYPE html>
<html xmlns="">
<body role="alert">
......@@ -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(
await SimpleTest.promiseFocus(win);
testRole(win.document, ROLE_ALERT);
// 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);
......@@ -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>
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