Backed out changeset 1aa4c60fbfdb (bug 1221084) for frequent bc7 failures in browser_aboutCertError.js
authorWes Kocher <wkocher@mozilla.com>
Fri, 13 Nov 2015 12:00:22 -0800
changeset 308806 717eb182ad45d82803d43122ee98711c0bd0a87e
parent 308805 4a1f206dfc25706a75d8f93cc7a73ca5fdceaf86
child 308807 676853087b553b89d499022b42550787d1c1815a
child 308851 697fb66c4494f8df72f4e8e5e97d7b842e0a0cfe
push id7526
push usermleibovic@mozilla.com
push dateFri, 13 Nov 2015 20:37:49 +0000
bugs1221084
milestone45.0a1
backs out1aa4c60fbfdbf868dc9f6775053b686889fb379a
Backed out changeset 1aa4c60fbfdb (bug 1221084) for frequent bc7 failures in browser_aboutCertError.js
browser/base/content/aboutcerterror/aboutCertError.xhtml
browser/base/content/browser.js
browser/base/content/test/general/browser_aboutCertError.js
security/manager/ssl/nsISecurityUITelemetry.idl
--- a/browser/base/content/aboutcerterror/aboutCertError.xhtml
+++ b/browser/base/content/aboutcerterror/aboutCertError.xhtml
@@ -46,16 +46,26 @@
         // s is optional, if no match just return nothing
         if (!matches || matches.length < 2)
           return "";
 
         // parenthetical match is the second entry
         return decodeURIComponent(matches[1]);
       }
 
+      function goBack(buttonEl)
+      {
+        if (history.length > 1) {
+          history.back();
+        } else {
+          location.href = "about:home";
+        }
+        buttonEl.disabled = true;
+      }
+
       function toggleVisibility(id)
       {
         var node = document.getElementById(id);
         node.style.visibility = node.style.visibility == "" ? "hidden" : "";
       }
 
       function getDescription()
       {
@@ -198,17 +208,17 @@
           <p>&certerror.introPara;</p>
         </div>
         <p id="badStsCertExplanation">&certerror.whatShouldIDo.badStsCertExplanation;</p>
         <div>
           <p><a href="https://support.mozilla.org/kb/tls-error-reports" id="learnMoreLink" target="new">&certerror.learnMore;</a></p>
         </div>
 
         <div id="buttonContainer">
-          <button id="returnButton" autocomplete="off" autofocus="true">&certerror.returnToPreviousPage.label;</button>
+          <button id="returnButton" autocomplete="off" onclick="goBack(this);" autofocus="true">&certerror.returnToPreviousPage.label;</button>
           <div id="buttonSpacer"></div>
           <button id="advancedButton" autocomplete="off" onclick="toggleVisibility('advancedPanel');" autofocus="true">&certerror.advanced.label;</button>
         </div>
         <!-- Advanced panel, which is hidden by default -->
         <div id="advancedPanel" style="visibility: hidden;">
           <p id="technicalContentText"/>
           <button id='exceptionDialogButton'>&certerror.addException.label;</button>
         </div>
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2977,24 +2977,30 @@ var BrowserOnClick = {
                           '','chrome,centerscreen,modal', params);
 
         // If the user added the exception cert, attempt to reload the page
         if (params.exceptionAdded) {
           browser.reload();
         }
         break;
 
-      case "returnButton":
+      case "getMeOutOfHereButton":
         if (isTopFrame) {
           secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_BAD_CERT_TOP_GET_ME_OUT_OF_HERE);
         }
-        goBackFromErrorPage();
+        getMeOutOfHere();
         break;
 
-      case "advancedButton":
+      case "technicalContent":
+        if (isTopFrame) {
+          secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_BAD_CERT_TOP_TECHNICAL_DETAILS);
+        }
+        break;
+
+      case "expertContent":
         if (isTopFrame) {
           secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_BAD_CERT_TOP_UNDERSTAND_RISKS);
         }
         break;
 
     }
   },
 
