01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.bridge;
20:
21: import org.apache.batik.test.*;
22:
23: /**
24: * Checks that ECMA Scripts which should be loaded are indeed
25: * loaded.
26: *
27: * @author <a href="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
28: * @version $Id: EcmaLoadTest.java 482118 2006-12-04 09:52:54Z dvholten $
29: */
30: public class EcmaLoadTest extends DefaultTestSuite {
31: public EcmaLoadTest() {
32: String scripts = "text/ecmascript";
33: String[] scriptSource = { "ecmaCheckLoadAny",
34: "ecmaCheckLoadSameAsDocument", "ecmaCheckLoadEmbed",
35: "ecmaCheckLoadEmbedAttr", };
36: boolean[] secure = { true, false };
37: String[][] scriptOrigin = { { "any" }, { "any", "document" },
38: { "any", "document", "embeded" },
39: { "any", "document", "embeded" }, };
40:
41: //
42: // <!> Need to make restricted {true/false}
43: //
44:
45: //
46: // An ecma script can be loaded if ECMA is listed
47: // as an allowed script _and_ the loaded script
48: // has an origin allowed by the scriptOrigin setting.
49: // All other security settings should not have an
50: // influence on whether or not the script can be loaded.
51: //
52: for (int i = 0; i < scriptSource.length; i++) {
53: for (int j = 0; j < scriptOrigin[i].length; j++) {
54: for (int k = 0; k < secure.length; k++) {
55: ScriptSelfTest t = buildTest(scripts,
56: scriptSource[i], scriptOrigin[i][j],
57: secure[k]);
58: addTest(t);
59: }
60: }
61: }
62: }
63:
64: ScriptSelfTest buildTest(String scripts, String id, String origin,
65: boolean secure) {
66: ScriptSelfTest t = new ScriptSelfTest();
67: String desc = "(scripts=" + scripts + ")(scriptOrigin="
68: + origin + ")(secure=" + secure + ')';
69:
70: t.setId(id + desc);
71: t.setScriptOrigin(origin);
72: t.setSecure(secure);
73: t.setScripts(scripts);
74:
75: return t;
76: }
77:
78: }
|