Bug 1425541: Expose reader mode state on the browser accessible using a "reader" object attribute. r=eeejay,Gijs
authorJames Teh <jteh@mozilla.com>
Fri, 15 Dec 2017 14:47:01 -0600
changeset 453681 a6004a75d2d3e5fe04b4d9920cd2e90080784c59
parent 453680 68c68173378867d3a4b11c5a6bad6270a556d2de
child 453688 e4107773cffb1baefd5446666fce22c4d6eb0517
child 453691 fcad66c3d2e2e1443c9fd1c59423f40cc77acdff
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay, Gijs
bugs1425541
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425541: Expose reader mode state on the browser accessible using a "reader" object attribute. r=eeejay,Gijs This makes it easy for accessibility clients to retrieve the reader mode state programmatically. There are three possibilities: 1. Reader mode is available for the current page (reader:available). 2. Reader mode is being used now (reader:active). 3. Reader is not available (the reader attribute is not present). We do this by setting/removing the aria-reader attribute on the node. This is not a real ARIA attribute, but it causes Gecko to expose it as an object attribute. MozReview-Commit-ID: B38G3AYyBnS
browser/modules/ReaderParent.jsm
--- a/browser/modules/ReaderParent.jsm
+++ b/browser/modules/ReaderParent.jsm
@@ -53,34 +53,44 @@ var ReaderParent = {
     let win = browser.ownerGlobal;
     if (browser != win.gBrowser.selectedBrowser) {
       return;
     }
 
     let button = win.document.getElementById("reader-mode-button");
     let command = win.document.getElementById("View:ReaderView");
     let key = win.document.getElementById("key_toggleReaderMode");
+    // aria-reader is not a real ARIA attribute. However, this will cause
+    // Gecko accessibility to expose the "reader" object attribute. We do this
+    // so that the reader state is easy for accessibility clients to access
+    // programmatically.
     if (browser.currentURI.spec.startsWith("about:reader")) {
       button.setAttribute("readeractive", true);
       button.hidden = false;
       let closeText = gStringBundle.GetStringFromName("readerView.close");
       button.setAttribute("tooltiptext", closeText);
       command.setAttribute("label", closeText);
       command.setAttribute("hidden", false);
       command.setAttribute("accesskey", gStringBundle.GetStringFromName("readerView.close.accesskey"));
       key.setAttribute("disabled", false);
+      browser.setAttribute("aria-reader", "active");
     } else {
       button.removeAttribute("readeractive");
       button.hidden = !browser.isArticle;
       let enterText = gStringBundle.GetStringFromName("readerView.enter");
       button.setAttribute("tooltiptext", enterText);
       command.setAttribute("label", enterText);
       command.setAttribute("hidden", !browser.isArticle);
       command.setAttribute("accesskey", gStringBundle.GetStringFromName("readerView.enter.accesskey"));
       key.setAttribute("disabled", !browser.isArticle);
+      if (browser.isArticle) {
+        browser.setAttribute("aria-reader", "available");
+      } else {
+        browser.removeAttribute("aria-reader");
+      }
     }
   },
 
   forceShowReaderIcon(browser) {
     browser.isArticle = true;
     this.updateReaderButton(browser);
   },