Our JavaScripts use lots of non-standard attributes on the form fields for input validation among other things. HttpUnit does not support arbitrary attributes, but I looked into adding this. In FormControl.java I modfied the get method of FormControlScriptable as such:
public Object get( String propertyName ) {
if (propertyName.equalsIgnoreCase( "name" )) {
return FormControl.this.getName();
} else {
Object valueOfSuper = super.get( propertyName );
if(valueOfSuper == null) { // If not found by super
Node attribute = getNode().getAttributes().getNamedItem( propertyName );
if(attribute != null)
return attribute.getNodeValue();
}
return valueOfSuper;
}
}
(Similarily the setNodeValue could be used).
I don't know if this is something that other might find useful also, so that you (Russel) would like to add it to the CVS. The test cases run fine with this modification (I have not tried adding the set feature). Although I am aware that this modifies the underlying DOM (which JavaScripts normally does not), and I don't know the "HttpUnit policy" about that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Our JavaScripts use lots of non-standard attributes on the form fields for input validation among other things. HttpUnit does not support arbitrary attributes, but I looked into adding this. In FormControl.java I modfied the get method of FormControlScriptable as such:
public Object get( String propertyName ) {
if (propertyName.equalsIgnoreCase( "name" )) {
return FormControl.this.getName();
} else {
Object valueOfSuper = super.get( propertyName );
if(valueOfSuper == null) { // If not found by super
Node attribute = getNode().getAttributes().getNamedItem( propertyName );
if(attribute != null)
return attribute.getNodeValue();
}
return valueOfSuper;
}
}
(Similarily the setNodeValue could be used).
I don't know if this is something that other might find useful also, so that you (Russel) would like to add it to the CVS. The test cases run fine with this modification (I have not tried adding the set feature). Although I am aware that this modifies the underlying DOM (which JavaScripts normally does not), and I don't know the "HttpUnit policy" about that.