Skip to content

Commit

Permalink
Add XML test for setHTMLUnsafe/parseHTMLUnsafe
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Nov 28, 2023
1 parent 0cb547a commit 113b3dc
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<link rel=author href="mailto:[email protected]">
<link rel=help href="https://github.com/whatwg/html/pull/9538">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
test(() => {
const xmlDoc = document.implementation.createDocument(null, 'root', null);
assert_equals(xmlDoc.contentType, 'application/xml');
// Intentionally unclosed and misnested tags
xmlDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
assert_equals(xmlDoc.documentElement.innerHTML,
'<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
'Element.setHTMLUnsafe should use the HTML parser in XML documents.');
}, 'setHTMLUnsafe should still parse HTML even in XML documents.');

test(() => {
const svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'root', null);
assert_equals(svgDoc.contentType, 'image/svg+xml');
// Intentionally unclosed and misnested tags
svgDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
assert_equals(svgDoc.documentElement.innerHTML,
'<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
'Element.setHTMLUnsafe should use the HTML parser in SVG documents.');
}, 'setHTMLUnsafe should still parse HTML even in SVG documents.');
</script>

0 comments on commit 113b3dc

Please sign in to comment.