summaryrefslogtreecommitdiffstats
path: root/security/manager/ssl/tests/unit/test_imminent_distrust.js
diff options
context:
space:
mode:
Diffstat (limited to 'security/manager/ssl/tests/unit/test_imminent_distrust.js')
-rw-r--r--security/manager/ssl/tests/unit/test_imminent_distrust.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/security/manager/ssl/tests/unit/test_imminent_distrust.js b/security/manager/ssl/tests/unit/test_imminent_distrust.js
new file mode 100644
index 0000000000..861269e784
--- /dev/null
+++ b/security/manager/ssl/tests/unit/test_imminent_distrust.js
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+// Tests handling of certificates that are selected to emit a distrust warning
+// to the console.
+
+function shouldBeImminentlyDistrusted(aTransportSecurityInfo) {
+ let isDistrust =
+ aTransportSecurityInfo.securityState &
+ Ci.nsIWebProgressListener.STATE_CERT_DISTRUST_IMMINENT;
+ Assert.ok(isDistrust, "This host should be imminently distrusted");
+}
+
+function shouldNotBeImminentlyDistrusted(aTransportSecurityInfo) {
+ let isDistrust =
+ aTransportSecurityInfo.securityState &
+ Ci.nsIWebProgressListener.STATE_CERT_DISTRUST_IMMINENT;
+ Assert.ok(!isDistrust, "This host should not be imminently distrusted");
+}
+
+do_get_profile();
+
+add_tls_server_setup("BadCertAndPinningServer", "bad_certs");
+
+add_connection_test(
+ "imminently-distrusted.example.com",
+ PRErrorCodeSuccess,
+ null,
+ shouldBeImminentlyDistrusted
+);
+
+add_connection_test(
+ "include-subdomains.pinning.example.com",
+ PRErrorCodeSuccess,
+ null,
+ shouldNotBeImminentlyDistrusted
+);