Debian Codegraph @

samples/tests/spec/scripting/security3.svg

raw
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
3 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
5 <!--
6
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21
22 -->
23 <!-- ========================================================================= -->
24 <!-- This test checks that scripts can properly invoke the Window object -->
25 <!-- methods but that they cannot access data through getURL. -->
26 <!-- -->
27 <!-- @author [email protected] -->
28 <!-- @version $Id$ -->
29 <!-- ========================================================================= -->
30 <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
31
32 <svg xmlns="http://www.w3.org/2000/svg"
33 xmlns:xlink="http://www.w3.org/1999/xlink"
34 width="450" height="500" viewBox="0 0 450 500"
35 onload="windowTest()">
36
37 <text x="225" y="30" class="title">
38 ECMA Script Secure Access to the Window Object
39 </text>
40
41 <style type="text/css"><![CDATA[
42 .cellLabel {
43 fill: white;
44 stroke: black;
45 shape-rendering: crispEdges;
46 }
47
48 .cellStatus {
49 stroke: black;
50 fill: white;
51 shape-rendering: crispEdges;
52 }
53
54 .label {
55 font-size: 12;
56 font-family: sans-serif;
57 fill: black;
58 text-anchor: start;
59 }
60
61 .passedTest {
62 fill: rgb(0,200,50);
63 stroke: none;
64 shape-rendering: crispEdges;
65 }
66
67 .failedTest {
68 fill: crimson;
69 stroke: none;
70 shape-rendering: crispEdges;
71 }
72
73 #table {
74 stroke: black;
75 }
76
77 .untested {
78 fill: gray;
79 stroke: none;
80 shapeRendering: crispEdges;
81 }
82
83 .tableCell {
84 fill: none;
85 stroke: black;
86 shapeRendering: crispEdges;
87 }
88 ]]>
89 </style>
90
91 <script type="text/ecmascript" ><![CDATA[
92
93 function windowTest() {
94 evalTest();
95 setIntervalTest();
96 setTimeoutTest();
97 getURLTest();
98 alertTest();
99 confirmTest();
100 promptTest();
101 }
102
103 function evalTest() {
104 var t = document.getElementById("eval");
105 try {
106 eval("dummyGetURL()");
107 t.setAttributeNS(null, "class", "passedTest");
108 } catch (e) {
109 t.setAttributeNS(null, "class", "failedTest");
110 }
111 }
112
113 function dummyGetURL(){
114 alert('dummyGetURL');
115 getURL('security3Include.svg', dummyFunction);
116 }
117
118 function dummyFunction() {
119 System.out.println("===>> dummyFunction called");
120 }
121
122 function setIntervalTest(){
123 var t = document.getElementById("setInterval");
124 var intervalId;
125
126 try {
127 intervalId = setInterval(dummyFunction, 10000);
128 t.setAttributeNS(null, "class", "passedTest");
129 } catch (e) {
130 t.setAttributeNS(null, "class", "failedTest");
131 return; // Cannot test clearInterval
132 }
133
134 t = document.getElementById("clearInterval");
135
136 try {
137 window.clearInterval(intervalId);
138 t.setAttributeNS(null, "class", "passedTest");
139 } catch (e) {
140 System.out.println("Got exception : " + e);
141 t.setAttributeNS(null, "class", "failedTest");
142 }
143 }
144
145 function setTimeoutTest(){
146 var t = document.getElementById("setTimeout");
147 var timeoutId = null;
148
149 try {
150 timeoutId = window.setTimeout(dummyFunction, 10000);
151 t.setAttributeNS(null, "class", "passedTest");
152 } catch (e) {
153 t.setAttributeNS(null, "class", "failedTest");
154 return; // Cannot test clearTimeout
155 }
156
157 t = document.getElementById("clearTimeout");
158
159 try {
160 window.clearTimeout(timeoutId);
161 t.setAttributeNS(null, "class", "passedTest");
162 } catch (e) {
163 t.setAttributeNS(null, "class", "failedTest");
164 }
165 }
166
167
168 function getURLTest(){
169 var t = document.getElementById("getURL");
170 try {
171 getURL("security3Include.svg", processGetURL);
172 } catch (e) {
173 t.setAttributeNS(null, "class", "failedTest");
174 return;
175 }
176 }
177
178 function processGetURL(status){
179 var t = document.getElementById("getURL");
180 alert("status.success : " + status.success);
181 if (status.success == false) {
182 t.setAttributeNS(null, "class", "failedTest");
183 return;
184 }
185
186 t.setAttributeNS(null, "class", "passedTest");
187
188 t = document.getElementById("parseXML");
189 try {
190 var root = parseXML(status.content, document);
191 if (root == null){
192 t.setAttributeNS(null, "class", "failedTest");
193 } else {
194 t.setAttributeNS(null, "class", "passedTest");
195 }
196 } catch (e) {
197 t.setAttributeNS(null, "class", "failedTest");
198 }
199
200 }
201
202 function dummyProcessGetURL(status){
203 }
204
205 function alertTest(){
206 var t = document.getElementById("alert");
207 try {
208 alert("alert() test");
209 t.setAttributeNS(null, "class", "passedTest");
210 } catch (e) {
211 t.setAttributeNS(null, "class", "failedTest");
212 }
213 }
214
215 function confirmTest(){
216 var t = document.getElementById("confirm");
217 try {
218 confirm("confirm() test");
219 t.setAttributeNS(null, "class", "passedTest");
220 } catch (e) {
221 t.setAttributeNS(null, "class", "failedTest");
222 }
223 }
224
225 function promptTest(){
226 var t = document.getElementById("prompt");
227 try {
228 prompt("prompt() test");
229 t.setAttributeNS(null, "class", "passedTest");
230 } catch (e) {
231 t.setAttributeNS(null, "class", "failedTest");
232 }
233 }
234
235 ]]></script>
236
237
238 <g id="testTable" transform="translate(125, 150)">
239
240 <g id="setIntervalTest">
241 <rect class="cellLabel" width="200" height="20" />
242 <rect class="cellStatus" x="200" width="20" height="20" />
243 <rect id="setInterval" class="untested" x="203" y="3" width="14" height="14" />
244 <text x="5" y="15" class="label">setInterval</text>
245 </g>
246
247 <g id="clearIntervalTest" transform="translate(0, 20)">
248 <rect class="cellLabel" width="200" height="20" />
249 <rect class="cellStatus" x="200" width="20" height="20" />
250 <rect id="clearInterval" class="untested" x="203" y="3" width="14" height="14" />
251 <text x="5" y="15" class="label">clearInterval</text>
252 </g>
253
254 <g id="setTimeoutTest" transform="translate(0, 40)">
255 <rect class="cellLabel" width="200" height="20" />
256 <rect class="cellStatus" x="200" width="20" height="20" />
257 <rect id="setTimeout" class="untested" x="203" y="3" width="14" height="14" />
258 <text x="5" y="15" class="label">setTimeout</text>
259 </g>
260
261 <g id="clearTimeoutTest" transform="translate(0, 60)">
262 <rect class="cellLabel" width="200" height="20" />
263 <rect class="cellStatus" x="200" width="20" height="20" />
264 <rect id="clearTimeout" class="untested" x="203" y="3" width="14" height="14" />
265 <text x="5" y="15" class="label">clearTimeout</text>
266 </g>
267
268 <g id="parseXMLTest" transform="translate(0, 80)">
269 <rect class="cellLabel" width="200" height="20" />
270 <rect class="cellStatus" x="200" width="20" height="20" />
271 <rect id="parseXML" class="untested" x="203" y="3" width="14" height="14" />
272 <text x="5" y="15" class="label">parseXML</text>
273 </g>
274
275 <g id="getURLTest" transform="translate(0, 100)">
276 <rect class="cellLabel" width="200" height="20" />
277 <rect class="cellStatus" x="200" width="20" height="20" />
278 <rect id="getURL" class="untested" x="203" y="3" width="14" height="14" />
279 <text x="5" y="15" class="label">getURL</text>
280 </g>
281
282 <g id="alertTest" transform="translate(0, 120)">
283 <rect class="cellLabel" width="200" height="20" />
284 <rect class="cellStatus" x="200" width="20" height="20" />
285 <rect id="alert" class="untested" x="203" y="3" width="14" height="14" />
286 <text x="5" y="15" class="label">alert</text>
287 </g>
288
289 <g id="confirmTest" transform="translate(0, 140)">
290 <rect class="cellLabel" width="200" height="20" />
291 <rect class="cellStatus" x="200" width="20" height="20" />
292 <rect id="confirm" class="untested" x="203" y="3" width="14" height="14" />
293 <text x="5" y="15" class="label">confirm</text>
294 </g>
295
296 <g id="promptTest" transform="translate(0, 160)">
297 <rect class="cellLabel" width="200" height="20" />
298 <rect class="cellStatus" x="200" width="20" height="20" />
299 <rect id="prompt" class="untested" x="203" y="3" width="14" height="14" />
300 <text x="5" y="15" class="label">prompt</text>
301 </g>
302
303 <g id="evalTest" transform="translate(0, 160)">
304 <rect class="cellLabel" width="200" height="20" />
305 <rect class="cellStatus" x="200" width="20" height="20" />
306 <rect id="eval" class="untested" x="203" y="3" width="14" height="14" />
307 <text x="5" y="15" class="label">eval</text>
308 </g>
309
310
311 </g>
312
313
314 <script type="text/ecmascript"><![CDATA[
315 function onDone() {
316 if (!(regardTestInstance == null)) {
317 regardTestInstance.scriptDone();
318 } else {
319 alert("This button only works when run in the regard framework");
320 }
321 }
322 ]]></script>
323 <g id="done" transform="translate(195, 468)" cursor="pointer" onclick="onDone()">
324 <rect rx="5" ry="5" width="60" height="25" fill="#eeeeee" stroke="black" />
325 <text x="30" y="18" font-size="14" font-weight="bold" text-anchor="middle">Done</text>
326 </g>
327
328 </svg>