Skip to content

Commit 365769c

Browse files
committed
Bug 1859344 [wpt PR 42563] - Add XML test for setHTMLUnsafe/parseHTMLUnsafe, a=testonly
Automatic update from web-platform-tests 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 <jarharchromium.org> Reviewed-by: David Baron <dbaronchromium.org> Cr-Commit-Position: refs/heads/main{#1229667} -- wpt-commits: 113b3dc05a9f4b3c4c5497a549320f3928c6bfa5 wpt-pr: 42563 UltraBlame original commit: 59921b0032a35e9621aa1f8cc994699cf6891571
1 parent f45be4f commit 365769c

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)