| <?xml version="1.0" standalone="no"?> |
| <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" |
| "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> |
| |
| <!-- |
| |
| Copyright 2005 The Apache Software Foundation |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <!-- ====================================================================== --> |
| <!-- Test of the getElementById method --> |
| <!-- --> |
| <!-- @author deweese@apache.org --> |
| <!-- @version $Id$ --> |
| <!-- ====================================================================== --> |
| |
| <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| |
| <svg id="body" width="450" height="500" viewBox="0 0 450 500" |
| onload="doTest()" |
| xmlns="http://www.w3.org/2000/svg" |
| xmlns:xlink="http://www.w3.org/1999/xlink"> |
| |
| <title>Test of 'getElementById' method</title> |
| |
| <text x="50%" y="45" class="title">Test of 'getElementById' method</text> |
| |
| <script type="text/ecmascript"> |
| var svgns = "http://www.w3.org/2000/svg"; |
| |
| function setText(id, text, color) { |
| var tspan = document.getElementById(id); |
| tspan.appendChild(document.createTextNode(text)); |
| tspan.setAttribute("fill", color); |
| } |
| function checkTest(e, base, id, tId) { |
| if (e == base.getElementById(id)) |
| setText(tId, "success", "green"); |
| else |
| setText(tId, "failed", "red"); |
| } |
| function doTest() { |
| var g = document.getElementById("group"); |
| var id1 = g.firstChild; |
| var id2 = id1.nextSibling; |
| var id3 = id2.nextSibling; |
| var id4 = id3.nextSibling; |
| var svg1 = id4.nextSibling; |
| var id5 = svg1.firstChild; |
| var id6 = id5.nextSibling; |
| var id7 = svg1.nextSibling; |
| |
| checkTest(id1, document, "id1", "t1"); |
| checkTest(id2, document, "id2", "t2"); |
| checkTest(null, document, "undefined", "t3"); |
| |
| checkTest(svg1, document, "svg1", "t4"); |
| checkTest(svg1, svg1, "svg1", "t5"); |
| |
| checkTest(id5, document, "id5", "t6"); |
| checkTest(id5, svg1, "id5", "t7"); |
| checkTest(id6, svg1, "id6", "t8"); |
| checkTest(id7, svg1, "id7", "t9"); |
| |
| id2.setAttribute("id", "d1"); |
| checkTest(id2, document, "d1", "t10"); |
| |
| var attr = document.createAttribute("id"); |
| attr.setValue("d2"); |
| id3.setAttributeNode(attr); |
| checkTest(id3, document, "d2", "t11"); |
| checkTest(null, document, "id3", "t12"); |
| attr.setValue("d3"); |
| checkTest(id3, document, "d3", "t13"); |
| |
| id4.removeAttribute("id"); |
| checkTest(null, document, "id4", "t14"); |
| |
| svg1.parentNode.removeChild(svg1); |
| checkTest(null, document, "id5", "t15"); |
| checkTest(id5, svg1, "id5", "t16"); |
| |
| var svg2 = document.createElementNS(svgns, "svg"); |
| var id8 = document.createElementNS(svgns, "desc"); |
| svg2.appendChild(id8); |
| id8.setAttribute("id", "id8"); |
| checkTest(null, document, "id8", "t17"); |
| checkTest(null, svg1, "id8", "t18"); |
| checkTest(id8, svg2, "id8", "t19"); |
| |
| var id9 = document.createElementNS(svgns, "desc"); |
| id9.setAttribute("id", "id9"); |
| svg2.appendChild(id9); |
| checkTest(null, document, "id9", "t20"); |
| checkTest(null, svg1, "id9", "t21"); |
| checkTest(id9, svg2, "id9", "t22"); |
| |
| var id5_2 = id5.cloneNode(true); |
| g.appendChild(id5_2); |
| checkTest(id5_2, document, "id5", "t23"); |
| } |
| </script> |
| |
| <g id="group"><rect id="id1" x="10" y="60" width="50" height="50" |
| fill="gold" stroke="black" |
| /><rect id="id2" x="70" y="60" width="50" height="50" |
| fill="crimson" stroke="black" |
| /><rect id="id3" x="130" y="60" width="50" height="50" |
| fill="gold" stroke="black" |
| /><rect id="id4" x="190" y="60" width="50" height="50" |
| fill="crimson" stroke="black" |
| /><svg id="svg1" x="0" y="0" width="450" height="500" |
| ><rect id="id5" x="250" y="60" width="50" height="50" |
| fill="gold" stroke="black" |
| /><rect id="id6" x="310" y="60" width="50" height="50" |
| fill="crimson" stroke="black" |
| /></svg><rect id="id7" x="370" y="60" width="50" height="50" |
| fill="gold" stroke="black"/> |
| |
| <text x="60" y="140" text-anchor="end" |
| >Test 1: <tspan id="t1" x="65" text-anchor="start"/></text> |
| <text x="60" y="160" text-anchor="end" |
| >Test 2: <tspan id="t2" x="65" text-anchor="start"/></text> |
| <text x="60" y="180" text-anchor="end" |
| >Test 3: <tspan id="t3" x="65" text-anchor="start"/></text> |
| <text x="60" y="200" text-anchor="end" |
| >Test 4: <tspan id="t4" x="65" text-anchor="start"/></text> |
| <text x="60" y="220" text-anchor="end" |
| >Test 5: <tspan id="t5" x="65" text-anchor="start"/></text> |
| |
| <text x="60" y="240" text-anchor="end" |
| >Test 6: <tspan id="t6" x="65" text-anchor="start"/></text> |
| <text x="60" y="260" text-anchor="end" |
| >Test 7: <tspan id="t7" x="65" text-anchor="start"/></text> |
| <text x="60" y="280" text-anchor="end" |
| >Test 8: <tspan id="t8" x="65" text-anchor="start"/></text> |
| <text x="60" y="300" text-anchor="end" |
| >Test 9: <tspan id="t9" x="65" text-anchor="start"/></text> |
| <text x="60" y="320" text-anchor="end" |
| >Test 10: <tspan id="t10" x="65" text-anchor="start"/></text> |
| |
| <text x="60" y="340" text-anchor="end" |
| >Test 11: <tspan id="t11" x="65" text-anchor="start"/></text> |
| |
| |
| <text x="220" y="140" text-anchor="end" |
| >Test 12: <tspan id="t12" x="225" text-anchor="start"/></text> |
| <text x="220" y="160" text-anchor="end" |
| >Test 13: <tspan id="t13" x="225" text-anchor="start"/></text> |
| <text x="220" y="180" text-anchor="end" |
| >Test 14: <tspan id="t14" x="225" text-anchor="start"/></text> |
| <text x="220" y="200" text-anchor="end" |
| >Test 15: <tspan id="t15" x="225" text-anchor="start"/></text> |
| <text x="220" y="220" text-anchor="end" |
| >Test 16: <tspan id="t16" x="225" text-anchor="start"/></text> |
| <text x="220" y="240" text-anchor="end" |
| >Test 17: <tspan id="t17" x="225" text-anchor="start"/></text> |
| <text x="220" y="260" text-anchor="end" |
| >Test 18: <tspan id="t18" x="225" text-anchor="start"/></text> |
| <text x="220" y="280" text-anchor="end" |
| >Test 19: <tspan id="t19" x="225" text-anchor="start"/></text> |
| <text x="220" y="300" text-anchor="end" |
| >Test 20: <tspan id="t20" x="225" text-anchor="start"/></text> |
| <text x="220" y="320" text-anchor="end" |
| >Test 21: <tspan id="t21" x="225" text-anchor="start"/></text> |
| <text x="220" y="340" text-anchor="end" |
| >Test 22: <tspan id="t22" x="225" text-anchor="start"/></text> |
| <text x="220" y="360" text-anchor="end" |
| >Test 23: <tspan id="t23" x="225" text-anchor="start"/></text> |
| </g> |
| </svg> |