Skip to content

Commit 113b3dc

Browse files
Add XML test for setHTMLUnsafe/parseHTMLUnsafe
This was recommended here: https://chromium-review.googlesource.com/c/chromium/src/+/4824679/3..8/third_party/blink/web_tests/external/wpt/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe.html#b6 Bug: 1478969 Change-Id: Ic2a6ef62d2b1affde4cadc8cf131b60cb57af33a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4942972 Commit-Queue: Joey Arhar <[email protected]> Reviewed-by: David Baron <[email protected]> Cr-Commit-Position: refs/heads/main@{#1229667}
1 parent 0cb547a commit 113b3dc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<link rel=author href="mailto:[email protected]">
3+
<link rel=help href="https://github.com/whatwg/html/pull/9538">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
7+
<script>
8+
test(() => {
9+
const xmlDoc = document.implementation.createDocument(null, 'root', null);
10+
assert_equals(xmlDoc.contentType, 'application/xml');
11+
// Intentionally unclosed and misnested tags
12+
xmlDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
13+
assert_equals(xmlDoc.documentElement.innerHTML,
14+
'<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
15+
'Element.setHTMLUnsafe should use the HTML parser in XML documents.');
16+
}, 'setHTMLUnsafe should still parse HTML even in XML documents.');
17+
18+
test(() => {
19+
const svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'root', null);
20+
assert_equals(svgDoc.contentType, 'image/svg+xml');
21+
// Intentionally unclosed and misnested tags
22+
svgDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
23+
assert_equals(svgDoc.documentElement.innerHTML,
24+
'<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
25+
'Element.setHTMLUnsafe should use the HTML parser in SVG documents.');
26+
}, 'setHTMLUnsafe should still parse HTML even in SVG documents.');
27+
</script>

0 commit comments

Comments
 (0)