Bug 1335018 - Make the side identity popup adhere to role=alertdialog for a11y. r=Gijs, r=MarcoZ, a=jcristau
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 09 Feb 2017 17:16:28 +0100
changeset 378607 32f96350bb4964b1f111edb9b3746fb3c0dcbda1
parent 378606 67d78fdd865dedbc6049cb8da3ab2e4841ea88ca
child 378608 d4e8a7b1832dc6cfe52b8a9dcf0133b2733418cb
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, MarcoZ, jcristau
bugs1335018
milestone53.0a2
Bug 1335018 - Make the side identity popup adhere to role=alertdialog for a11y. r=Gijs, r=MarcoZ, a=jcristau 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
@@ -7307,16 +7307,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>