Bug 1120748 - Split browser_ssl_error_reports.js into multiple tasks. r=felipe, a=test-only
authorTim Taubert <ttaubert@mozilla.com>
Thu, 02 Apr 2015 11:43:32 +0200
changeset 258233 b9d2266daf60
parent 258232 cc9ac7031506
child 258234 9c755cdc241c
push id4623
push userryanvm@gmail.com
push date2015-04-03 01:49 +0000
treeherdermozilla-beta@9c755cdc241c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe, test-only
bugs1120748
milestone38.0
Bug 1120748 - Split browser_ssl_error_reports.js into multiple tasks. r=felipe, a=test-only
browser/base/content/test/general/browser_ssl_error_reports.js
--- a/browser/base/content/test/general/browser_ssl_error_reports.js
+++ b/browser/base/content/test/general/browser_ssl_error_reports.js
@@ -1,25 +1,26 @@
+"use strict";
+
 let badChainURL = "https://badchain.include-subdomains.pinning.example.com";
 let noCertURL = "https://fail-handshake.example.com";
 let enabledPref = false;
 let automaticPref = false;
 let urlPref = "security.ssl.errorReporting.url";
 let enforcement_level = 1;
 let ROOT = getRootDirectory(gTestPath);
 
-add_task(function*(){
-  waitForExplicitFinish();
-  SimpleTest.requestCompleteLog();
-  yield testSendReportDisabled();
+SimpleTest.requestCompleteLog();
+
+add_task(function* test_send_report_manual_badchain() {
   yield testSendReportManual(badChainURL, "succeed");
+});
+
+add_task(function* test_send_report_manual_nocert() {
   yield testSendReportManual(noCertURL, "nocert");
-  yield testSendReportAuto();
-  yield testSendReportError();
-  yield testSetAutomatic();
 });
 
 // creates a promise of the message in an error page
 function createNetworkErrorMessagePromise(aBrowser) {
   return new Promise(function(resolve, reject) {
     // Error pages do not fire "load" events, so use a progressListener.
     let originalDocumentURI = aBrowser.contentDocument.documentURI;
 
@@ -62,17 +63,17 @@ function createNetworkErrorMessagePromis
 
     aBrowser.addProgressListener(progressListener,
             Ci.nsIWebProgress.NOTIFY_LOCATION |
             Ci.nsIWebProgress.NOTIFY_STATE_REQUEST);
   });
 }
 
 // check we can set the 'automatically send' pref
-let testSetAutomatic = function*() {
+add_task(function* test_set_automatic() {
   setup();
   let tab = gBrowser.addTab(badChainURL, {skipAnimation: true});
   let browser = tab.linkedBrowser;
   let mm = browser.messageManager;
   mm.loadFrameScript(ROOT + "browser_ssl_error_reports_content.js", true);
 
   gBrowser.selectedTab = tab;
 
@@ -111,17 +112,17 @@ let testSetAutomatic = function*() {
   });
 
   mm.sendAsyncMessage("ssler-test:SetAutoPref",{value:false});
 
   yield prefDisabled;
 
   gBrowser.removeTab(tab);
   cleanup();
-};
+});
 
 // test that manual report sending (with button clicks) works
 let testSendReportManual = function*(testURL, suffix) {
   setup();
   Services.prefs.setBoolPref("security.ssl.errorReporting.enabled", true);
   Services.prefs.setCharPref("security.ssl.errorReporting.url",
     "https://example.com/browser/browser/base/content/test/general/pinning_reports.sjs?" + suffix);
 
@@ -175,17 +176,17 @@ let testSendReportManual = function*(tes
 
   yield deferredReportSucceeds.promise;
 
   gBrowser.removeTab(tab);
   cleanup();
 };
 
 // test that automatic sending works
-let testSendReportAuto = function*() {
+add_task(function* test_send_report_auto() {
   setup();
   Services.prefs.setBoolPref("security.ssl.errorReporting.enabled", true);
   Services.prefs.setBoolPref("security.ssl.errorReporting.automatic", true);
   Services.prefs.setCharPref("security.ssl.errorReporting.url", "https://example.com/browser/browser/base/content/test/general/pinning_reports.sjs?succeed");
 
   let tab = gBrowser.addTab(badChainURL, {skipAnimation: true});
   let browser = tab.linkedBrowser;
   let mm = browser.messageManager;
@@ -222,20 +223,20 @@ let testSendReportAuto = function*() {
 
   mm.addMessageListener("ssler-test:SSLErrorReportStatus", statusListener);
 
   // Ensure the report is sent with no interaction
   yield deferredReportSucceeds.promise;
 
   gBrowser.removeTab(tab);
   cleanup();
-};
+});
 
 // test that an error is shown if there's a problem with the report server
-let testSendReportError = function*() {
+add_task(function* test_send_report_error() {
   setup();
   // set up prefs so error send is automatic and an error will occur
   Services.prefs.setBoolPref("security.ssl.errorReporting.enabled", true);
   Services.prefs.setBoolPref("security.ssl.errorReporting.automatic", true);
   Services.prefs.setCharPref("security.ssl.errorReporting.url", "https://example.com/browser/browser/base/content/test/general/pinning_reports.sjs?error");
 
   // load the test URL so error page is seen
   let tab = gBrowser.addTab(badChainURL, {skipAnimation: true});
@@ -260,19 +261,19 @@ let testSendReportError = function*() {
     mm.addMessageListener("ssler-test:SSLErrorReportStatus", statusListener);
   });
 
   // check that errors are sent
   yield reportErrors;
 
   gBrowser.removeTab(tab);
   cleanup();
-};
+});
 
-let testSendReportDisabled = function*() {
+add_task(function* test_send_report_disabled() {
   setup();
   Services.prefs.setBoolPref("security.ssl.errorReporting.enabled", false);
   Services.prefs.setCharPref("security.ssl.errorReporting.url", "https://offdomain.com");
 
   let tab = gBrowser.addTab(badChainURL, {skipAnimation: true});
   let browser = tab.linkedBrowser;
   let mm = browser.messageManager;
   mm.loadFrameScript(ROOT + "browser_ssl_error_reports_content.js", true);
@@ -302,17 +303,17 @@ let testSendReportDisabled = function*()
   // click the button
   mm.sendAsyncMessage("ssler-test:SendBtnClick",{forceUI:true});
 
   // check we get an error
   yield reportErrors;
 
   gBrowser.removeTab(tab);
   cleanup();
-};
+});
 
 function setup() {
   // ensure the relevant prefs are set
   enabledPref = Services.prefs.getBoolPref("security.ssl.errorReporting.enabled");
   automaticPref = Services.prefs.getBoolPref("security.ssl.errorReporting.automatic");
   urlPref = Services.prefs.getCharPref("security.ssl.errorReporting.url");
 
   enforcement_level = Services.prefs.getIntPref("security.cert_pinning.enforcement_level");