Skip to content

Commit 696792b

Browse files
authored
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
1 parent 35de054 commit 696792b

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

trusted-types/trusted-types-svg-script-set-href.html

+3-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<svg id="svg"><script id="script">"some script text";</script></svg>
1313
<script>
1414
const policy = trustedTypes.createPolicy("policy", {
15-
createScript: x => x, createHTML: x => x, createScriptURL: x => x });
15+
createScriptURL: script_url => script_url });
1616

1717
promise_test(t => {
1818
const elem = document.createElementNS(NSURI_SVG, "script");
@@ -104,27 +104,14 @@
104104
// but now expect all assignments to succeed.
105105
promise_test(t => {
106106
trustedTypes.createPolicy("default", {
107-
createScript: (x, _, sink) => {
108-
assert_equals(sink, 'SVGScriptElement text');
109-
return x;
110-
},
111-
createHTML: (x, _, sink) => {
112-
assert_equals(sink, 'Element innerHTML');
113-
return x;
114-
},
115-
createScriptURL: (x, _, sink) => {
107+
createScriptURL: (script_url, _, sink) => {
116108
assert_equals(sink, 'SVGScriptElement href');
117-
return x;
109+
return script_url;
118110
}});
119111

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

123-
promise_test(t => {
124-
document.getElementById("script").innerHTML = "'modified via innerHTML';";
125-
return Promise.resolve();
126-
}, "Assign String to SVGScriptElement.innerHTML w/ default policy.");
127-
128115
promise_test(t => {
129116
const elem = document.createElementNS(NSURI_SVG, "script");
130117
elem.href.baseVal = "about:blank";

trusted-types/trusted-types-svg-script.html

+15
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,20 @@
4040
document.getElementById("svg").appendChild(elem);
4141
return promise_spv();
4242
}, "Modify SVGScriptElement via DOM manipulation.");
43+
44+
promise_test(t => {
45+
trustedTypes.createPolicy("default", {
46+
createScript: (input, _, sink) => {
47+
assert_equals(sink, 'SVGScriptElement text');
48+
return input;
49+
},
50+
createHTML: (input, _, sink) => {
51+
assert_equals(sink, 'Element innerHTML');
52+
return input;
53+
},
54+
});
55+
document.getElementById("script").innerHTML = "'modified via innerHTML';";
56+
return Promise.resolve();
57+
}, "Assign String to SVGScriptElement.innerHTML w/ default policy.");
4358
</script>
4459
</body>

0 commit comments

Comments
 (0)