[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit/javascript JavaScript.java,1.3,1.4
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-08-05 17:34:28
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv19892/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: Added support for Javascript image object Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaScript.java 2 Aug 2002 16:26:15 -0000 1.3 +++ JavaScript.java 5 Aug 2002 17:34:25 -0000 1.4 @@ -24,6 +24,7 @@ import com.meterware.httpunit.WebForm; import com.meterware.httpunit.WebResponse; import com.meterware.httpunit.WebLink; +import com.meterware.httpunit.WebImage; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; @@ -57,6 +58,7 @@ ScriptableObject.defineClass( scope, Form.class ); ScriptableObject.defineClass( scope, Control.class ); ScriptableObject.defineClass( scope, Link.class ); + ScriptableObject.defineClass( scope, Image.class ); Window w = (Window) context.newObject( scope, "Window" ); w.initialize( null, response.getScriptableObject() ); @@ -189,6 +191,7 @@ private Scriptable _forms; private Scriptable _links; + private Scriptable _images; public String getClassName() { @@ -201,6 +204,7 @@ super.initialize( this, scriptable ); initializeLinks(); initializeForms(); + initializeImages(); } @@ -209,6 +213,11 @@ } + public Scriptable jsGet_images() { + return _images; + } + + public Scriptable jsGet_links() { return _links; } @@ -219,6 +228,16 @@ } + private void initializeImages() throws PropertyException, NotAFunctionException, JavaScriptException, SAXException { + WebImage.Scriptable scriptables[] = getDelegate().getImages(); + Image[] images = new Image[ scriptables.length ]; + for (int i = 0; i < images.length; i++) { + images[ i ] = (Image) toScriptable( scriptables[ i ] ); + } + _images = Context.getCurrentContext().newArray( this, images ); + } + + private void initializeLinks() throws PropertyException, NotAFunctionException, JavaScriptException, SAXException { WebLink.Scriptable scriptables[] = getDelegate().getLinks(); Link[] links = new Link[ scriptables.length ]; @@ -252,6 +271,8 @@ return "Form"; } else if (delegate instanceof WebLink.Scriptable) { return "Link"; + } else if (delegate instanceof WebImage.Scriptable) { + return "Image"; } else { throw new IllegalArgumentException( "Unknown ScriptableObject class: " + delegate.getClass() ); } @@ -281,6 +302,14 @@ _document = (Document) parent; } + } + + + static public class Image extends HTMLElement { + + public String getClassName() { + return "Image"; + } } |