Bug 1303298 - Use BrowserTestUtils.waitForErrorPage to wait for certerror page load. r=nhnt11, a=test-only
authorJohann Hofmann <jhofmann@mozilla.com>
Wed, 25 Jan 2017 16:19:04 +0100
changeset 375870 9406c3c13338279f95833ca0da17656f81b183bf
parent 375869 f4a0fbbefd444b54ab3d2daae5cb297fa7988acd
child 375871 dfdab396dff7a77d7d075b231431bad1c2a2bcb8
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnhnt11, test-only
bugs1303298
milestone53.0a2
Bug 1303298 - Use BrowserTestUtils.waitForErrorPage to wait for certerror page load. r=nhnt11, a=test-only MozReview-Commit-ID: BzT1cQAd9Qx
browser/base/content/test/general/browser_mixed_content_cert_override.js
browser/base/content/test/general/head.js
--- a/browser/base/content/test/general/browser_mixed_content_cert_override.js
+++ b/browser/base/content/test/general/browser_mixed_content_cert_override.js
@@ -22,16 +22,17 @@ function checkIdentityPopup(icon) {
   gIdentityHandler.refreshIdentityPopup();
   is(getConnectionIcon(), `url("chrome://browser/skin/${icon}")`);
   is(getConnectionState(), "secure-cert-user-overridden");
   isnot(getPopupContentVerifier().style.display, "none", "Overridden certificate warning is shown");
   ok(getPopupContentVerifier().textContent.includes("security exception"), "Text shows overridden certificate warning.");
 }
 
 add_task(function* () {
+  yield BrowserTestUtils.openNewForegroundTab(gBrowser);
 
   // check that a warning is shown when loading a page with mixed content and an overridden certificate
   yield loadBadCertPage(MIXED_CONTENT_URL);
   checkIdentityPopup("connection-mixed-passive-loaded.svg#icon");
 
   // check that the crossed out icon is shown when disabling mixed content protection
   gIdentityHandler.disableMixedContentProtection();
   yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
@@ -42,10 +43,12 @@ add_task(function* () {
   yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://self-signed.example.com");
   yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
   checkIdentityPopup("connection-mixed-passive-loaded.svg#icon");
 
   // remove cert exception
   let certOverrideService = Cc["@mozilla.org/security/certoverride;1"]
                               .getService(Ci.nsICertOverrideService);
   certOverrideService.clearValidityOverride("self-signed.example.com", -1);
+
+  yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -1015,26 +1015,19 @@ function* loadBadCertPage(url) {
         }
       }
     };
 
     Services.obs.addObserver(certExceptionDialogObserver,
                              "cert-exception-ui-ready", false);
   });
 
-  // Sometimes clearing the cert override is not immediately picked up,
-  // so we reload until we are on an actual cert error page.
-  yield BrowserTestUtils.waitForCondition(function*() {
-    yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
-    yield promiseErrorPageLoaded(gBrowser.selectedBrowser);
-    let isErrorPage = yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
-      return content.document.documentURI.startsWith("about:certerror");
-    });
-    return isErrorPage;
-  }, "Could not load error page", 1000);
+  let loaded = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser);
+  yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
+  yield loaded;
 
   yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
     content.document.getElementById("exceptionDialogButton").click();
   });
   yield exceptionDialogResolved;
   yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 }