Tests: Import some newly-passing SVG tests

This commit is contained in:
Tim Ledbetter 2025-02-25 11:56:52 +00:00 committed by Jelle Raaijmakers
parent 96fc840b03
commit abe1e14812
Notes: github-actions[bot] 2025-02-25 14:03:36 +00:00
26 changed files with 403 additions and 0 deletions

View file

@ -0,0 +1,9 @@
Harness status: OK
Found 4 tests
4 Pass
Pass new Document(): interfaces
Pass new Document(): children
Pass new Document(): metadata
Pass new Document(): characterSet aliases

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass Null test

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass Dynamic Adding of Elements

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass Dynamic Removal of Elements

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass childElementCount

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass childElementCount

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass Entity References

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass firstElementChild with namespaces

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass firstElementChild

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass lastElementChild

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass nextElementSibling

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass previousElementSibling

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass Null test

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="windows-1252"?>
<!-- Using windows-1252 to ensure that new Document() doesn't inherit utf-8
from the parent document. -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml"
width="100%" height="100%" viewBox="0 0 800 600">
<title>Document constructor</title>
<html:script src="../../resources/testharness.js"></html:script>
<html:script src="../../resources/testharnessreport.js"></html:script>
<html:script><![CDATA[
test(function() {
var doc = new Document();
assert_true(doc instanceof Node, "Should be a Node");
assert_true(doc instanceof Document, "Should be a Document");
assert_false(doc instanceof XMLDocument, "Should not be an XMLDocument");
assert_equals(Object.getPrototypeOf(doc), Document.prototype,
"Document should be the primary interface");
}, "new Document(): interfaces")
test(function() {
var doc = new Document();
assert_equals(doc.firstChild, null, "firstChild");
assert_equals(doc.lastChild, null, "lastChild");
assert_equals(doc.doctype, null, "doctype");
assert_equals(doc.documentElement, null, "documentElement");
assert_array_equals(doc.childNodes, [], "childNodes");
}, "new Document(): children")
test(function() {
var doc = new Document();
assert_equals(doc.URL, "about:blank");
assert_equals(doc.documentURI, "about:blank");
assert_equals(doc.compatMode, "CSS1Compat");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.contentType, "application/xml");
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "new Document(): metadata")
test(function() {
var doc = new Document();
assert_equals(doc.characterSet, "UTF-8", "characterSet");
assert_equals(doc.charset, "UTF-8", "charset");
assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "new Document(): characterSet aliases")
]]></html:script>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Null test</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of firstElementChild and lastChildElement returning null</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle" font-weight="bold">Test</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.firstElementChild, null)
assert_equals(parentEl.lastElementChild, null)
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 797 B

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Dynamic Adding of Elements</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of Dynamic Adding of Elements</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is
<tspan id="first_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var newChild = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
parentEl.appendChild(newChild);
assert_equals(parentEl.childElementCount, 2)
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 923 B

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Dynamic Removal of Elements</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of Dynamic Removal of Elements</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is
<tspan id="first_element_child" font-weight="bold">unknown.</tspan><tspan id="last_element_child"> </tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
parentEl.removeChild(lec);
assert_equals(parentEl.childElementCount, 1)
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 917 B

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>childElementCount</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of childElementCount with No Child Element Nodes</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle" font-weight="bold">Test</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_equals(parentEl.childElementCount, 0)
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 745 B

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>childElementCount</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of childElementCount</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child"><tspan>this</tspan> <tspan>test</tspan></tspan> is
<tspan id="middle_element_child" font-weight="bold">unknown.</tspan>
<tspan id="last_element_child" style="display:none;">fnord</tspan> </text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
assert_true("childElementCount" in parentEl)
assert_equals(parentEl.childElementCount, 3)
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 977 B

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
[
<!ENTITY tree "<tspan id='first_element_child' font-weight='bold'>unknown.</tspan>">
]>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Entity References</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of Entity References</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is &tree;</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl")
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:pickle="http://ns.example.org/pickle"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>firstElementChild with namespaces</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of firstElementChild with namespaces</text>
<g id="parentEl">
<pickle:dill id="first_element_child"/>
</g>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
assert_equals(fec.localName, "dill")
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 898 B

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>firstElementChild</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of firstElementChild</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is
<tspan id="first_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = parentEl.firstElementChild;
assert_true(!!fec)
assert_equals(fec.nodeType, 1)
assert_equals(fec.getAttribute("id"), "first_element_child")
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 899 B

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>lastElementChild</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of lastElementChild</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child">this test</tspan> is <tspan id="last_element_child" font-weight="bold">not</tspan> known.</text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = parentEl.lastElementChild;
assert_true(!!lec)
assert_equals(lec.nodeType, 1)
assert_equals(lec.getAttribute("id"), "last_element_child")
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 936 B

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>nextElementSibling</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of nextElementSibling</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child">this test</tspan> is <tspan id="last_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var fec = document.getElementById("first_element_child");
var nes = fec.nextElementSibling;
assert_true(!!nes)
assert_equals(nes.nodeType, 1)
assert_equals(nes.getAttribute("id"), "last_element_child")
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 995 B

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>previousElementSibling</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of previousElementSibling</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of <tspan id="first_element_child">this test</tspan> is
<tspan id="middle_element_child" font-weight="bold">unknown.</tspan>
<tspan id="last_element_child" display="none">fnord</tspan> </text>
<h:script><![CDATA[
test(function() {
var parentEl = document.getElementById("parentEl");
var lec = document.getElementById("last_element_child");
var pes = lec.previousElementSibling;
assert_true(!!pes)
assert_equals(pes.nodeType, 1)
assert_equals(pes.getAttribute("id"), "middle_element_child")
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
version="1.1"
width="100%" height="100%" viewBox="0 0 400 400">
<title>Null test</title>
<h:script src="../../resources/testharness.js"/>
<h:script src="../../resources/testharnessreport.js"/>
<text x="200" y="40" font-size="25" fill="black" text-anchor="middle">Test of previousElementSibling and nextElementSibling returning null</text>
<text id="parentEl" x="200" y="70" font-size="20" fill="black" text-anchor="middle">The result of this test is <tspan id="first_element_child" font-weight="bold">unknown.</tspan></text>
<h:script><![CDATA[
test(function() {
var fec = document.getElementById("first_element_child");
assert_equals(fec.previousElementSibling, null)
assert_equals(fec.nextElementSibling, null)
})
]]></h:script>
</svg>

After

Width:  |  Height:  |  Size: 879 B