Skip to content

Commit

Permalink
Bug 1859344 [wpt PR 42563] - Add XML test for setHTMLUnsafe/parseHTML…
Browse files Browse the repository at this point in the history
…Unsafe, 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 <[email protected]>
Reviewed-by: David Baron <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1229667}

--

wpt-commits: 113b3dc05a9f4b3c4c5497a549320f3928c6bfa5
wpt-pr: 42563
  • Loading branch information
josepharhar authored and moz-wptsync-bot committed Dec 1, 2023
1 parent 6e26a27 commit 56d9d9a
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 56d9d9a

Please sign in to comment.