httpunit-commit Mailing List for httpunit (Page 42)
Brought to you by:
russgold
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(31) |
Oct
(39) |
Nov
(18) |
Dec
(6) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(8) |
Feb
(5) |
Mar
(8) |
Apr
(25) |
May
(20) |
Jun
(23) |
Jul
(28) |
Aug
(10) |
Sep
(3) |
Oct
(32) |
Nov
(61) |
Dec
(24) |
| 2002 |
Jan
(50) |
Feb
(34) |
Mar
(35) |
Apr
(3) |
May
(25) |
Jun
(25) |
Jul
(30) |
Aug
(146) |
Sep
(49) |
Oct
(156) |
Nov
(121) |
Dec
(54) |
| 2003 |
Jan
(12) |
Feb
(79) |
Mar
(88) |
Apr
(26) |
May
(67) |
Jun
(29) |
Jul
(8) |
Aug
(16) |
Sep
(20) |
Oct
(17) |
Nov
|
Dec
(5) |
| 2004 |
Jan
|
Feb
(40) |
Mar
(30) |
Apr
(5) |
May
|
Jun
(83) |
Jul
(34) |
Aug
(20) |
Sep
(44) |
Oct
(46) |
Nov
|
Dec
(14) |
| 2005 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(1) |
| 2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(8) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
(36) |
May
(38) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
|
Nov
(18) |
Dec
(4) |
| 2009 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(35) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
(9) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
(18) |
Nov
(1) |
Dec
|
|
From: Russell G. <rus...@us...> - 2002-11-22 17:19:38
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv22673/src/com/meterware/httpunit
Modified Files:
AppletStubImpl.java WebApplet.java
Log Message:
Added support for applet parameters and archives
Index: AppletStubImpl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/AppletStubImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AppletStubImpl.java 15 Nov 2002 00:10:22 -0000 1.1
+++ AppletStubImpl.java 22 Nov 2002 17:19:35 -0000 1.2
@@ -94,7 +94,7 @@
* or <tt>null</tt> if not set.
*/
public String getParameter( String name ) {
- return null;
+ return _webApplet.getParameter( name );
}
Index: WebApplet.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebApplet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebApplet.java 15 Nov 2002 00:07:33 -0000 1.2
+++ WebApplet.java 22 Nov 2002 17:19:35 -0000 1.3
@@ -24,8 +24,15 @@
import java.net.URLClassLoader;
import java.applet.Applet;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.List;
import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -40,9 +47,12 @@
private WebResponse _response;
private Node _node;
private String _baseTarget;
+
private URL _codeBase;
private String _className;
private Applet _applet;
+ private HashMap _parameters;
+ private String[] _parameterNames;
final private String CLASS_EXTENSION = ".class";
@@ -57,14 +67,20 @@
/**
* Returns the URL of the codebase used to find the applet classes
*/
- public URL getCodeBase() throws MalformedURLException {
+ public URL getCodeBaseURL() throws MalformedURLException {
if (_codeBase == null) {
- _codeBase = new URL( _response.getURL(), getAttribute( "codebase", "/" ) );
+ _codeBase = new URL( _response.getURL(), getCodeBase() );
}
return _codeBase;
}
+ private String getCodeBase() {
+ final String codeBaseAttribute = getAttribute( "codebase", "/" );
+ return codeBaseAttribute.endsWith( "/" ) ? codeBaseAttribute : (codeBaseAttribute + "/");
+ }
+
+
/**
* Returns the name of the applet main class.
*/
@@ -114,9 +130,60 @@
}
+ /**
+ * Returns the archive specification.
+ */
+ public String getArchiveSpecification() {
+ String specification = getParameter( "archive" );
+ if (specification == null) specification = getAttribute( "archive" );
+ return specification;
+ }
+
+
+ List getArchiveList() throws MalformedURLException {
+ ArrayList al = new ArrayList();
+ StringTokenizer st = new StringTokenizer( getArchiveSpecification(), "," );
+ while (st.hasMoreTokens()) al.add( new URL( _response.getURL(), st.nextToken() ) );
+ return al;
+ }
+
+
+ /**
+ * Returns an array containing the names of the parameters defined for the applet.
+ */
+ public String[] getParameterNames() {
+ if (_parameterNames == null) {
+ ArrayList al = new ArrayList( getParameterMap().keySet() );
+ _parameterNames = (String[]) al.toArray( new String[ al.size() ] );
+ }
+ return _parameterNames;
+ }
+
+
+ /**
+ * Returns the value of the specified applet parameter, or null if not defined.
+ */
+ public String getParameter( String name ) {
+ return (String) getParameterMap().get( name );
+ }
+
+
+ private Map getParameterMap() {
+ if (_parameters == null) {
+ _parameters = new HashMap();
+ NodeList nl = ((Element) _node).getElementsByTagName( "param" );
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+ _parameters.put( NodeUtils.getNodeAttribute( n, "name", "" ), NodeUtils.getNodeAttribute( n, "value", "" ) );
+ }
+ }
+ return _parameters;
+ }
+
+
public Applet getApplet() throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
if (_applet == null) {
- ClassLoader cl = new URLClassLoader( getClassPath() );
+ ClassLoader cl = new URLClassLoader( getClassPath(), null );
Object o = cl.loadClass( getMainClassName() ).newInstance();
if (!(o instanceof Applet)) throw new RuntimeException( getMainClassName() + " is not an Applet" );
_applet = (Applet) o;
@@ -127,7 +194,9 @@
private URL[] getClassPath() throws MalformedURLException {
- return new URL[] { getCodeBase() };
+ List classPath = getArchiveList();
+ classPath.add( getCodeBaseURL() );
+ return (URL[]) classPath.toArray( new URL[ classPath.size() ] );
}
@@ -156,6 +225,5 @@
} catch (SAXException e) {
}
}
-
}
|
|
From: Russell G. <rus...@us...> - 2002-11-22 17:19:37
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv22673/doc
Modified Files:
release_notes.txt
Log Message:
Added support for applet parameters and archives
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.222
retrieving revision 1.223
diff -u -r1.222 -r1.223
--- release_notes.txt 21 Nov 2002 22:32:04 -0000 1.222
+++ release_notes.txt 22 Nov 2002 17:19:32 -0000 1.223
@@ -10,6 +10,13 @@
Revision History:
+22-Nov-2002
+Notes:
+ 1. The nekohtml.jar included has a patch supplied by the author (Andy Clark) to support applet parameter tags
+
+Additions:
+ 1. Added support for applet parameters and archives
+
20-Nov-2002
Problems fixed:
1. HttpUnit now ignores empty parameters on form actions, as IE and Netscape do.
|
|
From: Russell G. <rus...@us...> - 2002-11-22 17:19:37
|
Update of /cvsroot/httpunit/httpunit/jars In directory sc8-pr-cvs1:/tmp/cvs-serv22673/jars Modified Files: nekohtml.jar Log Message: Added support for applet parameters and archives Index: nekohtml.jar =================================================================== RCS file: /cvsroot/httpunit/httpunit/jars/nekohtml.jar,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 Binary files /tmp/cvs5q4QBh and /tmp/cvsIKG3Ho differ |
|
From: Russell G. <rus...@us...> - 2002-11-22 17:12:25
|
Update of /cvsroot/httpunit/httpunit/testData In directory sc8-pr-cvs1:/tmp/cvs-serv19260/testData Log Message: Directory /cvsroot/httpunit/httpunit/testData added to the repository |
|
From: Russell G. <rus...@us...> - 2002-11-21 22:32:09
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv26177/test/com/meterware/httpunit
Modified Files:
FileUploadTest.java
Log Message:
remove 1.4 dependency
Index: FileUploadTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FileUploadTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FileUploadTest.java 15 Nov 2002 02:53:59 -0000 1.13
+++ FileUploadTest.java 21 Nov 2002 22:32:04 -0000 1.14
@@ -372,7 +372,7 @@
private void appendFieldValue( String parameterName, StringBuffer sb, MimeBodyPart mbp ) throws IOException, MessagingException {
- sb.append( parameterName ).append( "=" ).append( URLEncoder.encode( mbp.getContent().toString(), "iso-8859-1" ) );
+ sb.append( parameterName ).append( "=" ).append( URLEncoder.encode( mbp.getContent().toString() ) );
}
|
|
From: Russell G. <rus...@us...> - 2002-11-21 22:32:09
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv26177/doc
Modified Files:
release_notes.txt
Log Message:
remove 1.4 dependency
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -r1.221 -r1.222
--- release_notes.txt 20 Nov 2002 13:04:15 -0000 1.221
+++ release_notes.txt 21 Nov 2002 22:32:04 -0000 1.222
@@ -5,7 +5,7 @@
This behavior matches that currently used by IE and Navigator.
Limitations:
- 1. JDK 1.2 or higher is required
+ 1. JDK 1.3.1 or higher is required
2. JavaScript support does not include some DOM properties
|
|
From: Stefan F. <Ste...@co...> - 2002-11-21 13:55:06
|
Hello *,
I try to get the frames from the following page:
<HTML>
<HEAD>
<TITLE>Test</TITLE>
<meta http-equiv=3D"pragma" content=3D"no-cache">
</HEAD>
<frameset cols=3D"170, *" border=3D"0" frameborder=3D"0" framespacing=3D"=
0">
<frame name=3D"navi" src=3D"navi.jsp" scrolling=3D"auto" framebo=
rder=3D"0" border=3D"0" framespacing=3D"0" marginwidth=3D"0"=20
marginheight=3D"0" noresize>
<frameset rows=3D"20, *" border=3D"0" frameborder=3D"0" framespa=
cing=3D"0">
<frame name=3D"meta" src=3D"meta.htm" scrolling=3D"no" f=
rameborder=3D"0" marginheight=3D"0" marginwidth=3D"0" noresize>
<frame name=3D"main" src=3D"main.jsp" scrolling=3D"auto"=
frameborder=3D"0" marginheight=3D"10" marginwidth=3D"7" noresize>
</frameset>
</frameset>
</HTML>
What I try to do is:
WebConversation wc =3D new WebConversation();
WebResponse resp =3D wc.getResponse( "The above page" );
WebResponse top =3D wc.getFrameContents( "_top" );
WebResponse meta =3D wc.getFrameContents( "meta" );
WebResponse navi =3D wc.getFrameContents( "navi" );
WebResponse main =3D wc.getFrameContents( "main" );
Getting "_top" works, but the others don't.
Is this a problem with the "frameset" statement?
And another question:
How can I dump the response I received to a file or screen,
is that possible at all?
I'm running httpunit 1.5 on weblogic 5.1 on linux.
Thanks,
Stefan
--=20
-----------------------------------------------------------------------
Stefan Fournier |ConSol*
Tel. +49 (0)89/45841-134 |Consulting&Solutions Software GmbH
Fax +49 (0)89/45841-139 |Franziskanerstr. 38, D-81669 M=FCnchen
email: ste...@co... |http://www.consol.de
-----------------------------------------------------------------------
|
|
From: Russell G. <rus...@us...> - 2002-11-20 13:04:19
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv32377/doc
Modified Files:
release_notes.txt
Log Message:
Ignore empty parameters in form action queries
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -r1.220 -r1.221
--- release_notes.txt 19 Nov 2002 04:57:16 -0000 1.220
+++ release_notes.txt 20 Nov 2002 13:04:15 -0000 1.221
@@ -10,6 +10,10 @@
Revision History:
+20-Nov-2002
+Problems fixed:
+ 1. HttpUnit now ignores empty parameters on form actions, as IE and Netscape do.
+
18-Nov-2002
Acknowledgements:
Thanks to Neville Wylie for catching the top.parent and frame name index problems
|
|
From: Russell G. <rus...@us...> - 2002-11-20 13:04:19
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv32377/test/com/meterware/httpunit
Modified Files:
FormParametersTest.java
Log Message:
Ignore empty parameters in form action queries
Index: FormParametersTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormParametersTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- FormParametersTest.java 3 Oct 2002 12:35:18 -0000 1.17
+++ FormParametersTest.java 20 Nov 2002 13:04:16 -0000 1.18
@@ -19,13 +19,9 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.net.URL;
-
import junit.framework.Test;
-import junit.framework.TestCase;
import junit.framework.TestSuite;
-import java.util.Vector;
import java.io.File;
@@ -230,7 +226,7 @@
public void testCheckboxValidation() throws Exception {
- defineWebPage( "Default", "<form method=GET action = \"/ask\">" +
+ defineWebPage( "Default", "<form method=GET action = 'ask?color='>" +
"<Input type=checkbox name=use_color>" +
"<Input type=checkbox name=color value=red>" +
"<Input type=checkbox name=color value=blue>" +
|
|
From: Russell G. <rus...@us...> - 2002-11-20 13:04:19
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv32377/src/com/meterware/httpunit
Modified Files:
FixedURLWebRequestSource.java WebForm.java
WebRequestSource.java
Log Message:
Ignore empty parameters in form action queries
Index: FixedURLWebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FixedURLWebRequestSource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FixedURLWebRequestSource.java 27 Sep 2002 15:49:02 -0000 1.2
+++ FixedURLWebRequestSource.java 20 Nov 2002 13:04:15 -0000 1.3
@@ -78,6 +78,11 @@
}
+ protected String getEmptyParameterValue() {
+ return "";
+ }
+
+
protected void setDestination( String destination ) {
super.setDestination( destination );
_presetParameterList = null;
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- WebForm.java 31 Oct 2002 15:17:06 -0000 1.69
+++ WebForm.java 20 Nov 2002 13:04:15 -0000 1.70
@@ -438,6 +438,11 @@
}
+ protected String getEmptyParameterValue() {
+ return null;
+ }
+
+
//---------------------------------- ParameterHolder methods --------------------------------
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WebRequestSource.java 8 Nov 2002 01:59:38 -0000 1.19
+++ WebRequestSource.java 20 Nov 2002 13:04:16 -0000 1.20
@@ -283,12 +283,13 @@
String value = ((index < 0)
? null
: ((index == param.length() - 1)
- ? ""
+ ? getEmptyParameterValue()
: HttpUnitUtils.decode( param.substring( index + 1 ) ).trim() ));
String name = (index < 0) ? param.trim() : HttpUnitUtils.decode( param.substring( 0, index ) ).trim();
addPresetParameter( name, value );
}
+ abstract protected String getEmptyParameterValue();
}
|
|
From: Russell G. <rus...@us...> - 2002-11-19 04:57:21
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv11470/test/com/meterware/httpunit/javascript
Modified Files:
ScriptingTest.java
Log Message:
Fixed frame name array index and top.parent bug
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- ScriptingTest.java 13 Nov 2002 13:36:39 -0000 1.44
+++ ScriptingTest.java 19 Nov 2002 04:57:17 -0000 1.45
@@ -341,6 +341,9 @@
" alert( 'top url=' + window.top.location );" +
" alert( '1st frame=' + top.frames[0].name );" +
" alert( '2nd frame=' + window.parent.blue.name );" +
+ " alert( 'parent url=' + window.parent.location );" +
+ " alert( 'top.parent=' + top.parent.location );" +
+ " alert( 'indexed frame=' + top.frames['red'].name );" +
"}" +
"</script></head><body>" +
"<a href=# onclick='show_properties()'>show</a>" +
@@ -364,6 +367,9 @@
assertEquals( "2nd alert", "top url=" + getHostPath() + "/Frames.html", wc.popNextAlert() );
assertEquals( "3rd alert", "1st frame=red", wc.popNextAlert() );
assertEquals( "4th alert", "2nd frame=blue", wc.popNextAlert() );
+ assertEquals( "5th alert", "parent url=" + getHostPath() + "/Frames.html", wc.popNextAlert() );
+ assertEquals( "6th alert", "top.parent=" + getHostPath() + "/Frames.html", wc.popNextAlert() );
+ assertEquals( "7th alert", "indexed frame=red", wc.popNextAlert() );
}
|
|
From: Russell G. <rus...@us...> - 2002-11-19 04:57:20
|
Update of /cvsroot/httpunit/httpunit/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv11470/doc
Modified Files:
release_notes.txt
Log Message:
Fixed frame name array index and top.parent bug
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -r1.219 -r1.220
--- release_notes.txt 17 Nov 2002 16:43:40 -0000 1.219
+++ release_notes.txt 19 Nov 2002 04:57:16 -0000 1.220
@@ -10,6 +10,14 @@
Revision History:
+18-Nov-2002
+Acknowledgements:
+ Thanks to Neville Wylie for catching the top.parent and frame name index problems
+
+Problems fixed:
+ 1. The parent attribute of the top frame was returning null rather than the frame.
+ 2. Frame names used as indexes into the Window.frames array were not being recognized.
+
17-Nov-2002
Problems fixed:
1. Bug #637208 Link.click() no longer returns null when an 'onClick' event fails to return true.
|
|
From: Russell G. <rus...@us...> - 2002-11-19 04:57:20
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv11470/src/com/meterware/httpunit
Modified Files:
WebResponse.java
Log Message:
Fixed frame name array index and top.parent bug
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- WebResponse.java 17 Nov 2002 16:43:41 -0000 1.101
+++ WebResponse.java 19 Nov 2002 04:57:17 -0000 1.102
@@ -20,6 +20,7 @@
*
*******************************************************************************************************************/
import com.meterware.httpunit.scripting.ScriptableDelegate;
+import com.meterware.httpunit.scripting.NamedDelegate;
import com.meterware.httpunit.cookies.CookieJar;
import com.meterware.httpunit.cookies.CookieSource;
@@ -532,7 +533,7 @@
}
- public class Scriptable extends ScriptableDelegate {
+ public class Scriptable extends ScriptableDelegate implements NamedDelegate {
public void alert( String message ) {
_client.postAlert( message );
@@ -607,11 +608,11 @@
**/
public Object get( String propertyName ) {
if (propertyName.equals( "name" )) {
- return getFrameName().equals( WebRequest.TOP_FRAME ) ? _window.getName() : getFrameName();
+ return getName();
} else if (propertyName.equalsIgnoreCase( "top" )) {
return _window.getFrameContents( WebRequest.TOP_FRAME ).getScriptableObject();
} else if (propertyName.equalsIgnoreCase( "parent" )) {
- return getFrameName().equals( WebRequest.TOP_FRAME ) ? null
+ return getFrameName().equals( WebRequest.TOP_FRAME ) ? this
: _window.getFrameContents( WebFrame.getParentFrameName( getFrameName() ) ).getScriptableObject();
} else if (propertyName.equalsIgnoreCase( "opener" )) {
return getFrameName().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null;
@@ -624,6 +625,11 @@
return super.get( propertyName );
}
}
+ }
+
+
+ public String getName() {
+ return getFrameName().equals( WebRequest.TOP_FRAME ) ? _window.getName() : getFrameName();
}
|
|
From: Russell G. <rus...@us...> - 2002-11-17 16:43:44
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv24639/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java
Log Message:
Added support for Document.open / close
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DocumentScriptingTest.java 6 Nov 2002 13:10:41 -0000 1.4
+++ DocumentScriptingTest.java 17 Nov 2002 16:43:41 -0000 1.5
@@ -271,5 +271,17 @@
}
+ public void testWriteToNewDocument() throws Exception {
+ defineWebPage( "OnCommand", "<a href='#' onclick=\"w = window.open( '', 'sample' );w.document.open( 'text/plain' ); w.document.write( 'You made it!' );w.document.close()\" >" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ WebLink link = response.getLinks()[0];
+ link.click();
+ WebWindow ww = wc.getOpenWindow( "sample");
+ assertEquals( "Generated page", "You made it!", ww.getCurrentPage().getText() );
+ assertEquals( "Content Type", "text/plain", ww.getCurrentPage().getContentType() );
+ }
+
+
}
|
|
From: Russell G. <rus...@us...> - 2002-11-17 16:43:44
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv24639/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added support for Document.open / close
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- JavaScript.java 15 Nov 2002 03:06:10 -0000 1.39
+++ JavaScript.java 17 Nov 2002 16:43:41 -0000 1.40
@@ -119,17 +119,18 @@
handleScriptException( e, "Script '" + script + "'" );
return "";
} finally {
- Context.getCurrentContext().removeThreadLocal( "stream" );
+ discardDocumentWriteBuffer();
}
}
+
protected StringBuffer getDocumentWriteBuffer() {
- StringBuffer buffer = (StringBuffer) Context.getCurrentContext().getThreadLocal( "stream" );
- if (buffer == null) {
- buffer = new StringBuffer();
- Context.getCurrentContext().putThreadLocal( "stream", buffer );
- }
- return buffer;
+ throw new IllegalStateException( "may not run executeScript() from " + getClass() );
+ }
+
+
+ protected void discardDocumentWriteBuffer() {
+ throw new IllegalStateException( "may not run executeScript() from " + getClass() );
}
@@ -267,6 +268,11 @@
}
+ protected static String toStringIfNotUndefined( Object object ) {
+ return (object == null || Undefined.instance.equals( object )) ? null : object.toString();
+ }
+
+
/**
* Converts a scriptable delegate obtained from a subobject into the appropriate Rhino-compatible Scriptable.
**/
@@ -429,8 +435,13 @@
}
- private String toStringIfNotUndefined( Object object ) {
- return (object == null || Undefined.instance.equals( object )) ? null : object.toString();
+ protected StringBuffer getDocumentWriteBuffer() {
+ return jsGet_document().getWriteBuffer();
+ }
+
+
+ protected void discardDocumentWriteBuffer() {
+ jsGet_document().clearWriteBuffer();
}
@@ -445,6 +456,8 @@
private ElementArray _forms;
private ElementArray _links;
private ElementArray _images;
+ private StringBuffer _writeBuffer;
+ private String _mimeType;
public String getClassName() {
@@ -490,15 +503,34 @@
}
+ public void jsFunction_open( Object mimeType ) {
+ _mimeType = toStringIfNotUndefined( mimeType );
+ }
+
+
+ public void jsFunction_close() {
+ getDelegate().replaceText( getWriteBuffer().toString(), _mimeType == null ? "text/html" : _mimeType );
+ }
+
+
public void jsFunction_write( String string ) {
- final StringBuffer documentWriteBuffer = getDocumentWriteBuffer();
- documentWriteBuffer.append( string );
+ getWriteBuffer().append( string );
}
public void jsFunction_writeln( String string ) {
- final StringBuffer documentWriteBuffer = getDocumentWriteBuffer();
- documentWriteBuffer.append( string ).append( (char) 0x0D ).append( (char) 0x0A );
+ getWriteBuffer().append( string ).append( (char) 0x0D ).append( (char) 0x0A );
+ }
+
+
+ protected StringBuffer getWriteBuffer() {
+ if (_writeBuffer == null) _writeBuffer = new StringBuffer();
+ return _writeBuffer;
+ }
+
+
+ protected void clearWriteBuffer() {
+ _writeBuffer = null;
}
|
|
From: Russell G. <rus...@us...> - 2002-11-17 16:43:44
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv24639/src/com/meterware/httpunit
Modified Files:
HTMLPage.java WebResponse.java
Log Message:
Added support for Document.open / close
Index: HTMLPage.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- HTMLPage.java 3 Nov 2002 06:28:36 -0000 1.15
+++ HTMLPage.java 17 Nov 2002 16:43:40 -0000 1.16
@@ -232,6 +232,11 @@
Scriptable() {}
+
+
+ public void replaceText( String text, String contentType ) {
+ getResponse().replaceText( text, contentType );
+ }
}
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- WebResponse.java 17 Nov 2002 00:17:07 -0000 1.100
+++ WebResponse.java 17 Nov 2002 16:43:41 -0000 1.101
@@ -248,7 +248,7 @@
* Returns a buffered input stream for reading the contents of this reply.
**/
public InputStream getInputStream() throws IOException {
- if (_inputStream == null) _inputStream = new ByteArrayInputStream( new byte[0] );
+ if (_inputStream == null) _inputStream = new ByteArrayInputStream( getText().getBytes() );
return _inputStream;
}
@@ -680,6 +680,17 @@
}
+ /**
+ * Constructs a response object.
+ * @param frameName the name of the frame to hold the response
+ * @param url the url from which the response was received
+ **/
+ protected WebResponse( WebClient client, String frameName, URL url, String text ) {
+ this( client, frameName, url );
+ _responseText = text;
+ }
+
+
final
protected void defineRawInputStream( InputStream inputStream ) throws IOException {
if (_inputStream != null || _responseText != null) {
@@ -724,6 +735,14 @@
}
+ void replaceText( String text, String contentType ) {
+ _responseText = text;
+ _inputStream = null;
+ _page = null;
+ _contentType = contentType;
+ }
+
+
/**
* Returns the frames found in the page in the order in which they appear.
**/
@@ -1100,8 +1119,7 @@
DefaultWebResponse( WebClient client, String target, URL url, String text ) {
- super( client, target, url );
- _responseText = text;
+ super( client, target, url, text );
}
@@ -1137,33 +1155,19 @@
}
}
+
public String[] getHeaderFields( String fieldName ) {
String value = getHeaderField( fieldName );
return value == null ? new String[0] : new String[]{ value };
}
- /**
- * Returns the text of the response (excluding headers) as a string. Use this method in preference to 'toString'
- * which may be used to represent internal state of this object.
- **/
- public String getText() {
- return _responseText;
- }
-
-
- /**
- * Returns an input stream for reading the contents of this reply.
- **/
- public InputStream getInputStream() {
- return new ByteArrayInputStream( _responseText.getBytes() );
- }
-
public String toString() {
- return "DefaultWebResponse [" + _responseText + "]";
+ try {
+ return "DefaultWebResponse [" + getText() + "]";
+ } catch (IOException e) { // should never happen
+ return "DefaultWebResponse [???]";
+ }
}
-
-
- private String _responseText;
}
|
|
From: Russell G. <rus...@us...> - 2002-11-17 16:43:43
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv24639/doc
Modified Files:
Javascript-support.html release_notes.txt
Log Message:
Added support for Document.open / close
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Javascript-support.html 13 Nov 2002 13:36:39 -0000 1.28
+++ Javascript-support.html 17 Nov 2002 16:43:40 -0000 1.29
@@ -84,6 +84,8 @@
</ul>
<h4>methods</h4>
<ul>
+<li>open - opens a document for writing, optionally specifying a MIME type</li>
+<li>close - closes the open document and replaces its contents with the written text</li>
<li>write - writes a string to the contents of the current open document</li>
<li>writeln - writes a line with carriage-return to the contents of the current open document</li>
</ul>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -r1.218 -r1.219
--- release_notes.txt 17 Nov 2002 13:57:47 -0000 1.218
+++ release_notes.txt 17 Nov 2002 16:43:40 -0000 1.219
@@ -6,13 +6,16 @@
Limitations:
1. JDK 1.2 or higher is required
- 2. JavaScript support does not include Document.open() and some DOM properties
+ 2. JavaScript support does not include some DOM properties
Revision History:
17-Nov-2002
Problems fixed:
1. Bug #637208 Link.click() no longer returns null when an 'onClick' event fails to return true.
+
+Additions:
+ 1. Added support for Document.open, Document.close, and Document.write / writeln for new documents
16-Nov-2002
Problems fixed:
|
|
From: Russell G. <rus...@us...> - 2002-11-17 13:57:50
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv13800/src/com/meterware/httpunit
Modified Files:
WebLink.java
Log Message:
637208: Link.click() no longer returns null
Index: WebLink.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- WebLink.java 15 Nov 2002 03:06:10 -0000 1.35
+++ WebLink.java 17 Nov 2002 13:57:47 -0000 1.36
@@ -78,13 +78,17 @@
/**
* Submits a request as though the user had clicked on this link. Will also fire the 'onClick' event if defined.
- * If clicking results in submitting a request, will return the result of that submission; otherwise, will
- * return the updated contents of the frame containing this link.
+ * If clicking results in submitting a request (that is, there is no 'onClick' event or it returns true,
+ * this method will return the result of that submission; otherwise, it will
+ * return the updated contents of the frame containing this link. Note that if an event updates a different frame
+ * that frame will not be returned by this method.
**/
public WebResponse click() throws IOException, SAXException {
+ WebResponse response = null;
String event = getAttribute( "onclick" );
- if (event.length() == 0 || getScriptableObject().doEvent( event )) return submitRequest();
- return getBaseResponse().getWindow().getFrameContents( getTarget() );
+ if (event.length() == 0 || getScriptableObject().doEvent( event )) response = submitRequest();
+ if (response == null) response = getBaseResponse().getWindow().getFrameContents( getTarget() );
+ return response;
}
|
|
From: Russell G. <rus...@us...> - 2002-11-17 13:57:50
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv13800/doc
Modified Files:
release_notes.txt
Log Message:
637208: Link.click() no longer returns null
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -r1.217 -r1.218
--- release_notes.txt 17 Nov 2002 00:16:58 -0000 1.217
+++ release_notes.txt 17 Nov 2002 13:57:47 -0000 1.218
@@ -10,7 +10,11 @@
Revision History:
-16-Nov-202
+17-Nov-2002
+Problems fixed:
+ 1. Bug #637208 Link.click() no longer returns null when an 'onClick' event fails to return true.
+
+16-Nov-2002
Problems fixed:
1. Bug #638304 Interframe dependancies for JavaScript at load time are now handled better.
|
|
From: Russell G. <rus...@us...> - 2002-11-17 00:17:10
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv30543/test/com/meterware/httpunit/javascript
Modified Files:
FormScriptingTest.java
Log Message:
Wait until all frames are loaded before running embedded JavaScripts
Index: FormScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FormScriptingTest.java 31 Oct 2002 04:54:58 -0000 1.13
+++ FormScriptingTest.java 17 Nov 2002 00:17:07 -0000 1.14
@@ -646,4 +646,24 @@
}
+ public void testAccessAcrossFrames() throws Exception {
+ defineWebPage( "First", "<script language='JavaScript'>" +
+ " top.frame2.document.testform.param1.value = 'new1';" +
+ " window.alert('value: ' + top.frame2.document.testform.param1.value);" +
+ "</script>" );
+ defineWebPage( "Second", "<form method=post name=testform action='http://trinity/dummy'>" +
+ " <input type=hidden name='param1' value='old1'></form>" );
+ defineResource( "Frames.html",
+ "<html><head><title>Initial</title></head>" +
+ "<frameset cols=\"20%,80%\">" +
+ " <frame src='First.html' name='frame1'>" +
+ " <frame src='Second.html' name='frame2'>" +
+ "</frameset></html>" );
+
+ WebConversation wc = new WebConversation();
+ wc.getResponse( getHostPath() + "/Frames.html" );
+ assertEquals( "Alert message", "value: new1", wc.popNextAlert() );
+ }
+
+
}
|
|
From: Russell G. <rus...@us...> - 2002-11-17 00:17:10
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv30543/src/com/meterware/httpunit
Modified Files:
FrameHolder.java WebClient.java WebResponse.java
WebWindow.java
Added Files:
RequestContext.java
Log Message:
Wait until all frames are loaded before running embedded JavaScripts
***** Error reading new file[Errno 2] No such file or directory: 'RequestContext.java'
Index: FrameHolder.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FrameHolder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FrameHolder.java 24 Oct 2002 13:28:53 -0000 1.6
+++ FrameHolder.java 17 Nov 2002 00:17:06 -0000 1.7
@@ -74,15 +74,19 @@
}
- void updateFrames( WebResponse response, String target ) throws MalformedURLException, IOException, SAXException {
+ void updateFrames( WebResponse response, String target, RequestContext requestContext ) throws MalformedURLException, IOException, SAXException {
removeSubFrames( target );
_contents.put( target, response );
if (response.isHTML()) {
- HttpUnitOptions.getScriptingEngine().associate( response );
- createSubFrames( target, response.getFrameNames() );
- WebRequest[] requests = response.getFrameRequests();
- for (int i = 0; i < requests.length; i++) response.getWindow().getResponse( requests[ i ] );
+ if (!response.hasSubframes()) {
+ requestContext.addNewResponse( response );
+ } else {
+ HttpUnitOptions.getScriptingEngine().associate( response );
+ createSubFrames( target, response.getFrameNames() );
+ WebRequest[] requests = response.getFrameRequests();
+ for (int i = 0; i < requests.length; i++) response.getWindow().getSubframeResponse( requests[ i ], requestContext );
+ }
}
}
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- WebClient.java 8 Nov 2002 02:18:54 -0000 1.46
+++ WebClient.java 17 Nov 2002 00:17:07 -0000 1.47
@@ -140,67 +140,6 @@
}
- WebResponse getResourceForWindow( WebRequest request, WebWindow window ) throws IOException {
- tellListeners( request );
- WebResponse response = getResource( request, window );
- if (response != null) tellListeners( response );
- return response;
- }
-
-
- private WebResponse getResource( WebRequest request, final WebWindow window ) throws IOException {
- final String frameName = getTargetFrame( request.getTarget() );
- String urlString = request.getURLString().trim();
- if (urlString.startsWith( "about:" )) {
- return WebResponse.BLANK_RESPONSE;
- } else if (!urlString.startsWith( "javascript:" )) {
- return newResponse( request, frameName );
- } else {
- WebRequestSource wrs = request.getWebRequestSource();
- String result = (wrs == null) ? window.getCurrentPage().getScriptableObject().evaluateURL( urlString )
- : wrs.getScriptableDelegate().evaluateURL( urlString );
- if (result == null) return null;
-
- return new DefaultWebResponse( this, frameName, request.getURL(), result );
- }
- }
-
-
- private String getTargetFrame( String target ) {
- if (WebRequest.NEW_WINDOW.equalsIgnoreCase( target )) {
- return WebRequest.TOP_FRAME;
- } else {
- return target;
- }
- }
-
-
- private void tellListeners( WebRequest request ) {
- List listeners;
-
- synchronized (_clientListeners) {
- listeners = new ArrayList( _clientListeners );
- }
-
- for (Iterator i = listeners.iterator(); i.hasNext();) {
- ((WebClientListener) i.next()).requestSent( this, request );
- }
- }
-
-
- private void tellListeners( WebResponse response ) {
- List listeners;
-
- synchronized (_clientListeners) {
- listeners = new ArrayList( _clientListeners );
- }
-
- for (Iterator i = listeners.iterator(); i.hasNext();) {
- ((WebClientListener) i.next()).responseReceived( this, response );
- }
- }
-
-
/**
* Resets the state of this client, removing all cookies, frames, and per-client headers. This does not affect
* any listeners or preferences which may have been set.
@@ -452,11 +391,40 @@
/**
* Updates this web client based on a received response. This includes updating
- * cookies and frames.
+ * cookies and frames. This method is required by ServletUnit, which cannot call the updateWindow method directly.
**/
final
protected void updateMainWindow( String target, WebResponse response ) throws MalformedURLException, IOException, SAXException {
- _mainWindow.updateWindow( target, response );
+ getMainWindow().updateWindow( target, response, new RequestContext() );
+ }
+
+
+//------------------------------------------------- package members ----------------------------------------------------
+
+
+ void tellListeners( WebRequest request ) {
+ List listeners;
+
+ synchronized (_clientListeners) {
+ listeners = new ArrayList( _clientListeners );
+ }
+
+ for (Iterator i = listeners.iterator(); i.hasNext();) {
+ ((WebClientListener) i.next()).requestSent( this, request );
+ }
+ }
+
+
+ void tellListeners( WebResponse response ) {
+ List listeners;
+
+ synchronized (_clientListeners) {
+ listeners = new ArrayList( _clientListeners );
+ }
+
+ for (Iterator i = listeners.iterator(); i.hasNext();) {
+ ((WebClientListener) i.next()).responseReceived( this, response );
+ }
}
@@ -466,13 +434,13 @@
}
- void updateFrameContents( WebWindow requestWindow, String requestTarget, WebResponse response ) throws IOException, SAXException {
+ void updateFrameContents( WebWindow requestWindow, String requestTarget, WebResponse response, RequestContext requestContext ) throws IOException, SAXException {
WebWindow window = getTargetWindow( requestWindow, requestTarget );
if (window != null) {
- window.updateFrameContents( response );
+ window.updateFrameContents( response, requestContext );
} else {
window = new WebWindow( this );
- window.updateFrameContents( response );
+ window.updateFrameContents( response, requestContext );
_openWindows.add( window );
reportWindowOpened( window );
}
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- WebResponse.java 13 Nov 2002 14:01:23 -0000 1.99
+++ WebResponse.java 17 Nov 2002 00:17:07 -0000 1.100
@@ -48,6 +48,8 @@
abstract
public class WebResponse implements HTMLSegment, CookieSource {
private String _refreshHeader;
+ private boolean _hasSubframes;
+
/**
* Returns a web response built from a URL connection. Provided to allow
@@ -797,7 +799,7 @@
} while (count != -1);
byte[] bytes = outputStream.toByteArray();
- readMetaTags( bytes );
+ readTags( bytes );
_responseText = new String( bytes, getCharacterSet() );
_inputStream = new ByteArrayInputStream( bytes );
@@ -811,11 +813,12 @@
}
- private void readMetaTags( byte[] rawMessage ) throws UnsupportedEncodingException {
+ private void readTags( byte[] rawMessage ) throws UnsupportedEncodingException {
ByteTagParser parser = new ByteTagParser( rawMessage );
ByteTag tag = parser.getNextTag();
while (tag != null && !tag.getName().equalsIgnoreCase( "body" )) {
if (tag.getName().equalsIgnoreCase( "meta" )) processMetaTag( tag );
+ if (tag.getName().equalsIgnoreCase( "frameset" )) _hasSubframes = true;
tag = parser.getNextTag();
}
}
@@ -969,6 +972,11 @@
} catch (UnsupportedEncodingException e) {
_characterSet = getDefaultEncoding();
}
+ }
+
+
+ boolean hasSubframes() {
+ return _hasSubframes;
}
Index: WebWindow.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- WebWindow.java 11 Oct 2002 01:26:22 -0000 1.7
+++ WebWindow.java 17 Nov 2002 00:17:07 -0000 1.8
@@ -106,12 +106,72 @@
* @exception SAXException thrown if there is an error parsing the retrieved page
**/
public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException {
- WebResponse response = _client.getResourceForWindow( request, this );
+ final RequestContext requestContext = new RequestContext();
+ final WebResponse response = getSubframeResponse( request, requestContext );
+ requestContext.runScripts();
+ return response;
+ }
+
+
+ WebResponse getSubframeResponse( WebRequest request, RequestContext requestContext ) throws IOException, SAXException {
+ WebResponse response = getResource( request );
+
+ return response == null ? null : updateWindow( request.getTarget(), response, requestContext );
+ }
+
+
+ /**
+ * Updates this web client based on a received response. This includes updating
+ * cookies and frames.
+ **/
+ WebResponse updateWindow( String requestTarget, WebResponse response, RequestContext requestContext ) throws MalformedURLException, IOException, SAXException {
+ _client.updateClient( response );
+ if (HttpUnitOptions.getAutoRefresh() && response.getRefreshRequest() != null) {
+ return getResponse( response.getRefreshRequest() );
+ } else if (shouldFollowRedirect( response )) {
+ delay( HttpUnitOptions.getRedirectDelay() );
+ return getResponse( new RedirectWebRequest( response ) );
+ } else {
+ _client.updateFrameContents( this, requestTarget, response, requestContext );
+ return response;
+ }
+ }
+
+
+ /**
+ * Returns the resource specified by the request. Does not update the window or load included framesets.
+ * May return null if the resource is a JavaScript URL which would normally leave the client unchanged.
+ */
+ public WebResponse getResource( WebRequest request ) throws IOException {
+ _client.tellListeners( request );
+
+ WebResponse response = null;
+ final String frameName = getTargetFrame( request.getTarget() );
+ String urlString = request.getURLString().trim();
+ if (urlString.startsWith( "about:" )) {
+ response = WebResponse.BLANK_RESPONSE;
+ } else if (!urlString.startsWith( "javascript:" )) {
+ response = _client.newResponse( request, frameName );
+ } else {
+ WebRequestSource wrs = request.getWebRequestSource();
+ String result = (wrs == null) ? getCurrentPage().getScriptableObject().evaluateURL( urlString )
+ : wrs.getScriptableDelegate().evaluateURL( urlString );
+ if (result != null) response = new DefaultWebResponse( _client, frameName, request.getURL(), result );
+ }
- return response == null ? null : updateWindow( request.getTarget(), response );
+ if (response != null) _client.tellListeners( response );
+ return response;
}
+ private String getTargetFrame( String target ) {
+ if (WebRequest.NEW_WINDOW.equalsIgnoreCase( target )) {
+ return WebRequest.TOP_FRAME;
+ } else {
+ return target;
+ }
+ }
+
/**
* Returns the name of the currently active frames.
**/
@@ -126,7 +186,7 @@
* Throws a runtime exception if no matching frame is defined.
**/
public WebResponse getFrameContents( String frameName ) {
- WebResponse response = (WebResponse) _frameContents.get( frameName );
+ WebResponse response = _frameContents.get( frameName );
if (response == null) throw new NoSuchFrameException( frameName );
return response;
}
@@ -152,36 +212,9 @@
}
- /**
- * Updates this web client based on a received response. This includes updating
- * cookies and frames.
- **/
- WebResponse updateWindow( String requestTarget, WebResponse response ) throws MalformedURLException, IOException, SAXException {
- _client.updateClient( response );
- if (HttpUnitOptions.getAutoRefresh() && response.getRefreshRequest() != null) {
- return getResponse( response.getRefreshRequest() );
- } else if (shouldFollowRedirect( response )) {
- delay( HttpUnitOptions.getRedirectDelay() );
- return getResponse( new RedirectWebRequest( response ) );
- } else {
- _client.updateFrameContents( this, requestTarget, response );
- return response;
- }
- }
-
-
- /**
- * Returns the resource specified by the request. Does not update the client or load included framesets.
- * May return null if the resource is a JavaScript URL which would normally leave the client unchanged.
- */
- WebResponse getResource( WebRequest request ) throws IOException {
- return _client.getResourceForWindow( request, this );
- }
-
-
- void updateFrameContents( WebResponse response ) throws IOException, SAXException {
+ void updateFrameContents( WebResponse response, RequestContext requestContext ) throws IOException, SAXException {
response.setWindow( this );
- _frameContents.updateFrames( response, response.getFrameName() );
+ _frameContents.updateFrames( response, response.getFrameName(), requestContext );
}
@@ -209,7 +242,6 @@
&& response.getResponseCode() <= HttpURLConnection.HTTP_MOVED_TEMP
&& response.getHeaderField( "Location" ) != null;
}
-
}
|
|
From: Russell G. <rus...@us...> - 2002-11-17 00:17:09
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv30543/doc
Modified Files:
release_notes.txt
Log Message:
Wait until all frames are loaded before running embedded JavaScripts
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -r1.216 -r1.217
--- release_notes.txt 15 Nov 2002 03:06:10 -0000 1.216
+++ release_notes.txt 17 Nov 2002 00:16:58 -0000 1.217
@@ -10,6 +10,10 @@
Revision History:
+16-Nov-202
+Problems fixed:
+ 1. Bug #638304 Interframe dependancies for JavaScript at load time are now handled better.
+
14-Nov-2002
Problems fixed:
1. Bug #638406 Multi-line values in form data were using the platform-specific line ending rather than CRLF.
|
|
From: Russell G. <rus...@us...> - 2002-11-15 06:56:13
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv29106/test/com/meterware/httpunit/javascript
Modified Files:
NekoEnhancedScriptingTest.java
Log Message:
638306: Document.writeln now uses CRLF as terminator rather than 13
Index: NekoEnhancedScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/NekoEnhancedScriptingTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NekoEnhancedScriptingTest.java 6 Nov 2002 13:10:41 -0000 1.1
+++ NekoEnhancedScriptingTest.java 15 Nov 2002 03:06:10 -0000 1.2
@@ -53,7 +53,7 @@
"<body>" +
"<script language='JavaScript'>" +
"document.write( '<a id=here href=about:blank>' );" +
- "document.write( document.title );" +
+ "document.writeln( document.title );" +
"document.write( '</a>' );" +
"</script>" +
"</body></html>" );
|
|
From: Russell G. <rus...@us...> - 2002-11-15 06:51:57
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv28629/src/com/meterware/httpunit Added Files: AppletContextImpl.java AppletStubImpl.java Log Message: support applet load, find, show-document ***** Error reading new file[Errno 2] No such file or directory: 'AppletContextImpl.java' ***** Error reading new file[Errno 2] No such file or directory: 'AppletStubImpl.java' |
|
From: Russell G. <rus...@us...> - 2002-11-15 06:51:48
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver
In directory usw-pr-cvs1:/tmp/cvs-serv27410/src/com/meterware/pseudoserver
Modified Files:
HttpUserAgentTest.java PseudoServer.java WebResource.java
Log Message:
support applet load, find, show-document
Index: HttpUserAgentTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/HttpUserAgentTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HttpUserAgentTest.java 22 Oct 2002 15:12:54 -0000 1.3
+++ HttpUserAgentTest.java 15 Nov 2002 00:07:33 -0000 1.4
@@ -89,6 +89,11 @@
}
+ protected void mapToClasspath( String directory ) {
+ _server.mapToClasspath( directory );
+ }
+
+
protected String getHostPath() {
return _hostPath;
}
@@ -189,6 +194,7 @@
}
return sb.toString();
}
+
static class QuerySpec {
QuerySpec( String urlString ) {
Index: PseudoServer.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/PseudoServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PseudoServer.java 13 Nov 2002 14:01:23 -0000 1.3
+++ PseudoServer.java 15 Nov 2002 00:07:33 -0000 1.4
@@ -19,26 +19,21 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import java.io.InterruptedIOException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
+import java.io.*;
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.net.Socket;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
+import java.util.*;
/**
* A basic simulated web-server for testing user agents without a web server.
**/
public class PseudoServer {
+ private ArrayList _classpathDirs = new ArrayList();
+
public PseudoServer() {
Thread t = new Thread() {
@@ -157,6 +152,11 @@
}
+ public void mapToClasspath( String directory ) {
+ _classpathDirs.add( directory );
+ }
+
+
//------------------------------------- private members ---------------------------------------
private Hashtable _resources = new Hashtable();
@@ -212,7 +212,7 @@
for (int i = 0; i < headers.length; i++) {
response.addHeader( headers[i] );
}
- response.write( resource.getContents() );
+ response.write( resource );
}
} catch (UnknownMethodException e) {
response.setResponse( HttpURLConnection.HTTP_BAD_METHOD, "unsupported method: " + e.getMethod() );
@@ -237,6 +237,13 @@
} else if (resource instanceof PseudoServlet) {
return getResource( (PseudoServlet) resource, request );
} else {
+ for (Iterator iterator = _classpathDirs.iterator(); iterator.hasNext();) {
+ String directory = (String) iterator.next();
+ if (request.getURI().startsWith( directory )) {
+ String resourceName = request.getURI().substring( directory.length()+1 );
+ return new WebResource( getClass().getClassLoader().getResourceAsStream( resourceName ), "application/class", 200 );
+ }
+ }
return null;
}
}
@@ -303,9 +310,9 @@
}
- void write( byte[] contents ) throws IOException {
+ void write( WebResource resource ) throws IOException {
flushHeaders();
- _stream.write( contents, 0, contents.length );
+ resource.writeTo( _stream );
}
@@ -315,7 +322,7 @@
}
- private void flushHeaders() throws IOException {
+ private void flushHeaders() {
if (!_headersWritten) {
sendResponse( _responseCode, _responseText );
for (Enumeration e = _headers.elements(); e.hasMoreElements();) {
@@ -328,18 +335,18 @@
}
- private void sendResponse( int responseCode, String responseText ) throws IOException {
+ private void sendResponse( int responseCode, String responseText ) {
sendLine( "HTTP/1.0 " + responseCode + ' ' + responseText );
}
- private void sendLine( String text ) throws IOException {
+ private void sendLine( String text ) {
sendText( text );
sendText( CRLF );
}
- private void sendText( String text ) throws IOException {
+ private void sendText( String text ) {
_pw.write( text );
}
Index: WebResource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/pseudoserver/WebResource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebResource.java 13 Nov 2002 14:01:23 -0000 1.2
+++ WebResource.java 15 Nov 2002 00:07:33 -0000 1.3
@@ -21,7 +21,9 @@
*******************************************************************************************************************/
import com.meterware.httpunit.HttpUnitUtils;
-import java.io.UnsupportedEncodingException;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.HttpURLConnection;
import java.util.Vector;
@@ -87,6 +89,13 @@
}
+ public WebResource( InputStream stream, String contentType, int responseCode ) {
+ _stream = stream;
+ _contentType = contentType;
+ _responseCode = responseCode;
+ }
+
+
String[] getHeaders() {
final Vector effectiveHeaders = (Vector) _headers.clone();
if (!_hasExplicitContentTypeHeader) effectiveHeaders.add( getContentTypeHeader() );
@@ -96,11 +105,18 @@
}
- byte[] getContents() throws UnsupportedEncodingException {
+ void writeTo( OutputStream outputStream ) throws IOException {
if (_string != null) {
- return _string.getBytes( getCharacterSet() );
- } else {
- return _contents;
+ outputStream.write( _string.getBytes( getCharacterSet() ) );
+ } else if (_contents != null) {
+ outputStream.write( _contents );
+ } else if (_stream != null) {
+ byte[] buffer = new byte[8 * 1024];
+ int count = 0;
+ do {
+ outputStream.write( buffer, 0, count );
+ count = _stream.read( buffer, 0, buffer.length );
+ } while (count != -1);
}
}
@@ -143,8 +159,9 @@
}
- private byte[] _contents;
- private String _string;
+ private byte[] _contents;
+ private String _string;
+ private InputStream _stream;
private int _responseCode;
private boolean _sendCharacterSet;
|