Merge pull request #124 from lightpanda-io/dom-parentnode
Dom parentnode accessors mixin
20
tests/wpt/dom/nodes/Element-childElement-null-svg.svg
Normal 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: 787 B |
20
tests/wpt/dom/nodes/Element-childElement-null-xhtml.xhtml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Null Test</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of firstElementChild and lastChildElement returning null</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl" style="font-weight:bold;">Test.</p>
|
||||
<script><![CDATA[
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl")
|
||||
assert_equals(parentEl.firstElementChild, null)
|
||||
assert_equals(parentEl.lastElementChild, null)
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
15
tests/wpt/dom/nodes/Element-childElement-null.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>Null test</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of firstElementChild and lastChildElement returning null</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl" style="font-weight:bold;">Test.</p>
|
||||
<script>
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl")
|
||||
assert_equals(parentEl.firstElementChild, null)
|
||||
assert_equals(parentEl.lastElementChild, null)
|
||||
})
|
||||
</script>
|
||||
@@ -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: 913 B |
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Dynamic Adding of Elements</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of Dynamic Adding of Elements</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is
|
||||
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
|
||||
<script><![CDATA[
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl");
|
||||
var newChild = document.createElement("span");
|
||||
parentEl.appendChild(newChild);
|
||||
assert_equals(parentEl.childElementCount, 2)
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>Dynamic Adding of Elements</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of Dynamic Adding of Elements</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is
|
||||
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
|
||||
<script>
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl");
|
||||
var newChild = document.createElement("span");
|
||||
parentEl.appendChild(newChild);
|
||||
assert_equals(parentEl.childElementCount, 2)
|
||||
})
|
||||
</script>
|
||||
@@ -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: 907 B |
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Dynamic Removal of Elements</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of Removal Adding of Elements</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is
|
||||
<span id="first_element_child" style="font-weight:bold;">logged above.</span><span id="last_element_child"> </span></p>
|
||||
<script><![CDATA[
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl");
|
||||
var lec = parentEl.lastElementChild;
|
||||
parentEl.removeChild(lec);
|
||||
assert_equals(parentEl.childElementCount, 1)
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>Dynamic Removal of Elements</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of Dynamic Removal of Elements</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is
|
||||
<span id="first_element_child" style="font-weight:bold;">unknown.</span><span id="last_element_child"> </span></p>
|
||||
<script>
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl");
|
||||
var lec = parentEl.lastElementChild;
|
||||
parentEl.removeChild(lec);
|
||||
assert_equals(parentEl.childElementCount, 1)
|
||||
})
|
||||
</script>
|
||||
@@ -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: 735 B |
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>childElementCount without Child Element Nodes</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of childElementCount with No Child Element Nodes</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl" style="font-weight:bold;">Test.</p>
|
||||
<script><![CDATA[
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl")
|
||||
assert_equals(parentEl.childElementCount, 0)
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
14
tests/wpt/dom/nodes/Element-childElementCount-nochild.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>childElementCount without Child Element Nodes</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of childElementCount with No Child Element Nodes</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl" style="font-weight:bold;">Test.</p>
|
||||
<script>
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl")
|
||||
assert_equals(parentEl.childElementCount, 0)
|
||||
})
|
||||
</script>
|
||||
25
tests/wpt/dom/nodes/Element-childElementCount-svg.svg
Normal 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: 967 B |
25
tests/wpt/dom/nodes/Element-childElementCount-xhtml.xhtml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>childElementCount</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of childElementCount</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of <span id="first_element_child"><span>this</span> <span>test</span></span> is
|
||||
<span id="middle_element_child" style="font-weight:bold;">unknown.</span>
|
||||
|
||||
|
||||
|
||||
<span id="last_element_child" style="display:none;">fnord</span> </p>
|
||||
<script><![CDATA[
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl")
|
||||
assert_true("childElementCount" in parentEl)
|
||||
assert_equals(parentEl.childElementCount, 3)
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
20
tests/wpt/dom/nodes/Element-childElementCount.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>childElementCount</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of childElementCount</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of <span id="first_element_child"><span>this</span> <span>test</span></span> is
|
||||
<span id="middle_element_child" style="font-weight:bold;">given above.</span>
|
||||
|
||||
|
||||
|
||||
<span id="last_element_child" style="display:none;">fnord</span> </p>
|
||||
<script>
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl")
|
||||
assert_true("childElementCount" in parentEl)
|
||||
assert_equals(parentEl.childElementCount, 3)
|
||||
})
|
||||
</script>
|
||||
58
tests/wpt/dom/nodes/Element-children.html
Normal file
@@ -0,0 +1,58 @@
|
||||
<!DOCTYPE html>
|
||||
<title>HTMLCollection edge cases</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<div id="test"><img><img id=foo><img id=foo><img name="bar"></div>
|
||||
<script>
|
||||
setup(function() {
|
||||
// Add some non-HTML elements in there to test what happens with those.
|
||||
var container = document.getElementById("test");
|
||||
var child = document.createElementNS("", "img");
|
||||
child.setAttribute("id", "baz");
|
||||
container.appendChild(child);
|
||||
|
||||
child = document.createElementNS("", "img");
|
||||
child.setAttribute("name", "qux");
|
||||
container.appendChild(child);
|
||||
});
|
||||
|
||||
test(function() {
|
||||
var container = document.getElementById("test");
|
||||
var result = container.children.item("foo");
|
||||
assert_true(result instanceof Element, "Expected an Element.");
|
||||
assert_false(result.hasAttribute("id"), "Expected the IDless Element.")
|
||||
})
|
||||
|
||||
test(function() {
|
||||
var container = document.getElementById("test");
|
||||
var list = container.children;
|
||||
var result = [];
|
||||
for (var p in list) {
|
||||
if (list.hasOwnProperty(p)) {
|
||||
result.push(p);
|
||||
}
|
||||
}
|
||||
assert_array_equals(result, ['0', '1', '2', '3', '4', '5']);
|
||||
result = Object.getOwnPropertyNames(list);
|
||||
assert_array_equals(result, ['0', '1', '2', '3', '4', '5', 'foo', 'bar', 'baz']);
|
||||
|
||||
// Mapping of exposed names to their indices in the list.
|
||||
var exposedNames = { 'foo': 1, 'bar': 3, 'baz': 4 };
|
||||
for (var exposedName in exposedNames) {
|
||||
assert_true(exposedName in list);
|
||||
assert_true(list.hasOwnProperty(exposedName));
|
||||
assert_equals(list[exposedName], list.namedItem(exposedName));
|
||||
assert_equals(list[exposedName], list.item(exposedNames[exposedName]));
|
||||
assert_true(list[exposedName] instanceof Element);
|
||||
}
|
||||
|
||||
var unexposedNames = ['qux'];
|
||||
for (var unexposedName of unexposedNames) {
|
||||
assert_false(unexposedName in list);
|
||||
assert_false(list.hasOwnProperty(unexposedName));
|
||||
assert_equals(list[unexposedName], undefined);
|
||||
assert_equals(list.namedItem(unexposedName), null);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
||||
[
|
||||
<!ENTITY tree "<span id='first_element_child' style='font-weight:bold;'>unknown.</span>">
|
||||
]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>Entity References</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of Entity References</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is &tree;</p>
|
||||
<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")
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
26
tests/wpt/dom/nodes/Element-firstElementChild-entity.svg
Normal 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: 1015 B |
@@ -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: 888 B |
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:pickle="http://ns.example.org/pickle">
|
||||
<head>
|
||||
<title>firstElementChild with namespaces</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of firstElementChild with namespaces</h1>
|
||||
<div id="parentEl">
|
||||
<pickle:dill id="first_element_child"/>
|
||||
</div>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is
|
||||
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
|
||||
<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")
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
21
tests/wpt/dom/nodes/Element-firstElementChild-namespace.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>firstElementChild with namespaces</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of firstElementChild with namespaces</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is a unknown.</p>
|
||||
<script>
|
||||
test(function() {
|
||||
var parentEl = document.getElementById("parentEl")
|
||||
var el = document.createElementNS("http://ns.example.org/pickle", "pickle:dill")
|
||||
el.setAttribute("id", "first_element_child")
|
||||
parentEl.appendChild(el)
|
||||
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")
|
||||
})
|
||||
</script>
|
||||
23
tests/wpt/dom/nodes/Element-firstElementChild-svg.svg
Normal 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: 889 B |
23
tests/wpt/dom/nodes/Element-firstElementChild-xhtml.xhtml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>firstElementChild</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of firstElementChild</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is
|
||||
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
|
||||
<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")
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
18
tests/wpt/dom/nodes/Element-firstElementChild.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>firstElementChild</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of firstElementChild</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of this test is
|
||||
<span id="first_element_child" style="font-weight:bold;">logged above.</span></p>
|
||||
<script>
|
||||
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")
|
||||
})
|
||||
</script>
|
||||
43
tests/wpt/dom/nodes/Element-getElementsByClassName.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<title>Element.getElementsByClassName</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var a = document.createElement("a"), b = document.createElement("b")
|
||||
b.className = "foo"
|
||||
a.appendChild(b)
|
||||
var list = a.getElementsByClassName("foo")
|
||||
assert_array_equals(list, [b])
|
||||
var secondList = a.getElementsByClassName("foo")
|
||||
assert_true(list === secondList || list !== secondList, "Caching is allowed.")
|
||||
}, "getElementsByClassName should work on disconnected subtrees.")
|
||||
|
||||
test(function() {
|
||||
var list = document.getElementsByClassName("foo")
|
||||
assert_false(list instanceof NodeList, "NodeList")
|
||||
assert_true(list instanceof HTMLCollection, "HTMLCollection")
|
||||
}, "Interface should be correct.")
|
||||
|
||||
test(function() {
|
||||
var a = document.createElement("a");
|
||||
var b = document.createElement("b");
|
||||
var c = document.createElement("c");
|
||||
b.className = "foo";
|
||||
document.body.appendChild(a);
|
||||
this.add_cleanup(function() {document.body.removeChild(a)});
|
||||
a.appendChild(b);
|
||||
|
||||
var l = a.getElementsByClassName("foo");
|
||||
assert_true(l instanceof HTMLCollection);
|
||||
assert_equals(l.length, 1);
|
||||
|
||||
c.className = "foo";
|
||||
a.appendChild(c);
|
||||
assert_equals(l.length, 2);
|
||||
|
||||
a.removeChild(c);
|
||||
assert_equals(l.length, 1);
|
||||
}, "getElementsByClassName() should be a live collection");
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
<root/>
|
||||
@@ -0,0 +1,51 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title></title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<iframe src="Element-getElementsByTagName-change-document-HTMLNess-iframe.xml"></iframe>
|
||||
<script>
|
||||
setup({ single_test: true });
|
||||
onload = function() {
|
||||
var parent = document.createElement("div");
|
||||
var child1 = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
|
||||
child1.textContent = "xhtml:a";
|
||||
var child2 = document.createElementNS("http://www.w3.org/1999/xhtml", "A");
|
||||
child2.textContent = "xhtml:A";
|
||||
var child3 = document.createElementNS("", "a");
|
||||
child3.textContent = "a";
|
||||
var child4 = document.createElementNS("", "A");
|
||||
child4.textContent = "A";
|
||||
|
||||
parent.appendChild(child1);
|
||||
parent.appendChild(child2);
|
||||
parent.appendChild(child3);
|
||||
parent.appendChild(child4);
|
||||
|
||||
var list = parent.getElementsByTagName("A");
|
||||
assert_array_equals(list, [child1, child4],
|
||||
"In an HTML document, should lowercase the tagname passed in for HTML " +
|
||||
"elements only");
|
||||
|
||||
frames[0].document.documentElement.appendChild(parent);
|
||||
assert_array_equals(list, [child1, child4],
|
||||
"After changing document, should still be lowercasing for HTML");
|
||||
|
||||
assert_array_equals(parent.getElementsByTagName("A"),
|
||||
[child2, child4],
|
||||
"New list with same root and argument should not be lowercasing now");
|
||||
|
||||
// Now reinsert all those nodes into the parent, to blow away caches.
|
||||
parent.appendChild(child1);
|
||||
parent.appendChild(child2);
|
||||
parent.appendChild(child3);
|
||||
parent.appendChild(child4);
|
||||
assert_array_equals(list, [child1, child4],
|
||||
"After blowing away caches, should still have the same list");
|
||||
|
||||
assert_array_equals(parent.getElementsByTagName("A"),
|
||||
[child2, child4],
|
||||
"New list with same root and argument should still not be lowercasing");
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
30
tests/wpt/dom/nodes/Element-getElementsByTagName.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Element.getElementsByTagName</title>
|
||||
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-getelementsbytagname">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="Document-Element-getElementsByTagName.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var element;
|
||||
setup(function() {
|
||||
element = document.createElement("div");
|
||||
element.appendChild(document.createTextNode("text"));
|
||||
var p = element.appendChild(document.createElement("p"));
|
||||
p.appendChild(document.createElement("a"))
|
||||
.appendChild(document.createTextNode("link"));
|
||||
p.appendChild(document.createElement("b"))
|
||||
.appendChild(document.createTextNode("bold"));
|
||||
p.appendChild(document.createElement("em"))
|
||||
.appendChild(document.createElement("u"))
|
||||
.appendChild(document.createTextNode("emphasized"));
|
||||
element.appendChild(document.createComment("comment"));
|
||||
});
|
||||
|
||||
test_getElementsByTagName(element, element);
|
||||
|
||||
test(function() {
|
||||
assert_array_equals(element.getElementsByTagName(element.localName), []);
|
||||
}, "Matching the context object");
|
||||
</script>
|
||||
37
tests/wpt/dom/nodes/Element-getElementsByTagNameNS.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Element.getElementsByTagNameNS</title>
|
||||
<link rel=help href="https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="Document-Element-getElementsByTagNameNS.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var element;
|
||||
setup(function() {
|
||||
element = document.createElement("div");
|
||||
element.appendChild(document.createTextNode("text"));
|
||||
var p = element.appendChild(document.createElement("p"));
|
||||
p.appendChild(document.createElement("a"))
|
||||
.appendChild(document.createTextNode("link"));
|
||||
p.appendChild(document.createElement("b"))
|
||||
.appendChild(document.createTextNode("bold"));
|
||||
p.appendChild(document.createElement("em"))
|
||||
.appendChild(document.createElement("u"))
|
||||
.appendChild(document.createTextNode("emphasized"));
|
||||
element.appendChild(document.createComment("comment"));
|
||||
});
|
||||
|
||||
test_getElementsByTagNameNS(element, element);
|
||||
|
||||
test(function() {
|
||||
assert_array_equals(element.getElementsByTagNameNS("*", element.localName), []);
|
||||
}, "Matching the context object (wildcard namespace)");
|
||||
|
||||
test(function() {
|
||||
assert_array_equals(
|
||||
element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",
|
||||
element.localName),
|
||||
[]);
|
||||
}, "Matching the context object (specific namespace)");
|
||||
</script>
|
||||
22
tests/wpt/dom/nodes/Element-lastElementChild-svg.svg
Normal 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: 926 B |
22
tests/wpt/dom/nodes/Element-lastElementChild-xhtml.xhtml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>firstElementChild</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Test of firstElementChild</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of <span id="first_element_child">this test</span> is <span id="last_element_child" style="font-weight:bold;">logged</span> above.</p>
|
||||
<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")
|
||||
})
|
||||
]]></script>
|
||||
</body>
|
||||
</html>
|
||||
17
tests/wpt/dom/nodes/Element-lastElementChild.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE HTML>
|
||||
<meta charset=utf-8>
|
||||
<title>lastElementChild</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<h1>Test of lastElementChild</h1>
|
||||
<div id="log"></div>
|
||||
<p id="parentEl">The result of <span id="first_element_child">this test</span> is <span id="last_element_child" style="font-weight:bold;">logged</span> above.</p>
|
||||
<script>
|
||||
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")
|
||||
})
|
||||
</script>
|
||||
27
tests/wpt/dom/nodes/ParentNode-children.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>ParentNode.children</title>
|
||||
<link rel=help href="https://dom.spec.whatwg.org/#dom-parentnode-children">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<div style="display: none">
|
||||
<ul><li id='test'>1</li><li>2</li><li>3</li><li>4</li></ul>
|
||||
</div>
|
||||
<script>
|
||||
test(() => {
|
||||
var node = document.getElementById("test");
|
||||
var parentNode = node.parentNode;
|
||||
var children = parentNode.children;
|
||||
assert_true(children instanceof HTMLCollection);
|
||||
var li = document.createElement("li");
|
||||
assert_equals(children.length, 4);
|
||||
|
||||
parentNode.appendChild(li);
|
||||
assert_equals(children.length, 5);
|
||||
|
||||
parentNode.removeChild(li);
|
||||
assert_equals(children.length, 4);
|
||||
}, "ParentNode.children should be a live collection");
|
||||
</script>
|
||||
</html>
|
||||