diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-outerHTML.tentative.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-outerHTML.tentative.html')
-rw-r--r-- | testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-outerHTML.tentative.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-outerHTML.tentative.html b/testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-outerHTML.tentative.html new file mode 100644 index 0000000000..9b6cf72cb4 --- /dev/null +++ b/testing/web-platform/tests/trusted-types/block-string-assignment-to-Element-outerHTML.tentative.html @@ -0,0 +1,78 @@ +<!DOCTYPE html> +<html> +<head> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="support/helper.sub.js"></script> + + <meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script';"> +</head> +<body> +<div id="container"></div> +<script> + var container = document.querySelector('#container') + + // TrustedHTML assignments do not throw. + test(t => { + let p = createHTML_policy(window, 1); + let html = p.createHTML(INPUTS.HTML); + + var d = document.createElement('div'); + document.querySelector('#container').appendChild(d); + d.outerHTML = html; + assert_equals(container.innerText, RESULTS.HTML); + + while (container.firstChild) + container.firstChild.remove(); + }, "outerHTML with html assigned via policy (successful HTML transformation)."); + + // String assignments throw. + test(t => { + var d = document.createElement('div'); + container.appendChild(d); + assert_throws_js(TypeError, _ => { + d.outerHTML = "Fail."; + }); + assert_equals(container.innerText, ""); + while (container.firstChild) + container.firstChild.remove(); + }, "`outerHTML = string` throws."); + + // Null assignment throws. + test(t => { + var d = document.createElement('div'); + container.appendChild(d); + assert_throws_js(TypeError, _ => { + d.outerHTML = null; + }); + assert_equals(container.innerText, ""); + while (container.firstChild) + container.firstChild.remove(); + }, "`outerHTML = null` throws."); + + // After default policy creation string assignment implicitly calls createHTML. + test(t => { + let p = window.trustedTypes.createPolicy("default", { createHTML: createHTMLJS }, true); + + var d = document.createElement('div'); + document.querySelector('#container').appendChild(d); + d.outerHTML = INPUTS.HTML; + assert_equals(container.innerText, RESULTS.HTML); + + while (container.firstChild) + container.firstChild.remove(); + }, "`outerHTML = string` assigned via default policy (successful HTML transformation)."); + + // After default policy creation null assignment implicitly calls createHTML. + test(t => { + var d = document.createElement('div'); + container.appendChild(d); + d.outerHTML = null; + assert_equals(container.innerText, ""); + + while (container.firstChild) + container.firstChild.remove(); + }, "`outerHTML = null` assigned via default policy does not throw"); +</script> +</body> +</html> |