Bug 1570630 - Removes query parameters in site identity panel header.r=johannh
authorCarolina <carolina.jimenez.g@gmail.com>
Mon, 12 Aug 2019 13:35:51 +0000
changeset 487445 abb9c317a9e2afc49da431f9f9cc410311f475f6
parent 487444 ff9a7905d22c72383d51ab04f18981fde2c40e0b
child 487446 7dbe4c9716a7889ff95333ad0410e7bb2fa22318
push id36422
push usermalexandru@mozilla.com
push dateMon, 12 Aug 2019 21:51:10 +0000
treeherdermozilla-central@076dd880cd67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1570630
milestone70.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 1570630 - Removes query parameters in site identity panel header.r=johannh Differential Revision: https://phabricator.services.mozilla.com/D40723
browser/base/content/browser-siteIdentity.js
browser/base/content/test/siteIdentity/browser_identity_UI.js
--- a/browser/base/content/browser-siteIdentity.js
+++ b/browser/base/content/browser-siteIdentity.js
@@ -621,16 +621,24 @@ var gIdentityHandler = {
     let host = "";
 
     try {
       host = this.getEffectiveHost();
     } catch (e) {
       // Some URIs might have no hosts.
     }
 
+    if (this._uri.schemeIs("about")) {
+      // For example in about:certificate the original URL is
+      // about:certificate?cert=<large base64 encoded data>&cert=<large base64 encoded data>&cert=...
+      // So, instead of showing that large string in the identity panel header, we are just showing
+      // about:certificate now. For the other about pages we are just showing about:<page>
+      host = "about:" + this._uri.filePath;
+    }
+
     let readerStrippedURI = ReaderMode.getOriginalUrlObjectForDisplay(
       this._uri.displaySpec
     );
     if (readerStrippedURI) {
       host = readerStrippedURI.host;
     }
 
     if (this._pageExtensionPolicy) {
--- a/browser/base/content/test/siteIdentity/browser_identity_UI.js
+++ b/browser/base/content/test/siteIdentity/browser_identity_UI.js
@@ -1,55 +1,66 @@
-/* Tests for correct behaviour of getEffectiveHost on identity handler */
+/* Tests for correct behaviour of getHostForDisplay on identity handler */
 
 requestLongerTimeout(2);
 
 // Greek IDN for 'example.test'.
 var idnDomain =
   "\u03C0\u03B1\u03C1\u03AC\u03B4\u03B5\u03B9\u03B3\u03BC\u03B1.\u03B4\u03BF\u03BA\u03B9\u03BC\u03AE";
 var tests = [
   {
     name: "normal domain",
     location: "http://test1.example.org/",
-    effectiveHost: "test1.example.org",
+    hostForDisplay: "test1.example.org",
   },
   {
     name: "view-source",
     location: "view-source:http://example.com/",
-    effectiveHost: null,
+    hostForDisplay: null,
   },
   {
     name: "normal HTTPS",
     location: "https://example.com/",
-    effectiveHost: "example.com",
+    hostForDisplay: "example.com",
   },
   {
     name: "IDN subdomain",
     location: "http://sub1.xn--hxajbheg2az3al.xn--jxalpdlp/",
-    effectiveHost: "sub1." + idnDomain,
+    hostForDisplay: "sub1." + idnDomain,
   },
   {
     name: "subdomain with port",
     location: "http://sub1.test1.example.org:8000/",
-    effectiveHost: "sub1.test1.example.org",
+    hostForDisplay: "sub1.test1.example.org",
   },
   {
     name: "subdomain HTTPS",
     location: "https://test1.example.com/",
-    effectiveHost: "test1.example.com",
+    hostForDisplay: "test1.example.com",
   },
   {
     name: "view-source HTTPS",
     location: "view-source:https://example.com/",
-    effectiveHost: null,
+    hostForDisplay: null,
   },
   {
     name: "IP address",
     location: "http://127.0.0.1:8888/",
-    effectiveHost: "127.0.0.1",
+    hostForDisplay: "127.0.0.1",
+  },
+  {
+    name: "about:certificate",
+    location:
+      "about:certificate?cert=MIIHQjCCBiqgAwIBAgIQCgYwQn9bvO&cert=1pVzllk7ZFHzANBgkqhkiG9w0BAQ",
+    hostForDisplay: "about:certificate",
+  },
+  {
+    name: "about:reader",
+    location: "about:reader?url=http://example.com",
+    hostForDisplay: "example.com",
   },
 ];
 
 add_task(async function test() {
   ok(gIdentityHandler, "gIdentityHandler should exist");
 
   await BrowserTestUtils.openNewForegroundTab(gBrowser);
 
@@ -92,44 +103,44 @@ async function runTest(i, forward) {
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser, currentTest.location);
   await loaded;
   await popupHidden;
   ok(
     BrowserTestUtils.is_hidden(gIdentityHandler._identityPopup),
     "Control Center is hidden"
   );
 
-  // Sanity check other values, and the value of gIdentityHandler.getEffectiveHost()
+  // Sanity check other values, and the value of gIdentityHandler.getHostForDisplay()
   is(
     gIdentityHandler._uri.spec,
     currentTest.location,
     "location matches for test " + testDesc
   );
-  // getEffectiveHost can't be called for all modes
-  if (currentTest.effectiveHost !== null) {
+  // getHostForDisplay can't be called for all modes
+  if (currentTest.hostForDisplay !== null) {
     is(
-      gIdentityHandler.getEffectiveHost(),
-      currentTest.effectiveHost,
-      "effectiveHost matches for test " + testDesc
+      gIdentityHandler.getHostForDisplay(),
+      currentTest.hostForDisplay,
+      "hostForDisplay matches for test " + testDesc
     );
   }
 
   // Open the Control Center and make sure it closes after nav (Bug 1207542).
   let popupShown = BrowserTestUtils.waitForEvent(
     gIdentityHandler._identityPopup,
     "popupshown"
   );
   gIdentityHandler._identityBox.click();
   info("Waiting for the Control Center to be shown");
   await popupShown;
   ok(
     !BrowserTestUtils.is_hidden(gIdentityHandler._identityPopup),
     "Control Center is visible"
   );
-  let displayedHost = currentTest.effectiveHost || currentTest.location;
+  let displayedHost = currentTest.hostForDisplay || currentTest.location;
   ok(
     gIdentityHandler._identityPopupMainViewHeaderLabel.textContent.includes(
       displayedHost
     ),
     "identity UI header shows the host for test " + testDesc
   );
 
   // Show the subview, which is an easy way in automation to reproduce