@@ -3123,58 +3129,29 @@ var BrowserOnClick = {
 /**
  * Re-direct the browser to a known-safe page.  This function is
  * used when, for example, the user browses to a known malware page
  * and is presented with about:blocked.  The "Get me out of here!"
  * button should take the user to the default start page so that even
  * when their own homepage is infected, we can get them somewhere safe.
  */
 function getMeOutOfHere() {
-  gBrowser.loadURI(getDefaultHomePage());
-}
-
-/**
- * Re-direct the browser to the previous page or a known-safe page if no
- * previous page is found in history.  This function is used when the user
- * browses to a secure page with certificate issues and is presented with
- * about:certerror.  The "Go Back" button should take the user to the previous
- * or a default start page so that even when their own homepage is on a server
- * that has certificate errors, we can get them somewhere safe.
- */
-function goBackFromErrorPage() {
-  const ss = Cc["@mozilla.org/browser/sessionstore;1"].
-             getService(Ci.nsISessionStore);
-  let state = JSON.parse(ss.getTabState(gBrowser.selectedTab));
-  if (state.index == 1) {
-    // If the unsafe page is the first or the only one in history, go to the
-    // start page.
-    gBrowser.loadURI(getDefaultHomePage());
-  } else {
-    BrowserBack();
-  }
-}
-
-/**
- * Return the default start page for the cases when the user's own homepage is
- * infected, so we can get them somewhere safe.
- */
-function getDefaultHomePage() {
   // Get the start page from the *default* pref branch, not the user's
   var prefs = Services.prefs.getDefaultBranch(null);
   var url = BROWSER_NEW_TAB_URL;
   try {
     url = prefs.getComplexValue("browser.startup.homepage",
                                 Ci.nsIPrefLocalizedString).data;
     // If url is a pipe-delimited set of pages, just take the first one.
     if (url.includes("|"))
       url = url.split("|")[0];
   } catch(e) {
     Components.utils.reportError("Couldn't get homepage pref: " + e);
   }
-  return url;
+  gBrowser.loadURI(url);
 }
 
 function BrowserFullScreen()
 {
   window.fullScreen = !window.fullScreen;
 }
 
 function mirrorShow(popup) {
--- a/browser/base/content/test/general/browser_aboutCertError.js
+++ b/browser/base/content/test/general/browser_aboutCertError.js
@@ -2,18 +2,16 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // This is testing the aboutCertError page (Bug 1207107).  It's a start,
 // but should be expanded to include cert_domain_link
 
 const GOOD_PAGE = "https://example.com/";
 const BAD_CERT = "https://expired.example.com/";
 const BAD_STS_CERT = "https://badchain.include-subdomains.pinning.example.com:443";
-const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
-const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
 add_task(function* checkReturnToAboutHome() {
   info("Loading a bad cert page directly and making sure 'return to previous page' goes to about:home");
   let browser;
   let certErrorLoaded;
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
     gBrowser.selectedTab = gBrowser.addTab(BAD_CERT);
     browser = gBrowser.selectedBrowser;
@@ -21,22 +19,16 @@ add_task(function* checkReturnToAboutHom
   }, false);
 
   info("Loading and waiting for the cert error");
   yield certErrorLoaded;
 
   is(browser.webNavigation.canGoBack, false, "!webNavigation.canGoBack");
   is(browser.webNavigation.canGoForward, false, "!webNavigation.canGoForward");
 
-  // Populate the shistory entries manually, since it happens asynchronously
-  // and the following tests will be too soon otherwise.
-  yield TabStateFlusher.flush(browser);
-  let {entries} = JSON.parse(ss.getTabState(tab));
-  is(entries.length, 1, "there is one shistory entry");
-
   info("Clicking the go back button on about:certerror");
   let pageshowPromise = promiseWaitForEvent(browser, "pageshow");
   yield ContentTask.spawn(browser, null, function* () {
     let doc = content.document;
     let returnButton = doc.getElementById("returnButton");
     returnButton.click();
   });
   yield pageshowPromise;
--- a/security/manager/ssl/nsISecurityUITelemetry.idl
+++ b/security/manager/ssl/nsISecurityUITelemetry.idl
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-[scriptable, uuid(5d1acf82-223a-46fb-a8f3-a1b16e2ceb04)]
+[scriptable, uuid(56e190a0-2802-4fc4-b09f-bcda357035c3)]
 
 interface nsISecurityUITelemetry : nsISupports {
 
 /*
  * Addon installation warnings
  */
 
 // Firefox prevented this site from asking you to install addon
@@ -125,17 +125,17 @@ const uint32_t WARNING_PHISHING_PAGE_FRA
 
 const uint32_t WARNING_BAD_CERT_TOP = 68;
 const uint32_t WARNING_BAD_CERT_TOP_STS = 69;
 const uint32_t WARNING_BAD_CERT_TOP_CLICK_ADD_EXCEPTION = 70;
 const uint32_t WARNING_BAD_CERT_TOP_CLICK_VIEW_CERT = 71;
 const uint32_t WARNING_BAD_CERT_TOP_DONT_REMEMBER_EXCEPTION = 72;
 const uint32_t WARNING_BAD_CERT_TOP_GET_ME_OUT_OF_HERE = 73;
 const uint32_t WARNING_BAD_CERT_TOP_UNDERSTAND_RISKS = 74;
-//     removed WARNING_BAD_CERT_TOP_TECHNICAL_DETAILS = 75;
+const uint32_t WARNING_BAD_CERT_TOP_TECHNICAL_DETAILS = 75;
 
 const uint32_t WARNING_BAD_CERT_TOP_ADD_EXCEPTION_BASE = 76;
 const uint32_t WARNING_BAD_CERT_TOP_ADD_EXCEPTION_FLAG_UNTRUSTED = 1;
 const uint32_t WARNING_BAD_CERT_TOP_ADD_EXCEPTION_FLAG_DOMAIN = 2;
 const uint32_t WARNING_BAD_CERT_TOP_ADD_EXCEPTION_FLAG_TIME = 4;
 
 const uint32_t WARNING_BAD_CERT_TOP_CONFIRM_ADD_EXCEPTION_BASE = 84;
 const uint32_t WARNING_BAD_CERT_TOP_CONFIRM_ADD_EXCEPTION_FLAG_UNTRUSTED = 1;