[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit FormControl.java,1.42,1.43 HTMLElement.ja
Brought to you by:
russgold
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv17038/src/com/meterware/httpunit
Modified Files:
FormControl.java HTMLElement.java HTMLElementBase.java
HTMLElementScriptable.java TableCell.java
WebRequestSource.java
Log Message:
Chris Hane: Added support for generic HTMLElement properties
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- FormControl.java 24 Jun 2003 22:40:36 -0000 1.42
+++ FormControl.java 19 Sep 2003 18:53:43 -0000 1.43
@@ -80,6 +80,8 @@
_disabled = NodeUtils.isNodeAttributePresent( node, "disabled" );
_onChangeEvent = NodeUtils.getNodeAttribute( node, "onchange" );
_onClickEvent = NodeUtils.getNodeAttribute( node, "onclick" );
+
+ supportAttribute( "tabindex" );
}
@@ -756,6 +758,7 @@
class TextFieldFormControl extends TextFormControl {
public TextFieldFormControl( WebForm form, Node node ) {
super( form, node, NodeUtils.getNodeAttribute( node, "value" ) );
+ supportAttribute( "maxlength" );
}
}
Index: HTMLElement.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElement.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HTMLElement.java 27 Aug 2003 02:16:06 -0000 1.3
+++ HTMLElement.java 19 Sep 2003 18:53:43 -0000 1.4
@@ -62,6 +62,12 @@
/**
+ * Returns true if this element may have an attribute with the specified name.
+ */
+ boolean isSupportedAttribute( String name );
+
+
+ /**
* Returns the delegate which supports scripting this element.
*/
ScriptableDelegate getScriptableDelegate();
Index: HTMLElementBase.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElementBase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HTMLElementBase.java 27 Aug 2003 02:16:06 -0000 1.4
+++ HTMLElementBase.java 19 Sep 2003 18:53:43 -0000 1.5
@@ -22,6 +22,9 @@
import org.w3c.dom.Node;
import com.meterware.httpunit.scripting.ScriptableDelegate;
+import java.util.List;
+import java.util.ArrayList;
+
/**
*
@@ -33,7 +36,7 @@
private Node _node;
private ScriptableDelegate _scriptable;
-
+ private List _supportedAttributes = new ArrayList();
public String getID() {
@@ -70,6 +73,10 @@
protected HTMLElementBase( Node node ) {
_node = node;
+ supportAttribute( "id" );
+ supportAttribute( "class" );
+ supportAttribute( "title" );
+ supportAttribute( "name" );
}
@@ -78,6 +85,11 @@
}
+ public boolean isSupportedAttribute( String name ) {
+ return _supportedAttributes.contains( name );
+ }
+
+
protected String getAttribute( final String name, String defaultValue ) {
return NodeUtils.getNodeAttribute( getNode(), name, defaultValue );
}
@@ -85,6 +97,11 @@
protected Node getNode() {
return _node;
+ }
+
+
+ protected void supportAttribute( String name ) {
+ _supportedAttributes.add( name );
}
Index: HTMLElementScriptable.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLElementScriptable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTMLElementScriptable.java 30 Dec 2002 21:46:54 -0000 1.1
+++ HTMLElementScriptable.java 19 Sep 2003 18:53:43 -0000 1.2
@@ -34,6 +34,8 @@
public Object get( String propertyName ) {
if (propertyName.equalsIgnoreCase( "title" )) {
return _element.getTitle();
+ } else if (_element.isSupportedAttribute( propertyName )) {
+ return _element.getAttribute( propertyName );
} else {
return super.get( propertyName );
}
Index: TableCell.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TableCell.java 27 Aug 2003 02:16:06 -0000 1.14
+++ TableCell.java 19 Sep 2003 18:53:43 -0000 1.15
@@ -116,6 +116,14 @@
}
+ /**
+ * Returns true if this element may have an attribute with the specified name.
+ */
+ public boolean isSupportedAttribute( String name ) {
+ return false;
+ }
+
+
public boolean equals( Object obj ) {
return obj instanceof TableCell && equals( (TableCell) obj );
}
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- WebRequestSource.java 27 Aug 2003 02:16:06 -0000 1.32
+++ WebRequestSource.java 19 Sep 2003 18:53:43 -0000 1.33
@@ -270,6 +270,11 @@
}
+ public boolean isSupportedAttribute( String name ) {
+ return false;
+ }
+
+
String getAttribute( final String name, String defaultValue ) {
return NodeUtils.getNodeAttribute( _node, name, defaultValue );
}
|