Bug 1303298 - Use BrowserTestUtils.waitForErrorPage to wait for certerror page load. r=nhnt11
MozReview-Commit-ID: BzT1cQAd9Qx
--- 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
@@ -1010,26 +1010,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);
}