Skip to content

Commit

Permalink
Bug 1941267 [wpt PR 50043] - Remove unrelated checks from trusted-typ…
Browse files Browse the repository at this point in the history
…es-svg-script-set-href.html, a=testonly

Automatic update from web-platform-tests
Remove unrelated checks from trusted-types-svg-script-set-href.html (#50043)

* Remove unrelated checks from trusted-types-svg-script-set-href.html

This test is intended to cover setting href [1] [2] but it also
currently verifies some (currently not specified) unrelated behavior
when setting the text of the script via innerHTML. A similar test exist
in block-text-node-insertion-into-svg-script-element.html, but for a
disconnected script. This PR just move the unrelated test to
trusted-types-svg-script.html instead.

[1] w3c/svgwg#934
[2] whatwg/dom#1268

--

wpt-commits: 696792b6aa714c2d7c54b986814bbdbbdecf1dd8
wpt-pr: 50043
  • Loading branch information
fred-wang authored and moz-wptsync-bot committed Jan 15, 2025
1 parent 0fa493d commit eb3c588
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<svg id="svg"><script id="script">"some script text";</script></svg>
<script>
const policy = trustedTypes.createPolicy("policy", {
createScript: x => x, createHTML: x => x, createScriptURL: x => x });
createScriptURL: script_url => script_url });

promise_test(t => {
const elem = document.createElementNS(NSURI_SVG, "script");
Expand Down Expand Up @@ -104,27 +104,14 @@
// but now expect all assignments to succeed.
promise_test(t => {
trustedTypes.createPolicy("default", {
createScript: (x, _, sink) => {
assert_equals(sink, 'SVGScriptElement text');
return x;
},
createHTML: (x, _, sink) => {
assert_equals(sink, 'Element innerHTML');
return x;
},
createScriptURL: (x, _, sink) => {
createScriptURL: (script_url, _, sink) => {
assert_equals(sink, 'SVGScriptElement href');
return x;
return script_url;
}});

return Promise.resolve();
}, "Setup default policy");

promise_test(t => {
document.getElementById("script").innerHTML = "'modified via innerHTML';";
return Promise.resolve();
}, "Assign String to SVGScriptElement.innerHTML w/ default policy.");

promise_test(t => {
const elem = document.createElementNS(NSURI_SVG, "script");
elem.href.baseVal = "about:blank";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,20 @@
document.getElementById("svg").appendChild(elem);
return promise_spv();
}, "Modify SVGScriptElement via DOM manipulation.");

promise_test(t => {
trustedTypes.createPolicy("default", {
createScript: (input, _, sink) => {
assert_equals(sink, 'SVGScriptElement text');
return input;
},
createHTML: (input, _, sink) => {
assert_equals(sink, 'Element innerHTML');
return input;
},
});
document.getElementById("script").innerHTML = "'modified via innerHTML';";
return Promise.resolve();
}, "Assign String to SVGScriptElement.innerHTML w/ default policy.");
</script>
</body>

0 comments on commit eb3c588

Please sign in to comment.