Bug 1303298 - Work around intermittent browser_mixed_content_cert_override.js. r=nhnt11
authorJohann Hofmann <jhofmann@mozilla.com>
Tue, 29 Nov 2016 18:01:35 +0100
changeset 325113 0eef7033686f6174c5739bb21aea969d3f4b3373
parent 325112 e341fa032c29358e8fd014b3d6db90a85e7f28e1
child 325114 1f7832017dbb5c53ba00aef3012b40c873a5005d
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersnhnt11
bugs1303298
milestone53.0a1
Bug 1303298 - Work around intermittent browser_mixed_content_cert_override.js. r=nhnt11 MozReview-Commit-ID: 5srDm58jz5M
browser/base/content/test/general/head.js
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -1018,18 +1018,27 @@ function* loadBadCertPage(url) {
         }
       }
     };
 
     Services.obs.addObserver(certExceptionDialogObserver,
                              "cert-exception-ui-ready", false);
   });
 
-  yield BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
-  yield promiseErrorPageLoaded(gBrowser.selectedBrowser);
+  // 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);
+
   yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
     content.document.getElementById("exceptionDialogButton").click();
   });
   yield exceptionDialogResolved;
   yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 }
 
 // Utility function to get a handle on the certificate exception dialog.