Bug 1511834 - Improving site Information header in reader mode r=johannh
authorneha <ns19041997@gmail.com>
Thu, 07 Mar 2019 12:36:51 +0000
changeset 521378 5a14eec92d6e422f452505dbffbf84862fc74af9
parent 521377 034dbb475f6dc7bb2f839a6ead75d4fd0abf8e2a
child 521379 b015322cb7795419db78fe072e3b56d7106b8e0e
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1511834
milestone67.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 1511834 - Improving site Information header in reader mode r=johannh Differential Revision: https://phabricator.services.mozilla.com/D21869
browser/base/content/browser-siteIdentity.js
browser/base/content/test/siteIdentity/browser_check_identity_state.js
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -738,16 +738,21 @@ var gIdentityHandler = {
     let owner = "";
 
     try {
       host = this.getEffectiveHost();
     } catch (e) {
       // Some URIs might have no hosts.
     }
 
+    let readerStrippedURI = ReaderMode.getOriginalUrlObjectForDisplay(this._uri.displaySpec);
+    if (readerStrippedURI) {
+      host = readerStrippedURI.host;
+    }
+
     if (this._pageExtensionPolicy) {
       host = this._pageExtensionPolicy.name;
     }
 
     // Fallback for special protocols.
     if (!host) {
       host = this._uri.specIgnoringRef;
     }
--- a/browser/base/content/test/siteIdentity/browser_check_identity_state.js
+++ b/browser/base/content/test/siteIdentity/browser_check_identity_state.js
@@ -19,16 +19,23 @@ function getIdentityMode(aWindow = windo
 
 function getConnectionState() {
   // Prevents items that are being lazy loaded causing issues
   document.getElementById("identity-box").click();
   gIdentityHandler.refreshIdentityPopup();
   return document.getElementById("identity-popup").getAttribute("connection");
 }
 
+function getReaderModeURL() {
+  // Gets the reader mode URL from "identity-popup mainView panel header span"
+  document.getElementById("identity-box").click();
+  gIdentityHandler.refreshIdentityPopup();
+  return document.getElementById("identity-popup-mainView-panel-header-span").innerHTML;
+}
+
 // This test is slow on Linux debug e10s
 requestLongerTimeout(2);
 
 async function webpageTest(secureCheck) {
   await SpecialPowers.pushPrefEnv({set: [[INSECURE_ICON_PREF, secureCheck]]});
   let oldTab = gBrowser.selectedTab;
 
   let newTab = await loadNewTab("http://example.com/" + DUMMY);
@@ -344,16 +351,34 @@ async function aboutUriTest(secureCheck)
   await SpecialPowers.popPrefEnv();
 }
 
 add_task(async function test_about_uri() {
   await aboutUriTest(true);
   await aboutUriTest(false);
 });
 
+async function readerUriTest(secureCheck) {
+  await SpecialPowers.pushPrefEnv({set: [[INSECURE_ICON_PREF, secureCheck]]});
+
+  let newTab = await loadNewTab("about:reader?url=http://example.com");
+  gBrowser.selectedTab = newTab;
+  let readerURL = getReaderModeURL();
+  is(readerURL, "Site Information for example.com", "should be the correct URI in reader mode");
+
+  gBrowser.removeTab(newTab);
+
+  await SpecialPowers.popPrefEnv();
+}
+
+add_task(async function test_reader_uri() {
+  await readerUriTest(true);
+  await readerUriTest(false);
+});
+
 async function dataUriTest(secureCheck) {
   let oldTab = gBrowser.selectedTab;
   await SpecialPowers.pushPrefEnv({set: [[INSECURE_ICON_PREF, secureCheck]]});
   let dataURI = "data:text/html,hi";
 
   let newTab = await loadNewTab(dataURI);
   is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");