Rubber-stamped by Brady Eidson.
[webbrowser.git] / LayoutTests / svg / custom / use-elementInstance-methods.svg
blob35d67763871ae7a1ce990acc8ca6ee53f5b0ba28
1 <svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2 <defs>
3 <g id="reference">
4 <rect x="240" y="1" width="239" height="358" />
5 <circle cx="240" cy="1" width="39" height="58" />
6 </g>
8 <script type="text/ecmascript">
9 <![CDATA[
10 if (window.layoutTestController)
11 layoutTestController.waitUntilDone();
13 window.setTimeout("clickNow()", 0);
15 function clickNow() {
16 if (window.eventSender) {
17 eventSender.mouseMoveTo(250, 50);
18 eventSender.mouseDown();
19 eventSender.mouseUp();
22 if (window.layoutTestController) {
23 layoutTestController.notifyDone();
27 function test (event) {
28 // get pointers to use and referenced elements
29 var container = document.getElementById('reference');
30 var rect = container.firstChild.nextSibling;
31 var circle = rect.nextSibling.nextSibling;
32 var use = document.getElementById('use');
34 // test all SVGElementInstance methods (except childNodes)
35 var rectInstance = event.target;
36 var gInstance = rectInstance.parentNode;
37 var circleInstance = rectInstance.nextSibling;
39 // Check wheter correspdoningElement is the <rect>, and wheter <use> is set correctly.
40 if (rectInstance.correspondingElement != rect) return;
41 if (rectInstance.correspondingUseElement != use) return;
43 // Our <rect> doesn't have children.
44 if (rectInstance.firstChild) return;
45 if (rectInstance.lastChild) return;
47 // Our <rect> SVGElementInstance has the <g> SVGElementInstance as parent node
48 if (!gInstance) return;
49 if (gInstance.correspondingElement != container) return;
51 // Our <rect> SVGElementInstance has no previous sibling
52 if (rectInstance.previousSibling) return;
54 // Our <rect> SVGElementInstance has the <circle> SVGElementInstance as next sibling
55 if (!circleInstance) return;
56 if (circleInstance.correspondingElement != circle) return;
57 if (rectInstance.nextSibling != circleInstance) return;
59 // Our <g> SVGElementInstance has no parent node, and <rect> as firstChild, <circle> as lastChild
60 if (gInstance.parentNode) return;
61 if (gInstance.firstChild != rectInstance) return;
62 if (gInstance.lastChild != circleInstance) return;
64 // Hopefully we pass :-)
65 document.getElementById("status").firstChild.nodeValue = "Test passed.";
67 ]]>
68 </script>
69 </defs>
71 <text x="100" y="50" id="status">Test failed.</text>
72 <use id="use" xlink:href="#reference" onclick="test(evt)" fill="grey" />
73 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
74 </svg>