1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 <script src=
"../../resources/js-test.js"/>
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">
24 <use xlink:
href=
"#rect"/>
33 <rect id=
"siblingElem1"/>
34 <foreignObject id=
"foreign">
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')");