Bug 1175702 - Fix browser_identity_UI.js failures r=paolo
☠☠ backed out by e78c32436369 ☠ ☠
authorTim Taubert <ttaubert@mozilla.com>
Thu, 06 Aug 2015 15:01:37 +0200
changeset 288267 dc33bb49347daad4d6332d26bedc3ad74bb0fc71
parent 288266 657bc9b41d7150028b81bf74ee4baa0b3aa07289
child 288268 7216b345380e3acd451fc842bd2e2c49b4d4a144
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)
reviewerspaolo
bugs1175702
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 1175702 - Fix browser_identity_UI.js failures r=paolo
browser/base/content/browser.js
browser/base/content/test/general/browser_identity_UI.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6853,24 +6853,34 @@ var gIdentityHandler = {
    * be called by onSecurityChange
    *
    * @param PRUint32 state
    * @param nsIURI uri The address for which the UI should be updated.
    */
   checkIdentity : function(state, uri) {
     let nsIWebProgressListener = Ci.nsIWebProgressListener;
 
+    // For some URIs like data: we can't get a host. URIs without a host will
+    // usually be treated as a non-secure connection if they're not on the
+    // whitelist below and don't resolve to file:// URIs internally.
+    let unknown = false;
+    try {
+      uri.host;
+    } catch (e) { unknown = true; }
+
     // Chrome URIs however get special treatment. Some chrome URIs are
     // whitelisted to provide a positive security signal to the user.
     let whitelist = /^about:(accounts|addons|app-manager|config|crashes|customizing|downloads|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback)/i;
     let isChromeUI = uri.schemeIs("about") && whitelist.test(uri.spec);
     let mode = this.IDENTITY_MODE_UNKNOWN;
 
     if (isChromeUI) {
       mode = this.IDENTITY_MODE_CHROMEUI;
+    } else if (unknown) {
+      // Use default mode.
     } else if (state & nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL) {
       if (state & nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT) {
         mode = this.IDENTITY_MODE_MIXED_ACTIVE_BLOCKED_IDENTIFIED;
       } else {
         mode = this.IDENTITY_MODE_IDENTIFIED;
       }
     } else if (state & nsIWebProgressListener.STATE_IS_SECURE) {
       if (state & nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT) {
--- a/browser/base/content/test/general/browser_identity_UI.js
+++ b/browser/base/content/test/general/browser_identity_UI.js
@@ -38,17 +38,16 @@ var tests = [
   {
     name: "subdomain with port",
     location: "http://sub1.test1.example.org:8000/",
     effectiveHost: "example.org"
   },
   {
     name: "subdomain HTTPS",
     location: "https://test1.example.com/",
-
     effectiveHost: "example.com",
     isHTTPS: true
   },
   {
     name: "view-source HTTPS",
     location: "view-source:https://example.com/",
     effectiveHost: null,
     isHTTPS: true
@@ -99,17 +98,19 @@ function nextTest() {
     if (!gForward)
       gTestDesc += " (second time)";
     content.location.reload(true);
   }
 }
 
 function checkResult() {
   // Sanity check other values, and the value of gIdentityHandler.getEffectiveHost()
-  is(gIdentityHandler._lastUri.spec, gCurrentTest.location, "location matches for test " + gTestDesc);
+  is(gIdentityHandler._uri.spec, gCurrentTest.location, "location matches for test " + gTestDesc);
   // getEffectiveHost can't be called for all modes
-  if (gCurrentTest.effectiveHost === null)
-    is(gIdentityHandler._mode == gIdentityHandler.IDENTITY_MODE_UNKNOWN || gIdentityHandler._mode == gIdentityHandler.IDENTITY_MODE_CHROMEUI, true, "mode matched");
-  else
+  if (gCurrentTest.effectiveHost === null) {
+    let identityBox = document.getElementById("identity-box");
+    is(identityBox.className == gIdentityHandler.IDENTITY_MODE_UNKNOWN || identityBox.className == gIdentityHandler.IDENTITY_MODE_CHROMEUI, true, "mode matched");
+  } else {
     is(gIdentityHandler.getEffectiveHost(), gCurrentTest.effectiveHost, "effectiveHost matches for test " + gTestDesc);
+  }
 
   executeSoon(nextTest);
 }