diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/trusted-types/default-policy-callback-arguments.tentative.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/trusted-types/default-policy-callback-arguments.tentative.html')
-rw-r--r-- | testing/web-platform/tests/trusted-types/default-policy-callback-arguments.tentative.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/trusted-types/default-policy-callback-arguments.tentative.html b/testing/web-platform/tests/trusted-types/default-policy-callback-arguments.tentative.html new file mode 100644 index 0000000000..a4a9c9e351 --- /dev/null +++ b/testing/web-platform/tests/trusted-types/default-policy-callback-arguments.tentative.html @@ -0,0 +1,50 @@ +<!DOCTYPE html> +<head> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta http-equiv="Content-Security-Policy" + content="require-trusted-types-for 'script'"> +</head> +<body> + <div id="log"></div> + <div id="div"></div> + <script id="script"></script> + <script> + var current_case = undefined; + function checker(...args) { + assert_equals(args.length, 3); + assert_true(current_case && current_case.length == 4); + assert_equals(args[0], current_case[0], "Expecting the value."); + assert_equals(args[1], current_case[1], "Expecting the type name."); + assert_equals(args[2], current_case[2], "Expecting the sink name."); + return args[0]; + } + + trustedTypes.createPolicy("default", { + createHTML: checker, + createScript: checker, + createScriptURL: checker + }); + + const div = document.getElementById("div"); + const script = document.getElementById("script"); + const cases = [ + [ "abc", "TrustedHTML", "Element innerHTML", + _ => div.innerHTML = "abc" ], + [ "2+2", "TrustedScript", "Node textContent", + _ => script.textContent = "2+2" ], + [ "about:blank", "TrustedScriptURL", "HTMLScriptElement src", + _ => script.src = "about:blank" ], + [ "2+2", "TrustedScript", "eval", _ => eval("2+2") ], + [ "(function anonymous(\n) {\nreturn 2+2\n})", "TrustedScript", + "Function", _ => new Function("return 2+2") ], + ]; + for (var tc of cases) { + test(t => { + current_case = tc; + tc[3](); + }, `Test callback arguments, case ${tc[2]}`); + } + </script> +</body> + |