[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit WebClient.java,1.17,1.18 WebForm.java,1.4
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-02-11 13:54:31
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv17962/src/com/meterware/httpunit
Modified Files:
WebClient.java WebForm.java WebFrame.java
WebRequestSource.java WebResponse.java
Log Message:
Use separate namespace for each frame set
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- WebClient.java 28 Jan 2002 18:43:25 -0000 1.17
+++ WebClient.java 11 Feb 2002 13:54:28 -0000 1.18
@@ -320,7 +320,7 @@
String[] names = (String[]) _subFrames.get( targetName );
if (names == null) return;
for (int i = 0; i < names.length; i++) {
- if (!targetName.equals( names[i] )) removeSubFrames( names[i] );
+ removeSubFrames( names[i] );
_frameContents.remove( names[i] );
_subFrames.remove( names[i] );
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- WebForm.java 6 Feb 2002 18:38:13 -0000 1.45
+++ WebForm.java 11 Feb 2002 13:54:28 -0000 1.46
@@ -394,8 +394,8 @@
* Contructs a web form given the URL of its source page and the DOM extracted
* from that page.
**/
- WebForm( URL baseURL, String parentTarget, Node node, String characterSet ) {
- super( node, baseURL, NodeUtils.getNodeAttribute( node, "action" ), parentTarget );
+ WebForm( URL baseURL, String frameName, Node node, String characterSet ) {
+ super( node, baseURL, NodeUtils.getNodeAttribute( node, "action" ), frameName );
_characterSet = characterSet;
}
Index: WebFrame.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WebFrame.java 9 Nov 2001 18:35:14 -0000 1.4
+++ WebFrame.java 11 Feb 2002 13:54:28 -0000 1.5
@@ -32,18 +32,34 @@
//---------------------------------------- package methods -----------------------------------------
- WebFrame( URL baseURL, Node frameNode ) {
+ WebFrame( URL baseURL, Node frameNode, String parentFrameName ) {
_element = frameNode;
_baseURL = baseURL;
+ _name = getFrameName( parentFrameName );
}
String getName() {
- if (_name == null) {
- _name = NodeUtils.getNodeAttribute( _element, "name" );
- if (_name.length() == 0) _name = toString();
- }
return _name;
+ }
+
+
+ private String getFrameName( String parentFrameName ) {
+ final String relativeName = NodeUtils.getNodeAttribute( _element, "name" );
+ if (relativeName.length() == 0) return toString();
+ else return getNestedFrameName( parentFrameName, relativeName );
+ }
+
+
+ private static String getNestedFrameName( String parentFrameName, final String relativeName ) {
+ if (parentFrameName.equalsIgnoreCase( WebRequest.TOP_FRAME )) return relativeName;
+ return parentFrameName + ':' + relativeName;
+ }
+
+
+ static String getTargetFrameName( String sourceFrameName, final String relativeName ) {
+ if (sourceFrameName.indexOf( ':' ) < 0) return relativeName;
+ return sourceFrameName.substring( 0, sourceFrameName.lastIndexOf( ':' ) ) + ':' + relativeName;
}
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WebRequestSource.java 4 Feb 2002 22:33:55 -0000 1.6
+++ WebRequestSource.java 11 Feb 2002 13:54:28 -0000 1.7
@@ -50,11 +50,11 @@
**/
public String getTarget() {
if (getSpecifiedTarget().length() == 0) {
- return _parentTarget;
+ return _pageFrame;
} else if (getSpecifiedTarget().equalsIgnoreCase( "_self" )) {
- return _parentTarget;
+ return _pageFrame;
} else {
- return getSpecifiedTarget();
+ return WebFrame.getTargetFrameName( _pageFrame, getSpecifiedTarget() );
}
}
@@ -123,12 +123,12 @@
* Contructs a web form given the URL of its source page and the DOM extracted
* from that page.
**/
- WebRequestSource( Node node, URL baseURL, String destination, String parentTarget ) {
+ WebRequestSource( Node node, URL baseURL, String destination, String pageFrame ) {
if (node == null) throw new IllegalArgumentException( "node must not be null" );
_node = node;
_baseURL = baseURL;
_destination = destination;
- _parentTarget = parentTarget;
+ _pageFrame = pageFrame;
}
@@ -174,8 +174,8 @@
private static final String PARAM_DELIM = "&";
- /** The target in which the parent response is to be rendered. **/
- private String _parentTarget;
+ /** The name of the frame in which the response containing this request source is rendered. **/
+ private String _pageFrame;
/** The URL of the page containing this entity. **/
private URL _baseURL;
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- WebResponse.java 1 Feb 2002 14:31:43 -0000 1.59
+++ WebResponse.java 11 Feb 2002 13:54:28 -0000 1.60
@@ -128,7 +128,7 @@
* Returns the target of the page.
**/
public String getTarget() {
- return _target;
+ return _frameName;
}
@@ -423,12 +423,12 @@
/**
* Constructs a response object.
- * @param target the name of the frame to hold the response
+ * @param frameName the name of the frame to hold the response
* @param url the url from which the response was received
**/
- protected WebResponse( String target, URL url ) {
+ protected WebResponse( String frameName, URL url ) {
_url = url;
- _target = target;
+ _frameName = frameName;
}
@@ -447,7 +447,7 @@
if (splitIndex < 0) splitIndex = 0;
try {
_refreshDelay = Integer.parseInt( contentTypeHeader.substring( 0, splitIndex ) );
- _refreshRequest = new GetMethodWebRequest( _url, getRefreshURL( contentTypeHeader.substring( splitIndex+1 ) ), _target );
+ _refreshRequest = new GetMethodWebRequest( _url, getRefreshURL( contentTypeHeader.substring( splitIndex+1 ) ), _frameName );
} catch (NumberFormatException e) {
System.out.println( "Unable to interpret refresh tag: \"" + contentTypeHeader + '"' );
}
@@ -548,7 +548,7 @@
private URL _url;
- private String _target;
+ private String _frameName;
protected void loadResponseText() throws IOException {
@@ -784,7 +784,7 @@
NodeList nl = NodeUtils.getElementsByTagName( getReceivedPage().getOriginalDOM(), frameTagName );
for (int i = 0; i < nl.getLength(); i++) {
Node child = nl.item(i);
- list.addElement( new WebFrame( getReceivedPage().getBaseURL(), child ) );
+ list.addElement( new WebFrame( getReceivedPage().getBaseURL(), child, _frameName ) );
}
}
@@ -793,7 +793,7 @@
if (_page == null) {
try {
if (!isHTML()) throw new NotHTMLException( getContentType() );
- _page = new ReceivedPage( _url, _target, getText(), getCharacterSet() );
+ _page = new ReceivedPage( _url, _frameName, getText(), getCharacterSet() );
} catch (IOException e) {
throw new SAXException( e );
}
|