bug 627234 - test that hsts data isn't deleted in private browsing when includeSubdomains is false r=bsmith a=testonly
authorDavid Keeler <dkeeler@mozilla.com>
Mon, 22 Oct 2012 10:38:50 -0700
changeset 109646 f748ad6a38fccdf87a9603cbe29ae5cfcdb2ac7b
parent 109645 b2e61264d362e506435c94189774d7a6eb156402
child 109651 8b18f841126dfb164e7886a98e27c33a580aa52a
push id1591
push userdkeeler@mozilla.com
push dateTue, 23 Oct 2012 18:29:29 +0000
treeherdermozilla-beta@f748ad6a38fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmith, testonly
bugs627234
milestone17.0
bug 627234 - test that hsts data isn't deleted in private browsing when includeSubdomains is false r=bsmith a=testonly
security/manager/ssl/tests/unit/test_bug627234.js
security/manager/ssl/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/security/manager/ssl/tests/unit/test_bug627234.js
@@ -0,0 +1,61 @@
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+var gPBService = Cc["@mozilla.org/privatebrowsing;1"]
+                 .getService(Ci.nsIPrivateBrowsingService);
+var gSTSService = Cc["@mozilla.org/stsservice;1"]
+                  .getService(Ci.nsIStrictTransportSecurityService);
+
+function Observer() {}
+Observer.prototype = {
+  observe: function(subject, topic, data) {
+    do_execute_soon(gNextTest);
+  }
+};
+
+var gObserver = new Observer();
+var gNextTest = null;
+
+function cleanup() {
+  Services.obs.removeObserver(gObserver, "private-browsing-transition-complete");
+  gPBService.privateBrowsingEnabled = false;
+  // (we have to remove any state added to the sts service so as to not muck
+  // with other tests).
+  var uri = Services.io.newURI("http://localhost", null, null);
+  gSTSService.removeStsState(uri);
+}
+
+function run_test() {
+  do_test_pending();
+  do_register_cleanup(cleanup);
+
+  gNextTest = test_part1;
+  Services.obs.addObserver(gObserver, "private-browsing-transition-complete", false);
+  Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
+  gPBService.privateBrowsingEnabled = true;
+}
+
+function test_part1() {
+  var uri = Services.io.newURI("https://localhost/img.png", null, null);
+  gSTSService.processStsHeader(uri, "max-age=1000");
+  do_check_true(gSTSService.isStsHost("localhost"));
+  gNextTest = test_part2;
+  gPBService.privateBrowsingEnabled = false;
+}
+
+function test_part2() {
+  var uri = Services.io.newURI("https://localhost/img.png", null, null);
+  gSTSService.processStsHeader(uri, "max-age=1000");
+  do_check_true(gSTSService.isStsHost("localhost"));
+  gNextTest = test_part3;
+  gPBService.privateBrowsingEnabled = true;
+}
+
+function test_part3() {
+  var uri = Services.io.newURI("https://localhost/img.png", null, null);
+  gSTSService.processStsHeader(uri, "max-age=1000");
+  do_check_true(gSTSService.isStsHost("localhost"));
+  do_test_finished();
+}
--- a/security/manager/ssl/tests/unit/xpcshell.ini
+++ b/security/manager/ssl/tests/unit/xpcshell.ini
@@ -6,9 +6,10 @@ tail =
 # Bug 676972: test hangs consistently on Android
 skip-if = os == "android"
 [test_hash_algorithms.js]
 # Bug 676972: test hangs consistently on Android
 skip-if = os == "android"
 [test_hmac.js]
 # Bug 676972: test hangs consistently on Android
 skip-if = os == "android"
+[test_bug627234.js]
 [test_sts_preloadlist.js]