tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ee06bd740aa6b3cc954f1916f863f39f9caf88eb
parent 08ca4b05b4d553a2db058a22b45564b09929eb7b
Author: David Baron <dbaron@chromium.org>
Date:   Fri,  7 Nov 2025 08:56:40 +0000

Bug 1998499 [wpt PR 55880] - Add some tests for XML fragment parsing via Element.innerHTML setter., a=testonly

Automatic update from web-platform-tests
Add some tests for XML fragment parsing via Element.innerHTML setter.

I realized both the existing parser glue and the new rust-based parser
glue have bugs here.  This adds a test which will hopefully show whether
those bugs are interoperable and perhaps help to fix them.

Bug: 441911594
Change-Id: If78ccbc226758ea2991a75f59d7301a02e42ef93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7113723
Reviewed-by: Dominik Röttsches <drott@chromium.org>
Commit-Queue: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1540656}

--

wpt-commits: d9903e2afad711225c2d7d0704d497ccedec2301
wpt-pr: 55880

Diffstat:
Atesting/web-platform/tests/html/webappapis/dynamic-markup-insertion/the-innerhtml-property/innerhtml-and-xml-namespaces.svg | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+), 0 deletions(-)

diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/the-innerhtml-property/innerhtml-and-xml-namespaces.svg b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/the-innerhtml-property/innerhtml-and-xml-namespaces.svg @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" + xmlns:h="http://www.w3.org/1999/xhtml" + width="800px" height="1000px"> + <title>innerHTML setter and XML namespaces</title> + <metadata> + <h:link rel="help" href="https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#the-innerhtml-property"/> + </metadata> + <h:script src="/resources/testharness.js"/> + <h:script src="/resources/testharnessreport.js"/> + + <foreignObject> + <h:body> + <h:div/> + <g/> + <element xmlns=""/> + <element xmlns="https://example.org/ns"/> + + <h:script><![CDATA[ + "use strict"; + + const SVG_NS = "http://www.w3.org/2000/svg"; + const XHTML_NS = "http://www.w3.org/1999/xhtml"; + + const body = document.querySelector("body"); + const prefixedContainer = body.firstElementChild; + const unprefixedContainer = prefixedContainer.nextElementSibling; + const noDefaultNsContainer = unprefixedContainer.nextElementSibling; + const newDefaultNsContainer = noDefaultNsContainer.nextElementSibling; + + test(() => { + assert_equals(prefixedContainer.namespaceURI, XHTML_NS); + assert_true(prefixedContainer.isDefaultNamespace(SVG_NS)); + assert_equals(unprefixedContainer.namespaceURI, SVG_NS); + assert_true(unprefixedContainer.isDefaultNamespace(SVG_NS)); + assert_equals(noDefaultNsContainer.namespaceURI, null); + assert_true(noDefaultNsContainer.isDefaultNamespace("")); + assert_equals(newDefaultNsContainer.namespaceURI, "https://example.org/ns"); + assert_true(newDefaultNsContainer.isDefaultNamespace("https://example.org/ns")); + }, "prerequisites"); + + test(() => { + prefixedContainer.innerHTML = "<e></e>"; + assert_equals(prefixedContainer.firstChild.namespaceURI, SVG_NS); + }, "default namespace applies to children of namespaced element"); + + test(() => { + unprefixedContainer.innerHTML = "<e></e>"; + assert_equals(prefixedContainer.firstChild.namespaceURI, SVG_NS); + }, "default namespace applies to children of default-namespaced element"); + + test(() => { + noDefaultNsContainer.innerHTML = "<e></e>"; + assert_equals(prefixedContainer.firstChild.namespaceURI, null); + }, "default namespace applies to children of non-namespaced element"); + + test(() => { + newDefaultNsContainer.innerHTML = "<e></e>"; + assert_equals(prefixedContainer.firstChild.namespaceURI, "https://example.org/ns"); + }, "default namespace applies to children of namespaced element with new default namespace"); + + test(() => { + prefixedContainer.innerHTML = "<e><h:span></h:span></e>"; + assert_equals(prefixedContainer.firstChild.firstChild.namespaceURI, XHTML_NS); + }, "namespace prefix applies to children of namespaced element"); + + test(() => { + prefixedContainer.innerHTML = "<e><h:span><f></f></h:span></e>"; + assert_equals(prefixedContainer.firstChild.firstChild.firstChild.namespaceURI, SVG_NS); + }, "default namespace prefix applies to descendants of namespaced element"); + + test(() => { + prefixedContainer.innerHTML = "<e><f xmlns=''><g></g></f></e>"; + assert_equals(prefixedContainer.firstChild.firstChild.namespaceURI, null); + }, "unsetting default namespace works inside parse of fragment (on element)"); + + test(() => { + prefixedContainer.innerHTML = "<e><f xmlns=''><g></g></f></e>"; + assert_equals(prefixedContainer.firstChild.firstChild.firstChild.namespaceURI, null); + }, "unsetting default namespace works inside parse of fragment (on child of element)"); + + test(() => { + prefixedContainer.innerHTML = "<e><h:f xmlns:h='https://example.com/new-h'><g><h:d></h:d></g></h:f></e>"; + assert_equals(prefixedContainer.firstChild.firstChild.namespaceURI, "https://example.com/new-h"); + assert_equals(prefixedContainer.firstChild.firstChild.firstChild.namespaceURI, SVG_NS); + assert_equals(prefixedContainer.firstChild.firstChild.firstChild.firstChild.namespaceURI, "https://example.com/new-h"); + }, "declaring namespace with prefix inside of fragment parsed by innerHTML"); + + test(() => { + prefixedContainer.innerHTML = "<e><f xmlns='https://example.com/new-default'><h:g><d></d></h:g></f></e>"; + assert_equals(prefixedContainer.firstChild.firstChild.namespaceURI, "https://example.com/new-default"); + assert_equals(prefixedContainer.firstChild.firstChild.firstChild.namespaceURI, XHTML_NS); + assert_equals(prefixedContainer.firstChild.firstChild.firstChild.firstChild.namespaceURI, "https://example.com/new-default"); + }, "declaring default namespace inside of fragment parsed by innerHTML"); + + ]]></h:script> + </h:body> + </foreignObject> +</svg>