Bug 1100687 - part 2: fix browser_blockHPKP.js, r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 26 Feb 2016 15:16:13 +0000
changeset 286204 2fa086d51b6a8d94566493b34cbce00a37af5024
parent 286203 083380e8d36f1ad68ddd565eeee3231ac9196282
child 286205 76c51477853faeac91211c2adee7adfee858b276
push id72696
push usercbook@mozilla.com
push dateTue, 01 Mar 2016 14:25:42 +0000
treeherdermozilla-inbound@0f47155c48a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1100687
milestone47.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 1100687 - part 2: fix browser_blockHPKP.js, r=jaws MozReview-Commit-ID: DxvN94O8fhi
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_blockHPKP.js
browser/base/content/test/general/browser_ssl_error_reports.js
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -522,17 +522,16 @@ tags = mcb
 tags = mcb
 [browser_bug1225194-remotetab.js]
 [browser_e10s_switchbrowser.js]
 [browser_e10s_about_process.js]
 [browser_e10s_chrome_process.js]
 [browser_e10s_javascript.js]
 [browser_blockHPKP.js]
 tags = psm
-skip-if = e10s # bug 1100687 - test directly manipulates content (content.document.getElementById)
 [browser_mcb_redirect.js]
 tags = mcb
 [browser_windowactivation.js]
 [browser_contextmenu_childprocess.js]
 [browser_bug963945.js]
 [browser_readerMode.js]
 support-files =
   readerModeArticle.html
--- a/browser/base/content/test/general/browser_blockHPKP.js
+++ b/browser/base/content/test/general/browser_blockHPKP.js
@@ -44,66 +44,58 @@ function test() {
     let uri = gIOService.newURI("https://" + kPinningDomain, null, null);
     gSSService.removeState(Ci.nsISiteSecurityService.HEADER_HPKP, uri, 0);
   });
   whenNewTabLoaded(window, loadPinningPage);
 }
 
 // Start by making a successful connection to a domain that will pin a site
 function loadPinningPage() {
-  gBrowser.selectedBrowser.addEventListener("load",
-                                             successfulPinningPageListener,
-                                             true);
 
-  gBrowser.selectedBrowser.loadURI("https://" + kPinningDomain + kURLPath + "valid");
+  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kPinningDomain + kURLPath + "valid").then(function() {
+    gBrowser.selectedBrowser.addEventListener("load",
+                                               successfulPinningPageListener,
+                                               true);
+  });
 }
 
 // After the site is pinned try to load with a subdomain site that should
 // fail to validate
 var successfulPinningPageListener = {
   handleEvent: function() {
     gBrowser.selectedBrowser.removeEventListener("load", this, true);
-    gBrowser.addProgressListener(certErrorProgressListener);
-    gBrowser.selectedBrowser.loadURI("https://" + kBadPinningDomain);
+    BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kBadPinningDomain).then(function() {
+      return promiseErrorPageLoaded(gBrowser.selectedBrowser);
+    }).then(errorPageLoaded);
   }
 };
 
 // The browser should load about:neterror, when this happens, proceed
 // to load the pinning domain again, this time removing the pinning information
-var certErrorProgressListener = {
-  onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
-    if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
-      let textElement = content.document.getElementById("errorShortDescText");
-      let text = textElement.innerHTML;
-      ok(text.indexOf("MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE") > 0,
-         "Got a pinning error page");
-      gBrowser.removeProgressListener(this);
-      gBrowser.selectedBrowser.addEventListener("load",
-                                                successfulPinningRemovalPageListener,
-                                                true);
-      gBrowser.selectedBrowser.loadURI("https://" + kPinningDomain + kURLPath + "zeromaxagevalid");
-    }
-  }
+function errorPageLoaded() {
+  ContentTask.spawn(gBrowser.selectedBrowser, null, function*() {
+    let textElement = content.document.getElementById("errorShortDescText");
+    let text = textElement.innerHTML;
+    ok(text.indexOf("MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE") > 0,
+       "Got a pinning error page");
+  }).then(function() {
+    BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kPinningDomain + kURLPath + "zeromaxagevalid").then(function() {
+      return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
+    }).then(pinningRemovalLoaded);
+  });
 };
 
 // After the pinning information has been removed (successful load) proceed
 // to load again with the invalid pin domain.
-var successfulPinningRemovalPageListener = {
-  handleEvent: function() {
-    gBrowser.selectedBrowser.removeEventListener("load", this, true);
-    gBrowser.selectedBrowser.addEventListener("load",
-                                              successfulLoadListener,
-                                              true);
-
-    gBrowser.selectedBrowser.loadURI("https://" + kBadPinningDomain);
-  }
+function pinningRemovalLoaded() {
+  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kBadPinningDomain).then(function() {
+    return BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
+  }).then(badPinningPageLoaded);
 };
 
 // Finally, we should successfully load
 // https://bad.include-subdomains.pinning-dynamic.example.com.
-var successfulLoadListener = {
-  handleEvent: function() {
-    gBrowser.selectedBrowser.removeEventListener("load", this, true);
-    gBrowser.removeTab(gBrowser.selectedTab);
+function badPinningPageLoaded() {
+  BrowserTestUtils.removeTab(gBrowser.selectedTab).then(function() {
     ok(true, "load complete");
     finish();
-  }
+  });
 };
--- a/browser/base/content/test/general/browser_ssl_error_reports.js
+++ b/browser/base/content/test/general/browser_ssl_error_reports.js
@@ -160,24 +160,15 @@ function createReportResponseStatusPromi
         Services.obs.removeObserver(observer, "http-on-examine-response");
         resolve(subject.responseStatus);
       }
     };
     Services.obs.addObserver(observer, "http-on-examine-response", false);
   });
 }
 
-function promiseErrorPageLoaded(browser) {
-  return new Promise(resolve => {
-    browser.addEventListener("DOMContentLoaded", function onLoad() {
-      browser.removeEventListener("DOMContentLoaded", onLoad, false, true);
-      resolve();
-    }, false, true);
-  });
-}
-
 function checkErrorPage(browser, suffix) {
   return ContentTask.spawn(browser, null, function* () {
     return content.document.documentURI;
   }).then(uri => {
     ok(uri.startsWith(`about:${suffix}`), "correct error page loaded");
   });
 }