[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit/javascript JavaScript.java,1.42,1.43
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-12-30 21:47:29
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv25347/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added document.getElementByID support
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- JavaScript.java 13 Dec 2002 12:57:11 -0000 1.42
+++ JavaScript.java 30 Dec 2002 21:46:56 -0000 1.43
@@ -96,6 +96,7 @@
ScriptableObject.defineClass( scope, Options.class );
ScriptableObject.defineClass( scope, Option.class );
ScriptableObject.defineClass( scope, ElementArray.class );
+ ScriptableObject.defineClass( scope, HTMLElement.class );
}
@@ -276,8 +277,10 @@
/**
* Converts a scriptable delegate obtained from a subobject into the appropriate Rhino-compatible Scriptable.
**/
- final Scriptable toScriptable( ScriptableDelegate delegate ) {
- if (delegate.getScriptEngine() instanceof Scriptable) {
+ final Object toScriptable( ScriptableDelegate delegate ) {
+ if (delegate == null) {
+ return NOT_FOUND;
+ } else if (delegate.getScriptEngine() instanceof Scriptable) {
return (Scriptable) delegate.getScriptEngine();
} else {
try {
@@ -302,6 +305,7 @@
if (delegate instanceof SelectionOptions) return "Options";
if (delegate instanceof SelectionOption) return "Option";
if (delegate instanceof Input) return "Control";
+ if (delegate instanceof DocumentElement) return "HTMLElement";
throw new IllegalArgumentException( "Unknown ScriptableDelegate class: " + delegate.getClass() );
}
@@ -488,6 +492,11 @@
}
+ public Object jsFunction_getElementWithID( String id ) {
+ return toScriptable( getDelegate().getElementWithID( id ) );
+ }
+
+
public Object jsGet_location() {
return _parent == null ? NOT_FOUND : getWindow().jsGet_location();
}
@@ -817,9 +826,14 @@
}
- abstract static public class HTMLElement extends JavaScriptEngine {
+ static public class HTMLElement extends JavaScriptEngine {
private Document _document;
+
+
+ public String getClassName() {
+ return "HTMLElement";
+ }
public Document jsGet_document() {
|