1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_w3element_traversal_svg.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +<!DOCTYPE html> 1.5 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.6 +<head> 1.7 + <title>Test for ElementTraversal via SVG</title> 1.8 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.9 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.10 +</head> 1.11 +<body> 1.12 + 1.13 +<p id="display"></p> 1.14 +<div id="content" style="display: none"></div> 1.15 + 1.16 +<iframe id="svg" src="w3element_traversal.svg"></iframe> 1.17 + 1.18 +<pre id="test"> 1.19 +<script class="testbody" type="application/javascript"> 1.20 +SimpleTest.waitForExplicitFinish(); 1.21 + 1.22 +function run() 1.23 +{ 1.24 + var doc = $("svg").contentDocument; 1.25 + 1.26 + //et-namespace.svg 1.27 + var parentEl = doc.getElementById("parentEl_namespace"); 1.28 + var nChild = parentEl.firstElementChild; 1.29 + is(nChild && "dill", nChild.localName, "failed to get child with namespace") 1.30 + 1.31 + //et-previousElementSibling.svg 1.32 + var lec = doc.getElementById("last_element_child_pes"); 1.33 + var pes = lec.previousElementSibling; 1.34 + isnot(pes, null, "previousElementSibling is null"); 1.35 + is(pes.nodeType, 1, "previousElementSibling returned the wrong node type"); 1.36 + is(pes.getAttribute("id"), "middle_element_child_pes", "previousElementSibling returned the wrong child"); 1.37 + 1.38 + //et-sibling_null.svg 1.39 + var fec = doc.getElementById("first_element_child_sibnull"); 1.40 + var pes = fec.previousElementSibling; 1.41 + var nes = fec.nextElementSibling; 1.42 + is(pes, null, "previousElementSibling is not null"); 1.43 + is(nes, null, "nextElementSibling is not null"); 1.44 + 1.45 + //et-nextElementSibling.svg 1.46 + fec = doc.getElementById("first_element_child_nes"); 1.47 + var nes = fec.nextElementSibling; 1.48 + isnot(nes, null, "nextElementSibling returned NULL"); 1.49 + is(nes.nodeType, 1, "nextElementSibling returned wrong node type"); 1.50 + is(nes.getAttribute("id"), "last_element_child_nes", "nextElementSibling returned wrong node id"); 1.51 + 1.52 + //et-lastElementChild.svg 1.53 + var parentEl = doc.getElementById("parentEl_lec"); 1.54 + var lec = parentEl.lastElementChild; 1.55 + isnot(lec, null, "lastElementChild returned null"); 1.56 + is(lec.nodeType, 1, "lastElementChild returned wrong nodeType"); 1.57 + is(lec.getAttribute("id"), "last_element_child_lec", "lastElementChild returned wrong id"); 1.58 + 1.59 + //et-firstElementChild.svg 1.60 + var parentEl = doc.getElementById("parentEl_fec"); 1.61 + var fec = parentEl.firstElementChild; 1.62 + isnot(fec, null, "firstElementChild returned null"); 1.63 + is(fec.nodeType, 1, "firstElementChild returned wrong nodeType"); 1.64 + is(fec.getAttribute("id"), "first_element_child_fec", "firstElementChild returned wrong id"); 1.65 + 1.66 + //et-entity.svg 1.67 + var parentEl = doc.getElementById("parentEl_entity"); 1.68 + var fec = parentEl.firstElementChild; 1.69 + isnot(fec, null, "firstElementChild returned null"); 1.70 + is(fec.nodeType, 1, "firstElementChild returned wrong nodeType"); 1.71 + is(fec.getAttribute("id"), "first_element_child_entity", "firstElementChild returned wrong id"); 1.72 + 1.73 + //et-dynamic-remove.svg 1.74 + var parentEl = doc.getElementById("parentEl_dynremove"); 1.75 + var lec = parentEl.lastElementChild; 1.76 + parentEl.removeChild( lec ); 1.77 + is(parentEl.childElementCount && 1, parentEl.childElementCount, "failed to removeChild"); 1.78 + 1.79 + //et-dynamic-add.svg 1.80 + var parentEl = doc.getElementById("parentEl_dynadd"); 1.81 + var newChild = doc.createElementNS("http://www.w3.org/2000/svg", "tspan"); 1.82 + parentEl.appendChild( newChild ); 1.83 + is(parentEl.childElementCount && 2, parentEl.childElementCount, "failed to appendChild"); 1.84 + 1.85 + //et-childElement-null.svg 1.86 + var parentEl = doc.getElementById("parentEl_null"); 1.87 + var fec = parentEl.firstElementChild; 1.88 + var lec = parentEl.lastElementChild; 1.89 + is(fec, null, "expected null from firstElementChild"); 1.90 + is(lec, null, "expected null from lastElementChild"); 1.91 + 1.92 + 1.93 + //et-childElementCount.svg 1.94 + var parentEl = doc.getElementById("parentEl_count"); 1.95 + is(parentEl.childElementCount && 3, parentEl.childElementCount, "got wrong childElementCount"); 1.96 + 1.97 + //et-childElementCount-nochild.svg 1.98 + var parentEl = doc.getElementById("parentEl_nochild"); 1.99 + is(0, parentEl.childElementCount, "got wrong childElementCount"); 1.100 + 1.101 + 1.102 + SimpleTest.finish(); 1.103 +} 1.104 + 1.105 +window.addEventListener("load", run, false); 1.106 +</script> 1.107 +</pre> 1.108 +</body> 1.109 +</html> 1.110 +