Bug 1178163 - Show connection info for file and data URIs in control center;r=ttaubert
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 28 Jul 2015 14:48:42 -0700
changeset 286852 5f27cc13a2c2e62fb18ee8dc1d5c9bade4862446
parent 286851 aa144e36fab0b56b256b1b54fc053288501091b3
child 286853 b1151fef26d49e5cf1ced478b4b87e117e221ba1
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs1178163
milestone42.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 1178163 - Show connection info for file and data URIs in control center;r=ttaubert
browser/base/content/browser.js
browser/base/content/test/general/browser_bug590206.js
browser/components/controlcenter/content/panel.inc.xul
browser/locales/en-US/chrome/browser/browser.dtd
browser/themes/shared/controlcenter/panel.inc.css
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6630,16 +6630,17 @@ var gIdentityHandler = {
   IDENTITY_MODE_UNKNOWN                                : "unknownIdentity",  // No trusted identity information
   IDENTITY_MODE_USES_WEAK_CIPHER                       : "unknownIdentity weakCipher",  // SSL with RC4 cipher suite or SSL3
   IDENTITY_MODE_MIXED_DISPLAY_LOADED                   : "unknownIdentity mixedContent mixedDisplayContent",  // SSL with unauthenticated display content
   IDENTITY_MODE_MIXED_ACTIVE_LOADED                    : "unknownIdentity mixedContent mixedActiveContent",  // SSL with unauthenticated active (and perhaps also display) content
   IDENTITY_MODE_MIXED_DISPLAY_LOADED_ACTIVE_BLOCKED    : "unknownIdentity mixedContent mixedDisplayContentLoadedActiveBlocked",  // SSL with unauthenticated display content; unauthenticated active content is blocked.
   IDENTITY_MODE_MIXED_ACTIVE_BLOCKED                   : "verifiedDomain mixedContent mixedActiveBlocked",  // SSL with unauthenticated active content blocked; no unauthenticated display content
   IDENTITY_MODE_MIXED_ACTIVE_BLOCKED_IDENTIFIED        : "verifiedIdentity mixedContent mixedActiveBlocked",  // SSL with unauthenticated active content blocked; no unauthenticated display content
   IDENTITY_MODE_CHROMEUI                               : "chromeUI",         // Part of the product's UI
+  IDENTITY_MODE_FILE_URI                               : "fileURI",  // File path
 
   // Cache the most recent SSLStatus and Location seen in checkIdentity
   _lastStatus : null,
   _lastUri : null,
   _mode : "unknownIdentity",
 
   // smart getters
   get _identityPopup () {
@@ -6845,17 +6846,30 @@ var gIdentityHandler = {
       } else if (state & nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT) {
         this.setMode(this.IDENTITY_MODE_MIXED_DISPLAY_LOADED_ACTIVE_BLOCKED);
       } else if (state & nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT) {
         this.setMode(this.IDENTITY_MODE_MIXED_DISPLAY_LOADED);
       } else {
         this.setMode(this.IDENTITY_MODE_USES_WEAK_CIPHER);
       }
     } else {
-      this.setMode(this.IDENTITY_MODE_UNKNOWN);
+      // Create a channel for the sole purpose of getting the resolved URI
+      // of the request to determine if it's loaded from the file system.
+      let resolvedURI = NetUtil.newChannel({uri,loadUsingSystemPrincipal:true}).URI;
+      if (resolvedURI.schemeIs("jar")) {
+        // Given a URI "jar:<jar-file-uri>!/<jar-entry>"
+        // create a new URI using <jar-file-uri>!/<jar-entry>
+        resolvedURI = NetUtil.newURI(resolvedURI.path);
+      }
+
+      if (resolvedURI.schemeIs("file")) {
+        this.setMode(this.IDENTITY_MODE_FILE_URI);
+      } else {
+        this.setMode(this.IDENTITY_MODE_UNKNOWN);
+      }
     }
 
     // Show the doorhanger when:
     // - mixed active content is blocked
     // - mixed active content is loaded (detected but not blocked)
     // - tracking content is blocked
     // - tracking content is not blocked
     if (state &
--- a/browser/base/content/test/general/browser_bug590206.js
+++ b/browser/base/content/test/general/browser_bug590206.js
@@ -1,25 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 const DUMMY = "browser/browser/base/content/test/general/dummy_page.html";
 
 function loadNewTab(aURL, aCallback) {
-  gBrowser.selectedTab = gBrowser.addTab();
-  gBrowser.loadURI(aURL);
-
-  gBrowser.selectedBrowser.addEventListener("load", function() {
-    if (gBrowser.selectedBrowser.currentURI.spec != aURL)
-      return;
-    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
-
-    aCallback(gBrowser.selectedTab);
-  }, true);
+  BrowserTestUtils.openNewForegroundTab(gBrowser, aURL).then(aCallback);
 }
 
 function getIdentityMode() {
   return document.getElementById("identity-box").className;
 }
 
 var TESTS = [
 function test_webpage() {
@@ -56,26 +47,24 @@ function test_blank() {
 
     runNextTest();
   });
 },
 
 function test_chrome() {
   let oldTab = gBrowser.selectedTab;
 
-  // Since users aren't likely to type in full chrome URLs, we won't show
-  // the positive security indicator on it, but we will show it on about:addons.
   loadNewTab("chrome://mozapps/content/extensions/extensions.xul", function(aNewTab) {
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+    is(getIdentityMode(), "fileURI", "Identity should be file");
 
     gBrowser.selectedTab = oldTab;
     is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
 
     gBrowser.selectedTab = aNewTab;
-    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+    is(getIdentityMode(), "fileURI", "Identity should be file");
 
     gBrowser.removeTab(aNewTab);
 
     runNextTest();
   });
 },
 
 function test_https() {
@@ -107,17 +96,74 @@ function test_addons() {
 
     gBrowser.selectedTab = aNewTab;
     is(getIdentityMode(), "chromeUI", "Identity should be chrome");
 
     gBrowser.removeTab(aNewTab);
 
     runNextTest();
   });
-}
+},
+
+function test_file() {
+  let oldTab = gBrowser.selectedTab;
+  let fileURI = getTestFilePath("");
+
+  loadNewTab(fileURI, function(aNewTab) {
+    is(getIdentityMode(), "fileURI", "Identity should be file");
+
+    gBrowser.selectedTab = oldTab;
+    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+
+    gBrowser.selectedTab = aNewTab;
+    is(getIdentityMode(), "fileURI", "Identity should be file");
+
+    gBrowser.removeTab(aNewTab);
+
+    runNextTest();
+  });
+},
+
+function test_resource_uri() {
+  let oldTab = gBrowser.selectedTab;
+  let dataURI = "resource://gre/modules/Services.jsm"
+
+  loadNewTab(dataURI, function(aNewTab) {
+    is(getIdentityMode(), "fileURI", "Identity should be unknown");
+
+    gBrowser.selectedTab = oldTab;
+    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+
+    gBrowser.selectedTab = aNewTab;
+    is(getIdentityMode(), "fileURI", "Identity should be unknown");
+
+    gBrowser.removeTab(aNewTab);
+
+    runNextTest();
+  });
+},
+
+function test_data_uri() {
+  let oldTab = gBrowser.selectedTab;
+  let dataURI = "data:text/html,hi"
+
+  loadNewTab(dataURI, function(aNewTab) {
+    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+
+    gBrowser.selectedTab = oldTab;
+    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+
+    gBrowser.selectedTab = aNewTab;
+    is(getIdentityMode(), "unknownIdentity", "Identity should be unknown");
+
+    gBrowser.removeTab(aNewTab);
+
+    runNextTest();
+  });
+},
 ];
 
 var gTestStart = null;
 
 function runNextTest() {
   if (gTestStart)
     info("Test part took " + (Date.now() - gTestStart) + "ms");
 
--- a/browser/components/controlcenter/content/panel.inc.xul
+++ b/browser/components/controlcenter/content/panel.inc.xul
@@ -22,16 +22,18 @@
         <vbox id="identity-popup-security-content" flex="1">
           <label class="identity-popup-headline" crop="end">
             <observes element="identity-popup-content-host" attribute="value"/>
           </label>
           <label class="identity-popup-connection-secure identity-popup-text"
                  value="&identity.connectionSecure;"/>
           <label class="identity-popup-connection-not-secure identity-popup-text"
                  value="&identity.connectionNotSecure;"/>
+          <label class="identity-popup-connection-file-uri identity-popup-text"
+                 value="&identity.connectionFile;"/>
           <label class="identity-popup-connection-internal identity-popup-text"
                  value="&identity.connectionInternal;"/>
         </vbox>
         <button class="identity-popup-expander"
                 oncommand="gIdentityHandler.toggleSubView('security', this)"/>
       </hbox>
 
       <!-- Tracking Protection Section -->
@@ -90,16 +92,18 @@
       <vbox id="identity-popup-securityView-header">
         <label class="identity-popup-headline" crop="end">
           <observes element="identity-popup-content-host" attribute="value"/>
         </label>
         <label class="identity-popup-connection-secure identity-popup-text"
                value="&identity.connectionSecure;"/>
         <label class="identity-popup-connection-not-secure identity-popup-text"
                value="&identity.connectionNotSecure;"/>
+        <label class="identity-popup-connection-file-uri identity-popup-text"
+               value="&identity.connectionFile;"/>
         <label class="identity-popup-connection-internal identity-popup-text"
                value="&identity.connectionInternal;"/>
       </vbox>
 
       <description id="identity-popup-content-verifier"
                    class="identity-popup-text"/>
 
       <description id="identity-popup-securityView-connection"
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -675,16 +675,17 @@ you can use these alternative items. Oth
 <!ENTITY spellAddDictionaries.accesskey "A">
 
 <!ENTITY editBookmark.done.label                     "Done">
 <!ENTITY editBookmark.cancel.label                   "Cancel">
 <!ENTITY editBookmark.removeBookmark.accessKey       "R">
 
 <!ENTITY identity.connectionSecure "Secure Connection">
 <!ENTITY identity.connectionNotSecure "Connection is Not Secure">
+<!ENTITY identity.connectionFile "This page is stored on your computer.">
 <!ENTITY identity.connectionVerified "&brandShortName; verified that you are securely connected to this site, run by:">
 <!ENTITY identity.connectionInternal "This is a secure &brandShortName; page.">
 
 <!ENTITY identity.moreInfoLinkText2 "More Information">
 
 <!ENTITY identity.permissions "Permissions">
 
 <!-- Name for the tabs toolbar as spoken by screen readers.
--- a/browser/themes/shared/controlcenter/panel.inc.css
+++ b/browser/themes/shared/controlcenter/panel.inc.css
@@ -7,21 +7,26 @@
    connection security. Show the organization address for EV certs. */
 #identity-popup-securityView:not(.unknownIdentity):not(.verifiedIdentity):not(.mixedContent):not(.weakCipher) > #identity-popup-content-supplemental,
 /* Show the "Connection is secure" labels only for EV and DV certs. */
 #identity-popup-security-content:not(.verifiedIdentity):not(.verifiedDomain) > .identity-popup-connection-secure,
 #identity-popup-securityView:not(.verifiedIdentity):not(.verifiedDomain) > #identity-popup-securityView-header > .identity-popup-connection-secure,
 /* Show the "Connection is not secure" labels only for non-secure sites. */
 #identity-popup-security-content:not(.unknownIdentity) > .identity-popup-connection-not-secure,
 #identity-popup-securityView:not(.unknownIdentity) > #identity-popup-securityView-header > .identity-popup-connection-not-secure,
+/* Show "This page is stored on your computer" only for file URLs. */
+#identity-popup-security-content:not(.fileURI) > .identity-popup-connection-file-uri,
+#identity-popup-securityView:not(.fileURI) > #identity-popup-securityView-header > .identity-popup-connection-file-uri,
 /* Show "This is a secure internal page" only for whitelisted pages. */
 #identity-popup-securityView:not(.chromeUI) > #identity-popup-securityView-header > .identity-popup-connection-internal,
 #identity-popup-security-content:not(.chromeUI) > .identity-popup-connection-internal,
 /* Hide the subsection arrow for whitelisted chromeUI pages. */
 #identity-popup-security-content.chromeUI + .identity-popup-expander,
+/* Hide the subsection arrow for whitelisted file URI pages. */
+#identity-popup-security-content.fileURI + .identity-popup-expander,
 /* Hide the tracking protection section for whitelisted chromeUI pages. */
 #identity-popup-mainView.chromeUI > #tracking-protection-container {
   display: none;
 }
 
 /* PANEL */
 
 #identity-popup,