Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv24618/src/com/meterware/httpunit
Modified Files:
HTMLPage.java
Log Message:
Treat form, image, and link names as case-sensitive in JavaScript
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- HTMLPage.java 30 Aug 2002 18:17:48 -0000 1.8
+++ HTMLPage.java 25 Sep 2002 16:20:53 -0000 1.9
@@ -20,6 +20,7 @@
*
*******************************************************************************************************************/
import com.meterware.httpunit.scripting.ScriptableDelegate;
+import com.meterware.httpunit.scripting.NamedDelegate;
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
@@ -148,20 +149,28 @@
public class Scriptable extends ScriptableDelegate {
public Object get( String propertyName ) {
- WebForm wf = getFormWithName( propertyName );
- if (wf != null) return wf.getScriptableObject();
+ NamedDelegate delegate = getNamedItem( getForms(), propertyName );
+ if (delegate != null) return delegate;
- WebLink wl = getLinkWithName( propertyName );
- if (wl != null) return wl.getScriptableObject();
+ delegate = getNamedItem( getLinks(), propertyName );
+ if (delegate != null) return delegate;
- WebImage wi = getImageWithName( propertyName );
- if (wi != null) return wi.getScriptableObject();
+ delegate = getNamedItem( getImages(), propertyName );
+ if (delegate != null) return delegate;
if (propertyName.equalsIgnoreCase( "location" )) {
return getResponse().getScriptableObject().get( "location" );
} else {
return super.get( propertyName );
}
+ }
+
+
+ private NamedDelegate getNamedItem( NamedDelegate[] items, String name ) {
+ for (int i = 0; i < items.length; i++) {
+ if (items[i].getName().equals( name )) return items[i];
+ }
+ return null;
}
|