Bug 1660365: Fix a11y dialog role placement for the Print modal. r=Gijs

Previously, the browser dialogTemplate contained role="dialog" and the Print modal body had no role.
This caused screen readers to extraneously report "dialog, Print grouping".
Dialogs presented with commonDialog.xhtml (e.g. using Services.prompt.alertBC) did have the dialog role on the body, so screen readers would report "dialog, {dialogTitle} dialog".

To fix this, remove role="dialog" from dialogTemplate.
Instead, SubDialog now sets role="dialog" on the dialog document when it loads.
Now, screen readers report just "Print dialog" and "{dialogTitle} dialog", respectively.

Differential Revision: https://phabricator.services.mozilla.com/D87977
This commit is contained in:
James Teh 2020-08-24 12:07:50 +00:00
parent f30d80c39a
commit 4f869a9ad6
2 changed files with 7 additions and 2 deletions

View File

@ -382,8 +382,7 @@
<html:template id="dialogStackTemplate">
<stack class="dialogStack tab-dialog-box" hidden="true">
<vbox class="dialogTemplate dialogOverlay" align="center" topmost="true" hidden="true">
<hbox class="dialogBox"
role="dialog">
<hbox class="dialogBox">
<browser class="dialogFrame"
autoscroll="false"
disablehistory="true"/>

View File

@ -381,6 +381,12 @@ SubDialog.prototype = {
// the dialog's load event.
this._overlay.style.visibility = "visible";
this._overlay.style.opacity = "0.01";
// Ensure the document gets an a11y role of dialog.
const a11yDoc =
this._frame.contentDocument.body ||
this._frame.contentDocument.documentElement;
a11yDoc.setAttribute("role", "dialog");
},
async _onLoad(aEvent) {