Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv27406/src/com/meterware/httpunit
Modified Files:
HTMLPage.java WebLink.java
Log Message:
add document.links and link.onMouseOver support
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HTMLPage.java 1 Aug 2002 14:58:59 -0000 1.2
+++ HTMLPage.java 2 Aug 2002 16:26:15 -0000 1.3
@@ -132,13 +132,27 @@
public Object get( String propertyName ) {
WebForm wf = getFormWithName( propertyName );
- if (wf == null) return super.get( propertyName );
- return wf.getScriptableObject();
+ if (wf != null) return wf.getScriptableObject();
+
+ WebLink wl = getLinkWithName( propertyName );
+ if (wl != null) return wl.getScriptableObject();
+
+ return super.get( propertyName );
}
public String getTitle() throws SAXException {
return HTMLPage.this.getTitle();
+ }
+
+
+ public WebLink.Scriptable[] getLinks() {
+ WebLink[] links = HTMLPage.this.getLinks();
+ WebLink.Scriptable[] result = new WebLink.Scriptable[ links.length ];
+ for (int i = 0; i < links.length; i++) {
+ result[i] = links[i].getScriptableObject();
+ }
+ return result;
}
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- WebLink.java 1 Aug 2002 14:58:59 -0000 1.20
+++ WebLink.java 2 Aug 2002 16:26:15 -0000 1.21
@@ -43,6 +43,9 @@
**/
public class WebLink extends WebRequestSource {
+ private Scriptable _scriptable;
+
+
/**
* Returns the URL referenced by this link. This may be a relative URL.
**/
@@ -72,13 +75,31 @@
/**
- * Submits a request as though the user had clicked on this link.
+ * Submits a request as though the user had clicked on this link. Will also fire the 'onClick' event if defined.
**/
public void click() throws IOException, SAXException {
submitRequest();
}
+ /**
+ * Simulates moving the mouse over the link. Will fire the 'onMouseOver' event if defined.
+ **/
+ public void mouseOver() {
+ String event = NodeUtils.getNodeAttribute( getNode(), "onmouseover" );
+ if (event.length() > 0) getScriptableObject().doEvent( event );
+ }
+
+
+ /**
+ * Returns an object which provides scripting access to this link.
+ **/
+ public Scriptable getScriptableObject() {
+ if (_scriptable == null) _scriptable = new Scriptable();
+ return _scriptable;
+ }
+
+
//----------------------------------------- WebRequestSource methods ---------------------------------------------------
@@ -206,7 +227,11 @@
}
- //--------------------------------------------------- package members --------------------------------------------------
+ public class Scriptable extends ScriptableObject {
+ }
+
+
+//--------------------------------------------------- package members --------------------------------------------------
/**
|