Debian Codegraph @

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

raw
1 <svg version="1.1" baseProfile="tiny" 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.8 $" testname="$RCSfile: struct-dom-04-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-04-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 */
72 featureStrings[length++] = "org.w3c.svg.lang";
73 featureStrings[length++] = "org.w3c.svg.dynamic";
74 featureStrings[length++] = "org.w3c.svg.static";
75 featureStrings[length++] = "org.w3c.dom.svg";
76 featureStrings[length++] = "org.w3c.svg";
77 /*
78 featureStrings[length++] = "org.w3c.dom.svg.static";
79 featureStrings[length++] = "org.w3c.dom.svg.animation";
80 featureStrings[length++] = "org.w3c.dom.svg.dynamic";
81 featureStrings[length++] = "org.w3c.svg.all";
82 featureStrings[length++] = "org.w3c.dom.svg.all";
83 */
84 var svg_ns = "http://www.w3.org/2000/svg"
85 function domTest(evt) {
86 // Get Document
87 var target = evt.target;
88 var doc = target.ownerDocument;
89
90 // Get DOMImplementation
91 var domImpl = doc.implementation;
92
93 //
94 // Iterate through the feature strings
95 //
96 for(var i=0; i<featureStrings.length; i++){
97 var supports = domImpl.hasFeature(featureStrings[i], '2.0');
98 //
99 // if time, pretty up by putting xml to traveral in a left column and
100 // org.w3c.svg to org.w3c.dom.svg.all in a right column; add an extra
101 // parameter to addTextElemen t for x coord, and test if i < 9
102 //
103 addTextElement(featureStrings[i], supports, doc, doc.getElementById("test-body-content"), (45 + 40*i));
104 }
105 }
106
107 function addTextElement(label, value, doc, svg, y){
108 var newText = doc.createElementNS(svg_ns, 'text');
109 newText.setAttribute('font-size', '30');
110 newText.setAttribute('x', '5');
111 newText.setAttribute('y', y);
112 var textValue = label;
113 var textContent = doc.createTextNode(textValue);
114 newText.appendChild(textContent);
115 svg.appendChild(newText);
116
117 newText = doc.createElementNS(svg_ns, 'text');
118 newText.setAttribute('font-size', '30');
119 newText.setAttribute('x', '385');
120 newText.setAttribute('y', y);
121 textValue = value;
122 textContent = doc.createTextNode(textValue);
123 newText.appendChild(textContent);
124 svg.appendChild(newText);
125 }
126
127 ]]></script>
128 </g>
129 <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
130 <text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.8 $</text>
131 </g>
132 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
133 <!-- comment out this watermark once the test is approved -->
134 <!--<g id="draft-watermark">
135 <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
136 <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
137 text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
138 </g>-->
139 </svg>