Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / custom / svg-getelementid.xhtml
blobded5cd2b3d2998a0c442eff13420fc43cb4729d7
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <script src="../../resources/js-test.js"/>
4 </head>
5 <body>
7 <div id="console"/>
9 <div id="foo"/>
10 <div id="bar"/>
12 <svg id="svg-root" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
13 <g id="test-body-content">
14 <defs>
15 <rect id="rect"/>
16 </defs>
17 <svg id="svgTree1">
18 <rect id="subElem1"/>
19 </svg>
20 <svg>
21 <rect id="subElem2"/>
22 </svg>
23 <svg id="svgTree3">
24 <use xlink:href="#rect"/>
25 </svg>
26 <svg id="svgTree4">
27 <rect id="foo"/>
28 </svg>
29 <svg id="svgTree5">
30 <rect id="bar"/>
31 <rect id="bar"/>
32 </svg>
33 <rect id="siblingElem1"/>
34 <foreignObject id="foreign">
35 <div id="nonsvg"/>
36 </foreignObject>
37 </g>
38 </svg>
40 <div id="foo"/>
42 <script><![CDATA[
43 if (window.testRunner)
44 testRunner.dumpAsText();
45 var svgTree1 = document.getElementById("svgTree1");
47 // Test support for "getElementById" on svgTree1
48 var subElem1 = svgTree1.getElementById("subElem1");
49 shouldBeTrue("null != subElem1");
50 shouldBe(subElem1.id, "subElem1");
52 // Test that "getElementById" on svgTree1 can't access children in other subtrees
53 shouldBeTrue("null == svgTree1.getElementById('subElem2')");
55 // Test that "getElementById" on svgTree1 can't access elements that are not its children
56 shouldBeTrue("null == svgTree1.getElementById('siblingElem1')");
58 // Test that an element outside of the subtree referenced through <use> is not found
59 var svgTree3 = document.getElementById("svgTree3");
60 shouldBeTrue("null == svgTree3.getElementById('rect')");
62 // Test that the <svg> being searched on is not found itself
63 shouldBeTrue("null == svgTree3.getElementById('svgTree3')");
65 // Test that search in svg returns the id from the subtree, not the div with the same id
66 var root = document.getElementById("svg-root");
67 var svgTree4 = document.getElementById("svgTree4");
68 shouldBeTrue("svgTree4.firstChild.nextSibling == root.getElementById('foo')");
70 // Test that search in svg subtree returns the first of the duplicates, not the div with the same id
71 var svgTree5 = document.getElementById("svgTree5");
72 var bar = root.getElementById("bar");
73 shouldBeTrue("svgTree5.firstChild.nextSibling == bar");
75 // Test that search in svg subtree returns the first of the duplicates
76 shouldBeTrue("svgTree5.firstChild.nextSibling == svgTree5.getElementById('bar')");
78 // Test that non SVG content can be found in the svg subtree
79 var nonsvg = root.getElementById("nonsvg");
80 var foreign = root.getElementById("foreign");
81 shouldBeTrue("foreign.firstChild.nextSibling == nonsvg");
83 // Test that SVG element can find child elements when svg is not part of document yet
84 var orphanSvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
85 var childSvg = document.createElementNS('http://www.w3.org/2000/svg', 'g');
86 orphanSvg.appendChild(childSvg)
87 childSvg.id = 'fooSvg2'
88 shouldBeTrue("childSvg == orphanSvg.getElementById('fooSvg2')");
89 ]]></script>
91 </body>
92 </html>