Debian Codegraph @

test_non_regression/fail/na/script/struct-dom-05-b.svg

raw
1 <svg version="1.1" baseProfile="basic" onload="domTest(evt)" id="svg-root"
2 width="100%" height="100%" viewBox="0 0 480 360"
3 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
4 <!--======================================================================-->
5 <!--= SVG 1.1 2nd Edition Test Case =-->
6 <!--======================================================================-->
7 <!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =-->
8 <!--= Institute of Technology, European Research Consortium for =-->
9 <!--= Informatics and Mathematics (ERCIM), Keio University). =-->
10 <!--= All Rights Reserved. =-->
11 <!--= See http://www.w3.org/Consortium/Legal/. =-->
12 <!--======================================================================-->
13 <d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/"
14 template-version="1.4" reviewer="SVGWG" author="Vincent Hardy" status="accepted"
15 version="$Revision: 1.7 $" testname="$RCSfile: struct-dom-05-b.svg,v $">
16 <d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/struct.html#DOMInterfaces">
17 <p>
18 Verify the basic capability to handle the hasFeature DOMImplementation method.
19 The DOMImplementation instance is retrieved from the Document instance. Then,
20 its hasFeature method is invoked on the various SVG feature strings.
21 </p>
22 <p>
23 The test displays the set of SVG feature strings and, next to them, a text
24 string that shows whether the feature is supported or not.
25 </p>
26 <p>
27 Note that this test uses the 'onload' event on the root svg element.
28 </p>
29 </d:testDescription>
30 <d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
31 <p>
32 Run the test. No interaction required.
33 </p>
34 </d:operatorScript>
35 <d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
36 <p>
37 The rendered picture should match the reference image, except for the true and
38 false values which may differ depending on the implementation.
39 </p>
40 <p>
41 Note that the test passes whether or not the feature is supported (i.e., true or
42 false are valid). The test fails if no value (true or false) appears next to the feature string
43 value.
44 </p>
45 </d:passCriteria>
46 </d:SVGTestCase>
47 <title id="test-title">$RCSfile: struct-dom-05-b.svg,v $</title>
48 <defs>
49 <font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F">
50 <font-face-src>
51 <font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
52 </font-face-src>
53 </font-face>
54 </defs>
55 <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
56 <script type="text/ecmascript"><![CDATA[
57
58 var featureStrings = new Array();
59 var length = 0;
60 /*
61 featureStrings[length++] = "xml";
62 featureStrings[length++] = "stylesheets";
63 featureStrings[length++] = "views";
64 featureStrings[length++] = "css2";
65 featureStrings[length++] = "events";
66 featureStrings[length++] = "uievents ";
67 featureStrings[length++] = "mouseevents";
68 featureStrings[length++] = "mutationevents";
69 featureStrings[length++] = "traversal";
70 featureStrings[length++] = "org.w3c.svg";
71 featureStrings[length++] = "org.w3c.svg.lang";
72 featureStrings[length++] = "org.w3c.svg.dynamic";
73 featureStrings[length++] = "org.w3c.svg.static";
74 featureStrings[length++] = "org.w3c.dom.svg";
75 featureStrings[length++] = "org.w3c.svg";
76 */
77 featureStrings[length++] = "org.w3c.dom.svg.static";
78 featureStrings[length++] = "org.w3c.dom.svg.animation";
79 featureStrings[length++] = "org.w3c.dom.svg.dynamic";
80 featureStrings[length++] = "org.w3c.dom.svg.all";
81 featureStrings[length++] = "org.w3c.svg.all";
82 var svg_ns = "http://www.w3.org/2000/svg"
83 function domTest(evt) {
84 // Get Document
85 var target = evt.target;
86 var doc = target.ownerDocument;
87
88 // Get DOMImplementation
89 var domImpl = doc.implementation;
90
91 //
92 // Iterate through the feature strings
93 //
94 for(var i=0; i<featureStrings.length; i++){
95 var supports = domImpl.hasFeature(featureStrings[i], '2.0');
96 //
97 // if time, pretty up by putting xml to traveral in a left column and
98 // org.w3c.svg to org.w3c.dom.svg.all in a right column; add an extra
99 // parameter to addTextElemen t for x coord, and test if i < 9
100 //
101 addTextElement(featureStrings[i], supports, doc, doc.getElementById("test-body-content"), (45 + 40*i));
102 }
103 }
104
105 function addTextElement(label, value, doc, svg, y){
106 var newText = doc.createElementNS(svg_ns, 'text');
107 newText.setAttribute('font-size', '30');
108 newText.setAttribute('x', '5');
109 newText.setAttribute('y', y);
110 var textValue = label;
111 var textContent = doc.createTextNode(textValue);
112 newText.appendChild(textContent);
113 svg.appendChild(newText);
114
115 newText = doc.createElementNS(svg_ns, 'text');
116 newText.setAttribute('font-size', '30');
117 newText.setAttribute('x', '385');
118 newText.setAttribute('y', y);
119 textValue = value;
120 textContent = doc.createTextNode(textValue);
121 newText.appendChild(textContent);
122 svg.appendChild(newText);
123 }
124
125 ]]></script>
126 </g>
127 <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
128 <text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.7 $</text>
129 </g>
130 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
131 <!-- comment out this watermark once the test is approved -->
132 <!--<g id="draft-watermark">
133 <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
134 <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
135 text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
136 </g>-->
137 </svg>