vhardy      2002/06/06 01:52:31

  Modified:    sources/org/apache/batik/bridge ScriptingEnvironment.java
  Added:       test-resources/org/apache/batik/bridge getURLException.svg
  Log:
  This test shows that we do not survive an exception in a getURL handler. Fix along 
with test
  
  Revision  Changes    Path
  1.1                  
xml-batik/test-resources/org/apache/batik/bridge/getURLException.svg
  
  Index: getURLException.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 that Batik survives exception in getURL callbacks                  -->
  <!--                                                                           -->
  <!-- @author [EMAIL PROTECTED]                                             -->
  <!-- @version $Id: getURLException.svg,v 1.1 2002/06/06 08:52:30 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="getURLTest()">
  
      <test:testResult id="testResult" result="failed" errorCode="evalCode not 
evaluated"/>
  
      <script type="text/ecmascript"><![CDATA[
  function getURLTest(){
      getURL("getURLException.svg", getURLHandler);
  }
  
  function getURLHandler(status) {
      // Add an error here
      var div = 0;
      callIDonotExist();
      alert("I should cause an error: " + 200/div);
  }
  
      ]]></script>
  
      <rect x="0" y="0" width="100%" height="100%" fill="crimson" 
onclick="getURLTest()" />
  
  </svg>
  
  
  
  1.29      +17 -5     
xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java
  
  Index: ScriptingEnvironment.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ScriptingEnvironment.java 21 May 2002 09:51:38 -0000      1.28
  +++ ScriptingEnvironment.java 6 Jun 2002 08:52:30 -0000       1.29
  @@ -47,7 +47,7 @@
    * This class contains the informations needed by the SVG scripting.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: ScriptingEnvironment.java,v 1.28 2002/05/21 09:51:38 hillion Exp $
  + * @version $Id: ScriptingEnvironment.java,v 1.29 2002/06/06 08:52:30 vhardy Exp $
    */
   public class ScriptingEnvironment extends BaseScriptingEnvironment {
   
  @@ -721,15 +721,27 @@
   
                               updateRunnableQueue.invokeLater(new Runnable() {
                                       public void run() {
  -                                        h.getURLDone(true,
  -                                                     purl.getContentType(),
  -                                                     sw.toString());
  +                                        try {
  +                                            h.getURLDone(true,
  +                                                         purl.getContentType(),
  +                                                         sw.toString());
  +                                        } catch (Exception e){
  +                                            if (userAgent != null) {
  +                                                userAgent.displayError(e);
  +                                            }
  +                                        }
                                       }
                                   });
                           } catch (Exception e) {
                               updateRunnableQueue.invokeLater(new Runnable() {
                                       public void run() {
  -                                        h.getURLDone(false, null, null);
  +                                        try {
  +                                            h.getURLDone(false, null, null);
  +                                        } catch (Exception e){
  +                                            if (userAgent != null) {
  +                                                userAgent.displayError(e);
  +                                            }
  +                                        }
                                       }
                                   });
                           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to