summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/trusted-types/trusted-types-duplicate-names-without-enforcement.tentative.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testing/web-platform/tests/trusted-types/trusted-types-duplicate-names-without-enforcement.tentative.html30
1 files changed, 30 insertions, 0 deletions
diff --git a/testing/web-platform/tests/trusted-types/trusted-types-duplicate-names-without-enforcement.tentative.html b/testing/web-platform/tests/trusted-types/trusted-types-duplicate-names-without-enforcement.tentative.html
new file mode 100644
index 0000000000..afef457a9c
--- /dev/null
+++ b/testing/web-platform/tests/trusted-types/trusted-types-duplicate-names-without-enforcement.tentative.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<script>
+const policy = { createHTML: a => a };
+
+test(t => {
+ // The spec demands that duplicate policies are allowed when TT is not
+ // enforced in the CSP.
+ let a = trustedTypes.createPolicy("duplicatename", policy);
+ let b = trustedTypes.createPolicy("duplicatename", policy);
+ assert_not_equals(a, b);
+ assert_true(a instanceof TrustedTypePolicy);
+ assert_true(b instanceof TrustedTypePolicy);
+}, "createPolicy - duplicate policies are allowed when Trusted Types are not enforced.");
+
+test(t => {
+ // The spec demands that duplicate "default" policy creation fails, even
+ // when TT is not enforced.
+ let p = trustedTypes.createPolicy("default", policy);
+ assert_true(p instanceof TrustedTypePolicy);
+
+ // The second instance should throw:
+ assert_throws_js(TypeError, _ => trustedTypes.createPolicy("default", policy));
+}, "createPolicy - duplicate \"default\" policy is never allowed.");
+</script>
+</body>