bug 627234 - test that hsts data isn't deleted in private browsing when includeSubdomains is false r=bsmith
authorDavid Keeler <dkeeler@mozilla.com>
Mon, 22 Oct 2012 10:38:50 -0700
changeset 111209 35e15835ddc96c47625cabbf9c21e608e57fb204
parent 111208 1e8b9181a268e87da7db0dd9de96c73bf2b8948f
child 111210 d1cef20450285697983dc737772d999d0d3846c4
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersbsmith
bugs627234
milestone19.0a1
bug 627234 - test that hsts data isn't deleted in private browsing when includeSubdomains is false r=bsmith
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]