Bug 1335018 - Make the side identity popup adhere to role=alertdialog for a11y. r=Gijs,MarcoZ draft
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 09 Feb 2017 17:16:28 +0100
changeset 483557 932d597e9e37235259e8e1060b3eeba57995992a
parent 483291 195049fabb7ac5709e5f75614ba630ba3d1b5a9b
child 545666 2e0d816e8bb58873a580e3a3752ead26ff299a8f
push id45342
push userbmo:jhofmann@mozilla.com
push dateTue, 14 Feb 2017 14:52:06 +0000
reviewersGijs, MarcoZ
bugs1335018
milestone54.0a1
Bug 1335018 - Make the side identity popup adhere to role=alertdialog for a11y. r=Gijs,MarcoZ MozReview-Commit-ID: DpqeeN570H9
browser/base/content/browser.js
browser/components/controlcenter/content/panel.inc.xul
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7280,16 +7280,21 @@ var gIdentityHandler = {
     this._identityBox.setAttribute("open", "true");
 
     // Now open the popup, anchored off the primary chrome element
     this._identityPopup.openPopup(this._identityIcon, "bottomcenter topleft");
   },
 
   onPopupShown(event) {
     if (event.target == this._identityPopup) {
+      // Move focus to the next available element in the identity popup.
+      // This is required by role=alertdialog and fixes an issue where
+      // an already open panel would steal focus from the identity popup.
+      document.commandDispatcher.advanceFocusIntoSubtree(this._identityPopup);
+
       window.addEventListener("focus", this, true);
     }
   },
 
   onPopupHidden(event) {
     if (event.target == this._identityPopup) {
       window.removeEventListener("focus", this, true);
       this._identityBox.removeAttribute("open");
--- a/browser/components/controlcenter/content/panel.inc.xul
+++ b/browser/components/controlcenter/content/panel.inc.xul
@@ -1,15 +1,16 @@
 <!-- This Source Code Form is subject to the terms of the Mozilla Public
    - License, v. 2.0. If a copy of the MPL was not distributed with this
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <panel id="identity-popup"
        type="arrow"
        hidden="true"
+       role="alertdialog"
        onpopupshown="gIdentityHandler.onPopupShown(event);"
        onpopuphidden="gIdentityHandler.onPopupHidden(event);"
        orient="vertical">
 
   <broadcasterset>
     <broadcaster id="identity-popup-mcb-learn-more" class="text-link plain" value="&identity.learnMore;"/>
     <broadcaster id="identity-popup-insecure-login-forms-learn-more" class="text-link plain" value="&identity.learnMore;"/>
   </broadcasterset>