Bug 1454866 part 2: Make the buttons in the Site Security panel keyboard navigable. r?johannh draft
authorJames Teh <jteh@mozilla.com>
Mon, 23 Apr 2018 10:42:06 +1000
changeset 791362 506e4adb0fa30a1573c98dc833b035aaa07bfb1a
parent 786363 c663646e1d719bda4ee6750c1d2eaec37575aa84
push id108796
push userbmo:jteh@mozilla.com
push dateFri, 04 May 2018 06:45:28 +0000
reviewersjohannh
bugs1454866
milestone61.0a1
Bug 1454866 part 2: Make the buttons in the Site Security panel keyboard navigable. r?johannh Previously, the only button that could be accessed with the keyboard was the Back button. MozReview-Commit-ID: 2khSExFNkVP
browser/base/content/test/siteIdentity/browser_identityPopup_focus.js
browser/components/controlcenter/content/panel.inc.xul
--- a/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js
+++ b/browser/base/content/test/siteIdentity/browser_identityPopup_focus.js
@@ -20,8 +20,45 @@ add_task(async function testIdentityPopu
     await focused;
     let shown = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
     EventUtils.sendString(" ");
     await shown;
     is(Services.focus.focusedElement, document.getElementById("identity-popup-security-expander"));
   });
 });
 
+// Access the Site Security panel, then move focus with the tab key.
+// Tabbing should be able to reach the More Information button.
+add_task(async function testSiteSecurityTabOrder() {
+  await SpecialPowers.pushPrefEnv({"set": [["accessibility.tabfocus", 7]]});
+  await BrowserTestUtils.withNewTab("https://example.com", async function() {
+    // 1. Access the identity popup.
+    let focused = BrowserTestUtils.waitForEvent(gIdentityHandler._identityBox, "focus");
+    gIdentityHandler._identityBox.focus();
+    await focused;
+    let shown = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "popupshown");
+    EventUtils.sendString(" ");
+    await shown;
+    is(Services.focus.focusedElement, document.getElementById("identity-popup-security-expander"));
+
+    // 2. Access the Site Security section.
+    let securityView = document.getElementById("identity-popup-securityView");
+    shown = BrowserTestUtils.waitForEvent(securityView, "ViewShown");
+    EventUtils.sendString(" ");
+    await shown;
+
+    // 3. First press of tab should focus the Back button.
+    let backButton = gIdentityHandler._identityPopup.querySelector(".subviewbutton-back");
+    // Wait for focus to move somewhere. We use focusin because focus doesn't bubble.
+    focused = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "focusin");
+    EventUtils.sendKey("tab");
+    await focused;
+    is(Services.focus.focusedElement, backButton);
+
+    // 4. Second press of tab should move to the More Information button.
+    let moreInfoButton = document.getElementById("identity-popup-more-info");
+    focused = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "focusin");
+    EventUtils.sendKey("tab");
+    await focused;
+    isnot(Services.focus.focusedElement, backButton);
+    is(Services.focus.focusedElement, moreInfoButton);
+  });
+});
--- a/browser/components/controlcenter/content/panel.inc.xul
+++ b/browser/components/controlcenter/content/panel.inc.xul
@@ -121,16 +121,17 @@
                      class="header"/>
         <description id="identity-popup-content-supplemental"
                      when-connection="secure-ev"/>
         <description id="identity-popup-content-verifier"
                      when-connection="secure secure-ev secure-cert-user-overridden"/>
 
         <!-- Remove Certificate Exception -->
         <button when-connection="secure-cert-user-overridden"
+                class="subviewkeynav"
                 label="&identity.removeCertException.label;"
                 accesskey="&identity.removeCertException.accesskey;"
                 oncommand="gIdentityHandler.removeCertException()"/>
 
         <!-- Connection is Not Secure -->
         <description when-connection="not-secure"
                      and-when-loginforms="secure">&identity.description.insecure;</description>
 
@@ -162,27 +163,28 @@
         <description when-mixedcontent="active-loaded"
                      and-when-loginforms="secure">&identity.description.activeLoaded2; <label observes="identity-popup-mcb-learn-more"/></description>
         <!-- Show only the first message when there are insecure login forms,
              and make sure the Learn More link is included. -->
         <description when-mixedcontent="active-loaded"
                      and-when-loginforms="insecure">&identity.description.activeLoaded; <label observes="identity-popup-mcb-learn-more"/></description>
 
         <!-- Buttons to enable/disable mixed content blocking. -->
-        <button when-mixedcontent="active-blocked"
+        <button when-mixedcontent="active-blocked" class="subviewkeynav"
                 label="&identity.disableMixedContentBlocking.label;"
                 accesskey="&identity.disableMixedContentBlocking.accesskey;"
                 oncommand="gIdentityHandler.disableMixedContentProtection()"/>
-        <button when-mixedcontent="active-loaded"
+        <button when-mixedcontent="active-loaded" class="subviewkeynav"
                 label="&identity.enableMixedContentBlocking.label;"
                 accesskey="&identity.enableMixedContentBlocking.accesskey;"
                 oncommand="gIdentityHandler.enableMixedContentProtection()"/>
       </vbox>
 
       <vbox id="identity-popup-securityView-footer">
         <!-- More Security Information -->
-        <button label="&identity.moreInfoLinkText2;"
+        <button id="identity-popup-more-info"  class="subviewkeynav"
+                label="&identity.moreInfoLinkText2;"
                 oncommand="gIdentityHandler.handleMoreInfoClick(event);"/>
       </vbox>
 
     </panelview>
   </panelmultiview>
 </panel>