vhardy 2002/06/06 01:21:22 Modified: test-resources/org/apache/batik/test regard.xml Added: test-resources/org/apache/batik/script/rhino eval.svg unitTesting.xml test-sources/org/apache/batik/script/rhino ScriptSelfTest.java Log: Added test showing bug on eval. Fix is following Revision Changes Path 1.1 xml-batik/test-resources/org/apache/batik/script/rhino/eval.svg Index: eval.svg =================================================================== <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- ========================================================================= --> <!-- Copyright (C) The Apache Software Foundation. All rights reserved. --> <!-- --> <!-- This software is published under the terms of the Apache Software License --> <!-- version 1.1, a copy of which has been included with this distribution in --> <!-- the LICENSE file. --> <!-- ========================================================================= --> <!-- ========================================================================= --> <!-- Checks the operation of the Rhino eval function. --> <!-- --> <!-- @author [EMAIL PROTECTED] --> <!-- @version $Id: eval.svg,v 1.1 2002/06/06 08:21:22 vhardy Exp $ --> <!-- ========================================================================= --> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:test="http://xml.apache.org/batik/test" width="450" height="500" viewBox="0 0 450 500" onload="checkEval()"> <test:testResult id="testResult" result="failed" errorCode="evalCode not evaluated"/> <script type="text/ecmascript"><![CDATA[ function checkEval(){ var e = document.getElementById('target'); var ecmaCode = e.getAttributeNS("http://some.company.com/", "eval"); alert("About to evaluate: " + ecmaCode); eval(ecmaCode); } function callMe() { alert("in callMe()"); var e = document.getElementById("testResult"); e.setAttributeNS(null, "result", "passed"); } ]]></script> <rect width="100%" height="100%" id="target" xmlns:data="http://some.company.com/" data:eval="callMe()" onclick="checkEval()"/> </svg> 1.1 xml-batik/test-resources/org/apache/batik/script/rhino/unitTesting.xml Index: unitTesting.xml =================================================================== <!-- ========================================================================= --> <!-- Copyright (C) The Apache Software Foundation. All rights reserved. --> <!-- --> <!-- This software is published under the terms of the Apache Software License --> <!-- version 1.1, a copy of which has been included with this distribution in --> <!-- the LICENSE file. --> <!-- ========================================================================= --> <!-- ========================================================================= --> <!-- @author [EMAIL PROTECTED] --> <!-- @version $Id: unitTesting.xml,v 1.1 2002/06/06 08:21:22 vhardy Exp $ --> <!-- ========================================================================= --> <testSuite id="script.rhino.unitTesting" name="org.apache.batik.script.rhino package - Unit Testing"> <!-- ================================================================ --> <!-- Script Permissions check --> <!-- ================================================================ --> <testGroup id="security" name="Script Security" class="org.apache.batik.script.rhino.ScriptSelfTest"> <test id="script/rhino/eval"> <property name="Secure" class="java.lang.Boolean" value="true" /> </test> </testGroup> </testSuite> 1.26 +2 -2 xml-batik/test-resources/org/apache/batik/test/regard.xml Index: regard.xml =================================================================== RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/regard.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- regard.xml 3 May 2002 12:28:53 -0000 1.25 +++ regard.xml 6 Jun 2002 08:21:22 -0000 1.26 @@ -11,7 +11,7 @@ <!-- regression testing. --> <!-- --> <!-- @author [EMAIL PROTECTED] --> -<!-- @version $Id: regard.xml,v 1.25 2002/05/03 12:28:53 vhardy Exp $ --> +<!-- @version $Id: regard.xml,v 1.26 2002/06/06 08:21:22 vhardy Exp $ --> <!-- ========================================================================= --> <testRun id="regard" name="Batik Standard Regression Test Run"> <testReportProcessor class="org.apache.batik.test.xml.XMLTestReportProcessor" > @@ -60,8 +60,8 @@ <testSuite href="file:test-resources/org/apache/batik/dom/svg/unitTesting.xml" /> <testSuite href="file:test-resources/org/apache/batik/gvt/unitTesting.xml" /> <testSuite href="file:test-resources/org/apache/batik/parser/unitTesting.xml" /> + <testSuite href="file:test-resources/org/apache/batik/script/rhino/unitTesting.xml" /> <testSuite href="file:test-resources/org/apache/batik/transcoder/image/unitTesting.xml" /> - <testSuite href="file:test-resources/org/apache/batik/css/engine/value/unitTesting.xml" /> 1.1 xml-batik/test-sources/org/apache/batik/script/rhino/ScriptSelfTest.java Index: ScriptSelfTest.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.script.rhino; import org.apache.batik.test.*; import org.apache.batik.util.ApplicationSecurityEnforcer; import org.apache.batik.util.ParsedURL; import org.apache.batik.test.svg.SelfContainedSVGOnLoadTest; import org.apache.batik.bridge.UserAgent; import org.apache.batik.bridge.UserAgentAdapter; import org.apache.batik.bridge.ScriptSecurity; import org.apache.batik.bridge.DefaultScriptSecurity; import org.apache.batik.bridge.NoLoadScriptSecurity; import org.apache.batik.bridge.RelaxedScriptSecurity; /** * Helper class to simplify writing the unitTesting.xml file for * scripting. The "id" for the test needs to be the path of the * selft contained SVG test, starting from: * <xml-batik-dir>/test-resources/org/apache/batik/ * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Hardy</a> * @version $Id: ScriptSelfTest.java,v 1.1 2002/06/06 08:21:22 vhardy Exp $ */ public class ScriptSelfTest extends SelfContainedSVGOnLoadTest { boolean secure = true; boolean constrain = true; String scripts = "text/ecmascript, application/java-archive"; TestUserAgent userAgent = new TestUserAgent(); public void setId(String id){ super.setId(id); svgURL = resolveURL("test-resources/org/apache/batik/" + id + ".svg"); } public void setSecure(Boolean secure){ this.secure = secure.booleanValue(); } public Boolean getSecure(){ return new Boolean(this.secure); } public void setConstrain(Boolean constrain){ this.constrain = constrain.booleanValue(); } public Boolean getConstrain(){ return new Boolean(this.constrain); } public void setScripts(String scripts){ this.scripts = scripts; } public String getScripts(){ return scripts; } public TestReport runImpl() throws Exception{ ApplicationSecurityEnforcer ase = new ApplicationSecurityEnforcer(this.getClass(), "org/apache/batik/apps/svgbrowser/resources/svgbrowser.policy", "dummy.jar"); if (secure) { ase.enforceSecurity(true); } try { return super.runImpl(); } finally { ase.enforceSecurity(false); } } protected UserAgent buildUserAgent(){ return userAgent; } class TestUserAgent extends UserAgentAdapter { public ScriptSecurity getScriptSecurity(String scriptType, ParsedURL scriptPURL, ParsedURL docPURL){ if (scripts.indexOf(scriptType) == -1){ return new NoLoadScriptSecurity(scriptType); } else { if (constrain){ return new DefaultScriptSecurity (scriptType, scriptPURL, docPURL); } else { return new RelaxedScriptSecurity (scriptType, scriptPURL, docPURL); } } } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]