httpunit-commit Mailing List for httpunit (Page 49)
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-10-09 19:15:34
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv13849/test/com/meterware/servletunit
Modified Files:
WebXMLTest.java
Log Message:
Added support for default servlet mapping
Index: WebXMLTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/servletunit/WebXMLTest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WebXMLTest.java 2 Oct 2002 15:04:43 -0000 1.12
+++ WebXMLTest.java 9 Oct 2002 19:15:29 -0000 1.13
@@ -261,6 +261,7 @@
wxs.addServlet( "/baz/*", Servlet2.class );
wxs.addServlet( "/catalog", Servlet3.class );
wxs.addServlet( "*.bop", Servlet4.class );
+ wxs.addServlet( "/", Servlet5.class );
ServletRunner sr = new ServletRunner( toInputStream( wxs.asText() ) );
ServletUnitClient wc = sr.newClient();
@@ -271,18 +272,13 @@
checkMapping( wc, "http://localhost/catalog", Servlet3.class, "/catalog", null );
checkMapping( wc, "http://localhost/catalog/racecar.bop", Servlet4.class, "/catalog/racecar.bop", null );
checkMapping( wc, "http://localhost/index.bop", Servlet4.class, "/index.bop", null );
-
- try {
- wc.newInvocation( "http://localhost/catalog/index.html" ).getServlet();
- fail( "Should have gotten a 404" );
- } catch (HttpNotFoundException e) {
- }
+ checkMapping( wc, "http://localhost/something/else", Servlet5.class, "/something/else", null );
}
private void checkMapping( ServletUnitClient wc, final String url, final Class servletClass, final String expectedPath, final String expectedInfo ) throws IOException, ServletException {
InvocationContext ic = wc.newInvocation( url );
- assertTrue( servletClass.isInstance( ic.getServlet() ) );
+ assertTrue( "selected servlet is " + ic.getServlet() + " rather than " + servletClass, servletClass.isInstance( ic.getServlet() ) );
assertEquals( "ServletPath for " + url, expectedPath, ic.getRequest().getServletPath() );
assertEquals( "ServletInfo for " + url, expectedInfo, ic.getRequest().getPathInfo() );
}
@@ -342,6 +338,7 @@
static class Servlet2 extends SimpleGetServlet {}
static class Servlet3 extends SimpleGetServlet {}
static class Servlet4 extends SimpleGetServlet {}
+ static class Servlet5 extends SimpleGetServlet {}
}
|
|
From: Russell G. <rus...@us...> - 2002-10-09 19:15:32
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit
In directory usw-pr-cvs1:/tmp/cvs-serv13849/src/com/meterware/servletunit
Modified Files:
WebApplication.java
Log Message:
Added support for default servlet mapping
Index: WebApplication.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/WebApplication.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- WebApplication.java 5 Sep 2002 19:29:55 -0000 1.13
+++ WebApplication.java 9 Oct 2002 19:15:29 -0000 1.14
@@ -591,9 +591,12 @@
private final Map _exactMatches = new HashMap();
private final Map _extensions = new HashMap();
private final Map _urlTree = new HashMap();
+ private ServletMapping _defaultMapping;
void put( String mapping, ServletConfiguration servletConfiguration ) {
- if (mapping.startsWith( "*." )) {
+ if (mapping.equals( "/" )) {
+ _defaultMapping = new ServletMapping( servletConfiguration );
+ } else if (mapping.startsWith( "*." )) {
_extensions.put( mapping.substring( 2 ), new ServletMapping( servletConfiguration ) );
} else if (!mapping.startsWith( "/" ) || !mapping.endsWith( "/*" )) {
_exactMatches.put( mapping, new ServletMapping( servletConfiguration ) );
@@ -647,6 +650,8 @@
if (_extensions.containsKey( getExtension( url ))) return (ServletMapping) _extensions.get( getExtension( url ) );
if (_urlTree.containsKey( "/" )) return (ServletMapping) _urlTree.get( "/" );
+
+ if (_defaultMapping != null) return _defaultMapping;
final String prefix = "/servlet/";
if (!url.startsWith( prefix )) return null;
|
|
From: Russell G. <rus...@us...> - 2002-10-09 19:15:32
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv13849/doc
Modified Files:
release_notes.txt
Log Message:
Added support for default servlet mapping
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -r1.184 -r1.185
--- release_notes.txt 9 Oct 2002 17:16:30 -0000 1.184
+++ release_notes.txt 9 Oct 2002 19:15:29 -0000 1.185
@@ -16,6 +16,9 @@
Additions:
1. Added support for the following JavaScript Window properties: frames, name, opener, top
2. Added do-nothing stubs for the Window properties and functions: closed, close(), moveTo(), focus(), setTimeout()
+Problems fixed:
+ 1. ServletUnit was not supporting mappings for the default servlet.
+
8-Oct-2002
Acknowledgements:
|
|
From: Russell G. <rus...@us...> - 2002-10-09 17:16:34
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv20416/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added support for JavaScript frame properties
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- JavaScript.java 9 Oct 2002 13:50:08 -0000 1.28
+++ JavaScript.java 9 Oct 2002 17:16:31 -0000 1.29
@@ -159,7 +159,7 @@
private void handleScriptException( Exception e, String badScript ) {
final String errorMessage = badScript + " failed: " + e;
- if (!(e instanceof EcmaError)) {
+ if (!(e instanceof EcmaError) && !(e instanceof EvaluatorException)) {
throw new RuntimeException( errorMessage );
} else if (isThrowExceptionsOnError()) {
throw new ScriptException( errorMessage );
@@ -277,6 +277,7 @@
private Document _document;
private Navigator _navigator;
private Screen _screen;
+ private ElementArray _frames;
public String getClassName() {
@@ -299,11 +300,30 @@
}
+ public Scriptable jsGet_frames() throws SAXException, PropertyException, JavaScriptException, NotAFunctionException {
+ if (_frames == null) {
+ WebResponse.Scriptable scriptables[] = getDelegate().getFrames();
+ Window[] frames = new Window[ scriptables.length ];
+ for (int i = 0; i < frames.length; i++) {
+ frames[ i ] = (Window) toScriptable( scriptables[ i ] );
+ }
+ _frames = (ElementArray) Context.getCurrentContext().newObject( this, "ElementArray" );
+ _frames.initialize( frames );
+ }
+ return _frames;
+ }
+
+
public Navigator jsGet_navigator() {
return _navigator;
}
+ public boolean jsGet_closed() {
+ return false;
+ }
+
+
public Screen jsGet_screen() {
return _screen;
}
@@ -337,6 +357,22 @@
public String jsFunction_prompt( String message, String defaultResponse ) {
return getDelegate().getUserResponse( message, defaultResponse );
+ }
+
+
+ public void jsFunction_moveTo( int x, int y ) {
+ }
+
+
+ public void jsFunction_focus() {
+ }
+
+
+ public void jsFunction_setTimeout() {
+ }
+
+
+ public void jsFunction_close() {
}
|
|
From: Russell G. <rus...@us...> - 2002-10-09 17:16:34
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv20416/doc
Modified Files:
Javascript-support.html release_notes.txt todo.txt
Log Message:
Added support for JavaScript frame properties
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Javascript-support.html 9 Oct 2002 13:50:07 -0000 1.21
+++ Javascript-support.html 9 Oct 2002 17:16:30 -0000 1.22
@@ -9,13 +9,15 @@
<h3>Window</h3>
<h4>properties</h4>
<ul>
-<li>document - the associated Document object</li>
-<li>location - r/w full URL only</li>
+<li>document - the associated Document object</li>
+<li>frames - an array of subframes of this window</li>
+<li>location - r/w full URL only</li>
+<li>name - r/w the name of the window</li>
<li>navigator - the Navigator object</li>
-<li>self - the Window itself</li>
-<li>window - a synonym for self</li>
-<li>name - r/w the name of the window (top-level frames only)</li>
-<li>opener - r/o the window which opened this one (top-level frames only)</li>
+<li>opener - r/o the window which opened this one (top-level frames only)</li>
+<li>self - the Window itself</li>
+<li>top - the top frame in the frameset containing this window
+<li>window - a synonym for self</li>
</ul>
<h4>events</h4>
<ul>
@@ -26,8 +28,8 @@
<li>alert() - queues up an alert message, accessible via WebResponse.getNextAlert() or popNextAlert()</li>
<li>confirm() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response. By default,
the callback returns true. Users may change this by supplying an implementation of DialogResponder.</li>
-<li>prompt() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response</li>
-<li>open() - opens a new window. A callback will be generated to any WebWindowListener registered with the client.
+<li>prompt() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response</li>
+<li>open() - opens a new window. A callback will be generated to any WebWindowListener registered with the client.</li>
</ul>
<h3>Navigator</h3>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -r1.183 -r1.184
--- release_notes.txt 9 Oct 2002 13:50:07 -0000 1.183
+++ release_notes.txt 9 Oct 2002 17:16:30 -0000 1.184
@@ -11,9 +11,11 @@
Revision History:
9-Oct-2002
+Acknowledgements:
+ Thanks to Richard Harris for adding stubs for various unimplemented JavaScript Window properties.
Additions:
- 1. Added support for the Window.opener property
- 2. Added support for the Window.name property for top-level frames
+ 1. Added support for the following JavaScript Window properties: frames, name, opener, top
+ 2. Added do-nothing stubs for the Window properties and functions: closed, close(), moveTo(), focus(), setTimeout()
8-Oct-2002
Acknowledgements:
Index: todo.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- todo.txt 30 Aug 2002 18:19:38 -0000 1.31
+++ todo.txt 9 Oct 2002 17:16:30 -0000 1.32
@@ -1,21 +1,27 @@
+High priority:
+o closing windows
+o better support for use with proxy server
+
Medium priority:
o Enable client code to write directly to the output stream of a message body request
o Provide customization for table to text
o Support optional tags which hide their contents (as in IFRAME, OBJECT, etc.)
o Check conformance with RFC 2109 - not currently sending $Version=1 string
-o Support IFRAME tag
-o Support _new frame tag
o Documentation, Documentation
JavaScript priorities:
+o Window.name for frames
+o Window.frames[]
+o Window.parent
+o Window.top
o Document.write - may required substantial parser rewrite
-o Navigator object
+
Possibles:
-o replace JTidy with a simpler custom parser
+o replace JTidy with a simpler custom parser or NekoHTML
Low priority:
-o history on web conversation
+o history on web window
o Support digest HTTP Authentication
|
|
From: Russell G. <rus...@us...> - 2002-10-09 17:16:34
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv20416/test/com/meterware/httpunit/javascript
Modified Files:
ScriptingTest.java
Log Message:
Added support for JavaScript frame properties
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- ScriptingTest.java 9 Oct 2002 13:50:10 -0000 1.33
+++ ScriptingTest.java 9 Oct 2002 17:16:31 -0000 1.34
@@ -311,6 +311,41 @@
}
+ public void testFrameProperties() throws Exception {
+ HttpUnitOptions.setExceptionsThrownOnScriptError( false );
+ defineWebPage( "Linker", "This is a trivial page with <a href=Target.html>one link</a>" );
+ defineResource( "Target.html", "<html><head><script language='JavaScript'>" +
+ "function show_properties() {" +
+ " alert( 'name=' + window.name );" +
+ " alert( 'top url=' + window.top.location );" +
+ " alert( '1st frame=' + top.frames[0].name );" +
+ " alert( '2nd frame=' + window.top.frames[1].name );" +
+ "}" +
+ "</script></head><body>" +
+ "<a href=# onclick='show_properties()'>show</a>" +
+ "</body></html>" );
+ defineWebPage( "Form", "This is a page with a simple form: " +
+ "<form action=submit><input name=name><input type=submit></form>" +
+ "<a href=Linker.html target=red>a link</a>");
+ defineResource( "Frames.html",
+ "<html><head><title>Initial</title></head>" +
+ "<frameset cols='20%,80%'>" +
+ " <frame src='Linker.html' name='red'>" +
+ " <frame src=Target.html name=blue>" +
+ "</frameset></html>" );
+
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/Frames.html" );
+ WebResponse blue = wc.getFrameContents( "blue" );
+ blue.getLinkWith( "show" ).click();
+
+ assertEquals( "1st alert", "name=blue", wc.popNextAlert() );
+ 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() );
+ }
+
+
public void testLocationProperty() throws Exception {
defineResource( "Target.html", "You made it!" );
defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
|
|
From: Russell G. <rus...@us...> - 2002-10-09 17:16:33
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv20416/src/com/meterware/httpunit
Modified Files:
WebClient.java WebResponse.java
Log Message:
Added support for JavaScript frame properties
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- WebClient.java 9 Oct 2002 13:50:08 -0000 1.38
+++ WebClient.java 9 Oct 2002 17:16:30 -0000 1.39
@@ -344,10 +344,11 @@
/**
- * Returns the next javascript alert and removes it from the queue.
+ * Returns the next javascript alert and removes it from the queue. If the queue is empty,
+ * will return an empty string.
*/
public String popNextAlert() {
- if (_alerts.isEmpty()) throw new IllegalStateException( "Tried to pop a non-existent alert" );
+ if (_alerts.isEmpty()) return "";
return (String) _alerts.removeFirst();
}
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- WebResponse.java 9 Oct 2002 13:50:08 -0000 1.84
+++ WebResponse.java 9 Oct 2002 17:16:30 -0000 1.85
@@ -555,6 +555,16 @@
}
+ public Scriptable[] getFrames() throws SAXException {
+ String[] names = getFrameNames();
+ Scriptable[] frames = new Scriptable[ names.length ];
+ for (int i = 0; i < frames.length; i++) {
+ frames[i] = getSubframeContents( names[i] ).getScriptableObject();
+ }
+ return frames;
+ }
+
+
public void load() throws SAXException {
runScript( getReceivedPage().getScripts() );
doEvent( getReceivedPage().getOnLoadEvent() );
@@ -581,7 +591,9 @@
**/
public Object get( String propertyName ) {
if (propertyName.equals( "name" )) {
- return getTarget().equals( WebRequest.TOP_FRAME ) ? _window.getName() : null;
+ return getTarget().equals( WebRequest.TOP_FRAME ) ? _window.getName() : getTarget();
+ } else if (propertyName.equalsIgnoreCase( "top" )) {
+ return _window.getFrameContents( WebRequest.TOP_FRAME ).getScriptableObject();
} else if (propertyName.equalsIgnoreCase( "location" )) {
return WebResponse.this._url.toExternalForm();
} else if (propertyName.equalsIgnoreCase( "opener" )) {
|
|
From: Russell G. <rus...@us...> - 2002-10-09 13:50:41
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv14198/src/com/meterware/httpunit
Modified Files:
HttpUnitOptions.java WebClient.java WebResponse.java
WebWindow.java
Log Message:
Added support for Window.opener and Window.name
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- HttpUnitOptions.java 8 Oct 2002 13:14:30 -0000 1.28
+++ HttpUnitOptions.java 9 Oct 2002 13:50:07 -0000 1.29
@@ -57,7 +57,7 @@
_acceptCookies = true;
setScriptEngineClassName( DEFAULT_SCRIPT_ENGINE_FACTORY );
setScriptingEnabled( true );
- _exceptionsThrownOnScriptError = true;
+ setExceptionsThrownOnScriptError( true );
}
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- WebClient.java 8 Oct 2002 17:55:49 -0000 1.37
+++ WebClient.java 9 Oct 2002 13:50:08 -0000 1.38
@@ -443,6 +443,16 @@
}
+ WebResponse openInNewWindow( WebRequest request, String windowName, WebResponse opener ) throws IOException, SAXException {
+ WebWindow window = new WebWindow( this, opener );
+ window.setName( windowName );
+ WebResponse response = window.getResponse( request );
+ _openWindows.add( window );
+ reportWindowOpened( window );
+ return response;
+ }
+
+
private WebWindow getTargetWindow( WebWindow requestWindow, String target ) {
return WebRequest.NEW_WINDOW.equalsIgnoreCase( target ) ? null : requestWindow;
}
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- WebResponse.java 9 Oct 2002 01:58:23 -0000 1.83
+++ WebResponse.java 9 Oct 2002 13:50:08 -0000 1.84
@@ -563,27 +563,16 @@
public Scriptable open( String name, String urlString, String features, boolean replace )
throws IOException, SAXException {
+ if (urlString == null || urlString.trim().length() == 0) urlString = "about:";
+ GetMethodWebRequest request = new GetMethodWebRequest( getURL(), urlString );
+
WebWindow[] windows = _client.getOpenWindows();
for (int i = 0; i < windows.length; i++) {
WebWindow window = windows[i];
- if (window.getName().equals( name )) return openInWindow( window, name, urlString, "_top" );
+ if (window.getName().equals( name )) return window.getResponse( request ).getScriptableObject();
}
- return openInWindow( _window, name, urlString, "_blank" );
- }
-
-
- private Scriptable openInWindow( WebWindow window, String name, String urlString, String target ) throws IOException, SAXException {
- try {
- if (urlString == null || urlString.trim().length() == 0) urlString = "about:";
- WebRequest request = new GetMethodWebRequest( getURL(), urlString, target );
- WebResponse response = window.getResponse( request );
- response._window.setName( name );
- return response.getScriptableObject();
- } catch (RuntimeException e) {
- e.printStackTrace();
- throw e;
- }
+ return _client.openInNewWindow( request, name, WebResponse.this ).getScriptableObject();
}
@@ -591,8 +580,12 @@
* Returns the value of the named property. Will return null if the property does not exist.
**/
public Object get( String propertyName ) {
- if (propertyName.equalsIgnoreCase( "location" )) {
+ if (propertyName.equals( "name" )) {
+ return getTarget().equals( WebRequest.TOP_FRAME ) ? _window.getName() : null;
+ } else if (propertyName.equalsIgnoreCase( "location" )) {
return WebResponse.this._url.toExternalForm();
+ } else if (propertyName.equalsIgnoreCase( "opener" )) {
+ return getTarget().equals( WebRequest.TOP_FRAME ) ? _window.getOpener().getScriptableObject() : null;
} else {
return super.get( propertyName );
}
@@ -604,7 +597,12 @@
* cannot accept the specified value.
**/
public void set( String propertyName, Object value ) {
- if (propertyName.equalsIgnoreCase( "location" )) {
+ if (propertyName.equals( "name" )) {
+ if (value == null) value = "";
+ if (getTarget().equals( WebRequest.TOP_FRAME )) {
+ _window.setName( value.toString() );
+ }
+ } else if (propertyName.equalsIgnoreCase( "location" )) {
try {
getWindow().getResponse( new GetMethodWebRequest( _url, value.toString(), _frameName ) );
} catch (IOException e) {
Index: WebWindow.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WebWindow.java 9 Oct 2002 01:58:23 -0000 1.4
+++ WebWindow.java 9 Oct 2002 13:50:08 -0000 1.5
@@ -41,6 +41,9 @@
/** The name of the window, set via JavaScript. **/
private String _name = "";
+ /** The web response containing the reference that opened this window **/
+ private WebResponse _opener;
+
public WebClient getClient() {
return _client;
@@ -57,6 +60,14 @@
/**
+ * Returns the web response that contained the script which opened this window.
+ */
+ public WebResponse getOpener() {
+ return _opener;
+ }
+
+
+ /**
* Submits a GET method request and returns a response.
* @exception SAXException thrown if there is an error parsing the retrieved page
**/
@@ -116,6 +127,12 @@
WebWindow( WebClient client ) {
_client = client;
_frameContents = new FrameHolder( _client, WebRequest.TOP_FRAME );
+ }
+
+
+ WebWindow( WebClient client, WebResponse opener ) {
+ this( client );
+ _opener = opener;
}
|
|
From: Russell G. <rus...@us...> - 2002-10-09 13:50:40
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv14198/doc
Modified Files:
Javascript-support.html release_notes.txt
Log Message:
Added support for Window.opener and Window.name
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Javascript-support.html 9 Oct 2002 01:58:22 -0000 1.20
+++ Javascript-support.html 9 Oct 2002 13:50:07 -0000 1.21
@@ -14,6 +14,8 @@
<li>navigator - the Navigator object</li>
<li>self - the Window itself</li>
<li>window - a synonym for self</li>
+<li>name - r/w the name of the window (top-level frames only)</li>
+<li>opener - r/o the window which opened this one (top-level frames only)</li>
</ul>
<h4>events</h4>
<ul>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -r1.182 -r1.183
--- release_notes.txt 9 Oct 2002 01:58:22 -0000 1.182
+++ release_notes.txt 9 Oct 2002 13:50:07 -0000 1.183
@@ -10,11 +10,17 @@
Revision History:
+ 9-Oct-2002
+Additions:
+ 1. Added support for the Window.opener property
+ 2. Added support for the Window.name property for top-level frames
+
8-Oct-2002
Acknowledgements:
Thanks to Richard Harris for adding support for the title attribute for links,
for adding the JavaScript Navigator.platform property,
- and for adding Javascript support for the Screen object.
+ for adding Javascript support for the Screen object,
+ for pointing out the value of retaining the same ScriptingEngine instance for a ScriptableDelegate.
Additions:
1. Links, forms, and images now have a readable title property.
@@ -25,6 +31,8 @@
Problems fixed:
1. When not using Latin-1 encoding, URL string characters *, _, and - were improperly being encoded
2. AuthorizationRequiredException was being thrown even when exceptions on error status was disabled
+ 3. Repeated requests for the same JavaScript domain objects returned new and different instances, thus
+ preventing identity tests.
4-Oct-2002
|
|
From: Russell G. <rus...@us...> - 2002-10-09 13:50:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv14198/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added support for Window.opener and Window.name
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- JavaScript.java 9 Oct 2002 01:58:23 -0000 1.27
+++ JavaScript.java 9 Oct 2002 13:50:08 -0000 1.28
@@ -252,11 +252,21 @@
/**
* Converts a scriptable delegate obtained from a subobject into the appropriate Rhino-compatible Scriptable.
- * This default implementation throws an exception.
**/
- Scriptable toScriptable( ScriptableDelegate delegate )
- throws PropertyException, NotAFunctionException, JavaScriptException, SAXException {
- throw new UnsupportedOperationException();
+ final Scriptable toScriptable( ScriptableDelegate delegate )
+ throws PropertyException, JavaScriptException, NotAFunctionException, SAXException {
+ if (delegate.getScriptEngine() instanceof Scriptable) {
+ return (Scriptable) delegate.getScriptEngine();
+ } else {
+ JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, getScriptableClassName( delegate ) );
+ element.initialize( this, delegate );
+ return element;
+ }
+ }
+
+
+ protected String getScriptableClassName( ScriptableDelegate delegate ) {
+ throw new IllegalArgumentException( "Unknown ScriptableDelegate class: " + delegate.getClass() );
}
}
@@ -341,15 +351,8 @@
}
- Scriptable toScriptable( ScriptableDelegate delegate )
- throws PropertyException, JavaScriptException, NotAFunctionException, SAXException {
- if (!(delegate instanceof WebResponse.Scriptable)) {
- return null;
- } else {
- JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, "Window" );
- element.initialize( this, delegate );
- return element;
- }
+ protected String getScriptableClassName( ScriptableDelegate delegate ) {
+ return (delegate instanceof WebResponse.Scriptable) ? "Window" : super.getScriptableClassName( delegate );
}
@@ -433,15 +436,7 @@
}
- Scriptable toScriptable( com.meterware.httpunit.scripting.ScriptableDelegate delegate )
- throws PropertyException, JavaScriptException, NotAFunctionException, SAXException {
- JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, getScriptableClassName( delegate ) );
- element.initialize( this, delegate );
- return element;
- }
-
-
- private String getScriptableClassName( ScriptableDelegate delegate ) {
+ protected String getScriptableClassName( ScriptableDelegate delegate ) {
if (delegate instanceof WebForm.Scriptable) {
return "Form";
} else if (delegate instanceof WebLink.Scriptable) {
@@ -449,7 +444,7 @@
} else if (delegate instanceof WebImage.Scriptable) {
return "Image";
} else {
- throw new IllegalArgumentException( "Unknown ScriptableDelegate class: " + delegate.getClass() );
+ return super.getScriptableClassName( delegate );
}
}
@@ -633,11 +628,8 @@
}
- Scriptable toScriptable( ScriptableDelegate delegate )
- throws PropertyException, NotAFunctionException, JavaScriptException, SAXException {
- final Control control = (Control) Context.getCurrentContext().newObject( this, "Control" );
- control.initialize( this, delegate );
- return control;
+ protected String getScriptableClassName( ScriptableDelegate delegate ) {
+ return "Control";
}
@@ -715,20 +707,8 @@
}
- Scriptable toScriptable( ScriptableDelegate delegate )
- throws PropertyException, JavaScriptException, NotAFunctionException, SAXException {
- JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, getScriptableClassName( delegate ) );
- element.initialize( this, delegate );
- return element;
- }
-
-
- private String getScriptableClassName( ScriptableDelegate delegate ) {
- if (delegate instanceof SelectionOptions) {
- return "Options";
- } else {
- throw new IllegalArgumentException( "Unknown ScriptableDelegate class: " + delegate.getClass() );
- }
+ protected String getScriptableClassName( ScriptableDelegate delegate ) {
+ return (delegate instanceof SelectionOptions) ? "Options" : super.getScriptableClassName( delegate );
}
}
@@ -767,11 +747,8 @@
}
- Scriptable toScriptable( ScriptableDelegate delegate )
- throws PropertyException, JavaScriptException, NotAFunctionException, SAXException {
- JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, "Option" );
- element.initialize( this, delegate );
- return element;
+ protected String getScriptableClassName( ScriptableDelegate delegate ) {
+ return "Option";
}
}
|
|
From: Russell G. <rus...@us...> - 2002-10-09 13:50:14
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv14198/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java ScriptingTest.java
Log Message:
Added support for Window.opener and Window.name
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DocumentScriptingTest.java 9 Oct 2002 01:58:23 -0000 1.1
+++ DocumentScriptingTest.java 9 Oct 2002 13:50:10 -0000 1.2
@@ -99,6 +99,26 @@
}
+ public void testJavaScriptObjectIdentity() throws Exception {
+ defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
+ "function compareLinks() { " +
+ " if (document.reallink == document.links['reallink']) {" +
+ " alert( 'they are the same' );" +
+ " } else {" +
+ " alert( 'they are different' );" +
+ " }" +
+ "}" +
+ "</script></head>" +
+ "<body onLoad='compareLinks()'>" +
+ "<a href='something' name='reallink'>first</a>" +
+ "<a href='else'>second</a>" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "Alert message", "they are the same", wc.popNextAlert() );
+ }
+
+
public void testCaseSensitiveNames() throws Exception {
defineResource( "OnCommand.html", "<html><head></head>" +
"<body>" +
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- ScriptingTest.java 9 Oct 2002 01:58:23 -0000 1.32
+++ ScriptingTest.java 9 Oct 2002 13:50:10 -0000 1.33
@@ -288,6 +288,29 @@
}
+ public void testOpenedWindowProperties() throws Exception {
+ defineResource( "Target.html", "<html><head><script language='JavaScript'>" +
+ "function show_properties() {" +
+ " alert( 'name=' + window.name );" +
+ " alert( 'opener name=' + window.opener.name );" +
+ "}" +
+ "</script></head><body onload='show_properties()'>" +
+ "</body></html>" );
+ defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
+ "<body onload='window.name=\"main\"'>" +
+ "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Target.html' );\">go</a>" +
+ "</body></html>" );
+ final ArrayList windowsOpened = new ArrayList();
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "main window name", "main", wc.getMainWindow().getName() );
+ response.getLinks()[0].click();
+
+ assertEquals( "1st alert", "name=sample", wc.popNextAlert() );
+ assertEquals( "2nd alert", "opener name=main", wc.popNextAlert() );
+ }
+
+
public void testLocationProperty() throws Exception {
defineResource( "Target.html", "You made it!" );
defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
|
|
From: Russell G. <rus...@us...> - 2002-10-09 13:50:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting
In directory usw-pr-cvs1:/tmp/cvs-serv14198/src/com/meterware/httpunit/scripting
Modified Files:
ScriptableDelegate.java
Log Message:
Added support for Window.opener and Window.name
Index: ScriptableDelegate.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting/ScriptableDelegate.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ScriptableDelegate.java 23 Aug 2002 19:33:13 -0000 1.3
+++ ScriptableDelegate.java 9 Oct 2002 13:50:10 -0000 1.4
@@ -96,7 +96,7 @@
}
- private ScriptingEngine getScriptEngine() {
+ public ScriptingEngine getScriptEngine() {
return _scriptEngine != null ? _scriptEngine : NULL_SCRIPT_ENGINE;
}
|
|
From: Russell G. <rus...@us...> - 2002-10-09 01:58:27
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv8505/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Added JavaScript support for Window.open
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- JavaScript.java 8 Oct 2002 14:36:00 -0000 1.26
+++ JavaScript.java 9 Oct 2002 01:58:23 -0000 1.27
@@ -330,8 +330,26 @@
}
- Scriptable toScriptable( ScriptableDelegate delegate ) {
- return null;
+ public Window jsFunction_open( String name, Object url, String features, boolean replace )
+ throws PropertyException, JavaScriptException, NotAFunctionException, IOException, SAXException {
+ return (Window) toScriptable( getDelegate().open( name, toStringIfNotUndefined( url ), features, replace ) );
+ }
+
+
+ private String toStringIfNotUndefined( Object object ) {
+ return (object == null || Undefined.instance.equals( object )) ? null : object.toString();
+ }
+
+
+ Scriptable toScriptable( ScriptableDelegate delegate )
+ throws PropertyException, JavaScriptException, NotAFunctionException, SAXException {
+ if (!(delegate instanceof WebResponse.Scriptable)) {
+ return null;
+ } else {
+ JavaScriptEngine element = (JavaScriptEngine) Context.getCurrentContext().newObject( this, "Window" );
+ element.initialize( this, delegate );
+ return element;
+ }
}
|
|
From: Russell G. <rus...@us...> - 2002-10-09 01:58:27
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv8505/doc
Modified Files:
Javascript-support.html release_notes.txt
Log Message:
Added JavaScript support for Window.open
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Javascript-support.html 8 Oct 2002 14:36:00 -0000 1.19
+++ Javascript-support.html 9 Oct 2002 01:58:22 -0000 1.20
@@ -25,6 +25,7 @@
<li>confirm() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response. By default,
the callback returns true. Users may change this by supplying an implementation of DialogResponder.</li>
<li>prompt() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response</li>
+<li>open() - opens a new window. A callback will be generated to any WebWindowListener registered with the client.
</ul>
<h3>Navigator</h3>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -r1.181 -r1.182
--- release_notes.txt 8 Oct 2002 17:55:49 -0000 1.181
+++ release_notes.txt 9 Oct 2002 01:58:22 -0000 1.182
@@ -20,6 +20,7 @@
1. Links, forms, and images now have a readable title property.
2. The navigator object now supports the readable 'platform' property.
3. The screen object is now supported, with properties availHeight and availWidth
+ 4. The Window.open function is now supported
Problems fixed:
1. When not using Latin-1 encoding, URL string characters *, _, and - were improperly being encoded
|
|
From: Russell G. <rus...@us...> - 2002-10-09 01:58:26
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv8505/test/com/meterware/httpunit/javascript
Modified Files:
JavaScriptTestSuite.java ScriptingTest.java
Added Files:
DocumentScriptingTest.java
Log Message:
Added JavaScript support for Window.open
***** Error reading new file[Errno 2] No such file or directory: 'DocumentScriptingTest.java'
Index: JavaScriptTestSuite.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/JavaScriptTestSuite.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JavaScriptTestSuite.java 16 Aug 2002 18:52:51 -0000 1.1
+++ JavaScriptTestSuite.java 9 Oct 2002 01:58:23 -0000 1.2
@@ -38,6 +38,7 @@
public static Test suite() {
TestSuite result = new TestSuite();
result.addTest( ScriptingTest.suite() );
+ result.addTest( DocumentScriptingTest.suite() );
result.addTest( FormScriptingTest.suite() );
return result;
}
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- ScriptingTest.java 8 Oct 2002 17:45:15 -0000 1.31
+++ ScriptingTest.java 9 Oct 2002 01:58:23 -0000 1.32
@@ -24,6 +24,8 @@
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import java.util.ArrayList;
+
/**
*
@@ -220,12 +222,69 @@
}
- public void testDocumentTitle() throws Exception {
- defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
- "<body onLoad='alert(\"Window title is \" + document.title)'></body>" );
- WebConversation wc = new WebConversation();
+ public void testWindowOpen() throws Exception {
+ defineResource( "Target.html", "You made it!" );
+ defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
+ "<body>" +
+ "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Target.html' );\">go</a>" +
+ "</body></html>" );
+ final ArrayList windowsOpened = new ArrayList();
+ WebConversation wc = new WebConversation();
+ wc.addWindowListener( new WebWindowListener() {
+ public void windowOpened( WebClient client, WebWindow window ) { windowsOpened.add( window ); }
+ public void windowClosed( WebClient client, WebWindow window ) {}
+ } );
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ response.getLinks()[0].click();
+
+ assertFalse( "No window opened", windowsOpened.isEmpty() );
+ assertEquals( "New window message", "You made it!", ((WebWindow) windowsOpened.get( 0 )).getCurrentPage().getText() );
+ assertEquals( "New window name", "sample", ((WebWindow) windowsOpened.get( 0 )).getName() );
+ }
+
+
+ public void testWindowOpenNoContents() throws Exception {
+ defineResource( "Target.html", "You made it!" );
+ defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
+ "<body>" +
+ "<a href='#' onClick=\"window.open( 'sample' );\">go</a>" +
+ "</body></html>" );
+ final ArrayList windowsOpened = new ArrayList();
+ WebConversation wc = new WebConversation();
+ wc.addWindowListener( new WebWindowListener() {
+ public void windowOpened( WebClient client, WebWindow window ) { windowsOpened.add( window ); }
+ public void windowClosed( WebClient client, WebWindow window ) {}
+ } );
WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- assertEquals( "Alert message", "Window title is Amazing!", wc.popNextAlert() );
+ response.getLinks()[0].click();
+
+ assertFalse( "No window opened", windowsOpened.isEmpty() );
+ assertEquals( "New window message", "", ((WebWindow) windowsOpened.get( 0 )).getCurrentPage().getText() );
+ assertEquals( "New window name", "sample", ((WebWindow) windowsOpened.get( 0 )).getName() );
+ }
+
+
+ public void testWindowReopen() throws Exception {
+ defineResource( "Target.html", "You made it!" );
+ defineResource( "Revise.html", "You changed it!" );
+ defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
+ "<body>" +
+ "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Target.html' );\">go</a>" +
+ "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Revise.html' );\">go</a>" +
+ "</body></html>" );
+ final ArrayList windowsOpened = new ArrayList();
+ WebConversation wc = new WebConversation();
+ wc.addWindowListener( new WebWindowListener() {
+ public void windowOpened( WebClient client, WebWindow window ) { windowsOpened.add( window ); }
+ public void windowClosed( WebClient client, WebWindow window ) {}
+ } );
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ response.getLinks()[0].click();
+ assertEquals( "New window message", "You made it!", ((WebWindow) windowsOpened.get( 0 )).getCurrentPage().getText() );
+ response.getLinks()[1].click();
+
+ assertEquals( "Number of window openings", 1, windowsOpened.size() );
+ assertEquals( "Changed window message", "You changed it!", ((WebWindow) windowsOpened.get( 0 )).getCurrentPage().getText() );
}
@@ -251,106 +310,6 @@
}
- public void testDocumentFindForms() throws Exception {
- defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
- "function getFound( object ) {" +
- " return (object == null) ? \"did not find \" : \"found \";" +
- " }" +
- "function viewForms() { " +
- " alert( \"found \" + document.forms.length + \" form(s)\" );" +
- " alert( getFound( document.realform ) + \"form 'realform'\" );" +
- " alert( getFound( document.forms[\"realform\"] ) + \"form 'forms[\'realform\']'\" );" +
- " alert( getFound( document.noform ) + \"form 'noform'\" ); }" +
- "</script></head>" +
- "<body onLoad='viewForms()'>" +
- "<form name='realform'></form>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- assertEquals( "Alert message", "found 1 form(s)", wc.popNextAlert() );
- assertEquals( "Alert message", "found form 'realform'", wc.popNextAlert() );
- assertEquals( "Alert message", "found form 'forms[\'realform\']'", wc.popNextAlert() );
- assertEquals( "Alert message", "did not find form 'noform'", wc.popNextAlert() );
- assertNull( "Alert should have been removed", wc.getNextAlert() );
- }
-
-
- public void testDocumentFindLinks() throws Exception {
- defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
- "function getFound( object ) {" +
- " return (object == null) ? \"did not find \" : \"found \";" +
- " }" +
- "function viewLinks() { " +
- " alert( \"found \" + document.links.length + \" link(s)\" );" +
- " alert( getFound( document.reallink ) + \"link 'reallink'\" );" +
- " alert( getFound( document.links[\"reallink\"] ) + \"link 'links[reallink]'\" );" +
- " alert( getFound( document.nolink ) + \"link 'nolink'\" );" +
- "}" +
- "</script></head>" +
- "<body onLoad='viewLinks()'>" +
- "<a href='something' name='reallink'>first</a>" +
- "<a href='else'>second</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- assertEquals( "Alert message", "found 2 link(s)", wc.popNextAlert() );
- assertEquals( "Alert message", "found link 'reallink'", wc.popNextAlert() );
- assertEquals( "Alert message", "found link 'links[reallink]'", wc.popNextAlert() );
- assertEquals( "Alert message", "did not find link 'nolink'", wc.popNextAlert() );
- assertNull( "Alert should have been removed", wc.getNextAlert() );
- }
-
-
- public void testCaseSensitiveNames() throws Exception {
- defineResource( "OnCommand.html", "<html><head></head>" +
- "<body>" +
- "<form name='item' action='run'></form>" +
- "<a name='Item' href='sample.html'></a>" +
- "<a href='#' name='first' onMouseOver='alert( document.item.action );'>1</a>" +
- "<a href='#' name='second' onMouseOver='alert( document.Item.href );'>2</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- WebForm form = response.getFormWithName( "realform" );
- response.getLinkWithName( "first" ).mouseOver();
- assertEquals( "form action", "run", wc.popNextAlert() );
- response.getLinkWithName( "second" ).mouseOver();
- assertEquals( "link href", getHostPath() + "/sample.html", wc.popNextAlert() );
- }
-
-
- public void testLinkMouseOverEvent() throws Exception {
- defineResource( "OnCommand.html", "<html><head></head>" +
- "<body>" +
- "<form name='realform'><input name='color' value='blue'></form>" +
- "<a href='#' onMouseOver=\"document.realform.color.value='green';return false;\">green</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- WebForm form = response.getFormWithName( "realform" );
- WebLink link = response.getLinks()[0];
- assertEquals( "initial parameter value", "blue", form.getParameterValue( "color" ) );
- link.mouseOver();
- assertEquals( "changed parameter value", "green", form.getParameterValue( "color" ) );
- }
-
-
- public void testLinkClickEvent() throws Exception {
- defineResource( "OnCommand.html", "<html><head></head>" +
- "<body>" +
- "<form name='realform'><input name='color' value='blue'></form>" +
- "<a href='nothing.html' onClick=\"JavaScript:document.realform.color.value='green';return false;\">green</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- WebForm form = response.getFormWithName( "realform" );
- WebLink link = response.getLinks()[0];
- assertEquals( "initial parameter value", "blue", form.getParameterValue( "color" ) );
- link.click();
- assertEquals( "changed parameter value", "green", form.getParameterValue( "color" ) );
- }
-
-
public void testScriptDisabled() throws Exception {
HttpUnitOptions.setScriptingEnabled( false );
defineResource( "nothing.html", "Should get here" );
@@ -367,109 +326,6 @@
link.click();
assertEquals( "unchanged parameter value", "blue", form.getParameterValue( "color" ) );
assertEquals( "Expected result", "Should get here", wc.getCurrentPage().getText() );
- }
-
-
- public void testHashDestinationOnEvent() throws Exception {
- defineResource( "OnCommand.html", "<html><head></head>" +
- "<body>" +
- "<form name='realform'><input name='color' value='blue'></form>" +
- "<a href='#' onClick=\"document.realform.color.value='green';\">green</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- WebForm form = response.getFormWithName( "realform" );
- WebLink link = response.getLinks()[0];
- assertEquals( "initial parameter value", "blue", form.getParameterValue( "color" ) );
- response = link.click();
- assertEquals( "changed parameter value", "green", response.getFormWithName( "realform" ).getParameterValue( "color" ) );
- }
-
-
- public void testLinkProperties() throws Exception {
- defineResource( "somewhere.html?with=values", "you made it!" );
- defineResource( "OnCommand.html", "<html><head></head>" +
- "<body>" +
- "<a name=target href='nowhere.html'>" +
- "<a name=control href='#' onClick=\"document.target.href='somewhere.html?with=values';\">green</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- WebLink link = response.getLinkWithName( "target" );
- assertEquals( "initial value", "nowhere.html", link.getURLString() );
- response.getLinkWithName( "control" ).click();
- assertEquals( "changed reference", getHostPath() + "/somewhere.html?with=values", link.getRequest().getURL().toExternalForm() );
- response = link.click();
- assertEquals( "New page", "you made it!", response.getText() );
- }
-
-
- public void testLinkIndexes() throws Exception {
- defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
- "function alertLinks() { " +
- " for (var i=0; i < document.links.length; i++) {" +
- " alert( document.links[i].href );" +
- " }" +
- "}" +
- "</script></head>" +
- "<body onLoad='alertLinks()'>" +
- "<a href='demo.html'>green</a>" +
- "<map name='map1'>" +
- " <area href='guide.html' alt='Guide' shape='rect' coords='0,0,118,28'>" +
- " <area href='search.html' alt='Search' shape='circle' coords='184,200,60'>" +
- "</map>" +
- "<a href='sample.html'>green</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- assertEquals( "Alert message", getHostPath() + "/demo.html", wc.popNextAlert() );
- assertEquals( "Alert message", getHostPath() + "/guide.html", wc.popNextAlert() );
- assertEquals( "Alert message", getHostPath() + "/search.html", wc.popNextAlert() );
- assertEquals( "Alert message", getHostPath() + "/sample.html", wc.popNextAlert() );
- assertNull( "Alert should have been removed", wc.getNextAlert() );
- }
-
-
- public void testDocumentFindImages() throws Exception {
- defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
- "function getFound( object ) {\n" +
- " return (object == null) ? \"did not find \" : \"found \";\n" +
- " }\n" +
- "function viewImages() { \n" +
- " alert( \"found \" + document.images.length + \" images(s)\" );\n" +
- " alert( getFound( document.realimage ) + \"image 'realimage'\" )\n;" +
- " alert( getFound( document.images['realimage'] ) + \"image 'images[realimage]'\" )\n;" +
- " alert( getFound( document.noimage ) + \"image 'noimage'\" );\n" +
- " alert( '2nd image is ' + document.images[1].src ); }\n" +
- "</script></head>\n" +
- "<body onLoad='viewImages()'>\n" +
- "<img name='realimage' src='pict1.gif'>\n" +
- "<img name='2ndimage' src='pict2.gif'>\n" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- assertEquals( "Alert message", "found 2 images(s)", wc.popNextAlert() );
- assertEquals( "Alert message", "found image 'realimage'", wc.popNextAlert() );
- assertEquals( "Alert message", "found image 'images[realimage]'", wc.popNextAlert() );
- assertEquals( "Alert message", "did not find image 'noimage'", wc.popNextAlert() );
- assertEquals( "Alert message", "2nd image is pict2.gif", wc.popNextAlert() );
- assertNull( "Alert should have been removed", wc.getNextAlert() );
- }
-
-
- public void testImageSwap() throws Exception {
- defineResource( "OnCommand.html", "<html><head></head>" +
- "<body>" +
- "<img name='theImage' src='initial.gif'>" +
- "<a href='#' onMouseOver=\"document.theImage.src='new.jpg';\">green</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- WebImage image = response.getImageWithName( "theImage" );
- WebLink link = response.getLinks()[0];
- assertEquals( "initial image source", "initial.gif", image.getSource() );
- link.mouseOver();
- assertEquals( "changed image source", "new.jpg", image.getSource() );
}
|
|
From: Russell G. <rus...@us...> - 2002-10-09 01:58:26
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv8505/src/com/meterware/httpunit
Modified Files:
WebResponse.java WebWindow.java
Log Message:
Added JavaScript support for Window.open
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- WebResponse.java 4 Oct 2002 02:16:00 -0000 1.82
+++ WebResponse.java 9 Oct 2002 01:58:23 -0000 1.83
@@ -546,7 +546,7 @@
public ClientProperties getClientProperties() {
- return _client.getClientProperties();
+ return _client == null ? ClientProperties.getDefaultProperties() : _client.getClientProperties();
}
@@ -561,6 +561,32 @@
}
+ public Scriptable open( String name, String urlString, String features, boolean replace )
+ throws IOException, SAXException {
+ WebWindow[] windows = _client.getOpenWindows();
+ for (int i = 0; i < windows.length; i++) {
+ WebWindow window = windows[i];
+ if (window.getName().equals( name )) return openInWindow( window, name, urlString, "_top" );
+ }
+
+ return openInWindow( _window, name, urlString, "_blank" );
+ }
+
+
+ private Scriptable openInWindow( WebWindow window, String name, String urlString, String target ) throws IOException, SAXException {
+ try {
+ if (urlString == null || urlString.trim().length() == 0) urlString = "about:";
+ WebRequest request = new GetMethodWebRequest( getURL(), urlString, target );
+ WebResponse response = window.getResponse( request );
+ response._window.setName( name );
+ return response.getScriptableObject();
+ } catch (RuntimeException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+
/**
* Returns the value of the named property. Will return null if the property does not exist.
**/
@@ -668,7 +694,7 @@
//------------------------------------------ package members ------------------------------------------------
- final static String BLANK_HTML = "<html><head><title>Blank</title></head><body></body></html>";
+ final static String BLANK_HTML = "";
final static WebResponse BLANK_RESPONSE = new DefaultWebResponse( BLANK_HTML );
Index: WebWindow.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WebWindow.java 4 Oct 2002 15:19:25 -0000 1.3
+++ WebWindow.java 9 Oct 2002 01:58:23 -0000 1.4
@@ -38,6 +38,23 @@
/** A map of frame names to current contents. **/
private FrameHolder _frameContents;
+ /** The name of the window, set via JavaScript. **/
+ private String _name = "";
+
+
+ public WebClient getClient() {
+ return _client;
+ }
+
+
+ /**
+ * Returns the name of this window. Windows created through normal HTML or browser commands have empty names,
+ * but JavaScript can set the name. A name may be used as a target for a request.
+ */
+ public String getName() {
+ return _name;
+ }
+
/**
* Submits a GET method request and returns a response.
@@ -64,9 +81,7 @@
public WebResponse getResponse( WebRequest request ) throws MalformedURLException, IOException, SAXException {
WebResponse response = _client.getResourceForWindow( request, this );
- if (response != null) updateWindow( request.getTarget(), response );
-
- return getFrameContents( request.getTarget() );
+ return response == null ? null : updateWindow( request.getTarget(), response );
}
@@ -108,15 +123,16 @@
* Updates this web client based on a received response. This includes updating
* cookies and frames.
**/
- void updateWindow( String requestTarget, WebResponse response ) throws MalformedURLException, IOException, SAXException {
- _client.updateClient( response );
+ WebResponse updateWindow( String requestTarget, WebResponse response ) throws MalformedURLException, IOException, SAXException {
+ _client.updateClient( response );
if (HttpUnitOptions.getAutoRefresh() && response.getRefreshRequest() != null) {
- getResponse( response.getRefreshRequest() );
+ return getResponse( response.getRefreshRequest() );
} else if (shouldFollowRedirect( response )) {
delay( HttpUnitOptions.getRedirectDelay() );
- getResponse( new RedirectWebRequest( response ) );
+ return getResponse( new RedirectWebRequest( response ) );
} else {
_client.updateFrameContents( this, requestTarget, response );
+ return response;
}
}
@@ -136,8 +152,8 @@
}
- public WebClient getClient() {
- return _client;
+ void setName( String name ) {
+ _name = name;
}
|
|
From: Russell G. <rus...@us...> - 2002-10-08 17:55:52
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv988/src/com/meterware/httpunit
Modified Files:
WebClient.java
Log Message:
don't throw authorization required exception if disabled
Index: WebClient.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- WebClient.java 4 Oct 2002 15:19:25 -0000 1.36
+++ WebClient.java 8 Oct 2002 17:55:49 -0000 1.37
@@ -506,16 +506,16 @@
* Examines the headers in the response and throws an exception if appropriate.
**/
private void validateHeaders( WebResponse response ) throws HttpException, IOException {
+ if (!getExceptionsThrownOnErrorStatus()) return;
+
if (response.getHeaderField( "WWW-Authenticate" ) != null) {
throw new AuthorizationRequiredException( response.getHeaderField( "WWW-Authenticate" ) );
- } else if (getExceptionsThrownOnErrorStatus()) {
- if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
- throw new HttpInternalErrorException( response.getURL() );
- } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
- throw new HttpNotFoundException( response.getResponseMessage(), response.getURL() );
- } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) {
- throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() );
- }
+ } else if (response.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
+ throw new HttpInternalErrorException( response.getURL() );
+ } else if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new HttpNotFoundException( response.getResponseMessage(), response.getURL() );
+ } else if (response.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) {
+ throw new HttpException( response.getResponseCode(), response.getResponseMessage(), response.getURL() );
}
}
|
|
From: Russell G. <rus...@us...> - 2002-10-08 17:55:52
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv988/doc
Modified Files:
release_notes.txt
Log Message:
don't throw authorization required exception if disabled
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -r1.180 -r1.181
--- release_notes.txt 8 Oct 2002 17:45:11 -0000 1.180
+++ release_notes.txt 8 Oct 2002 17:55:49 -0000 1.181
@@ -23,6 +23,7 @@
Problems fixed:
1. When not using Latin-1 encoding, URL string characters *, _, and - were improperly being encoded
+ 2. AuthorizationRequiredException was being thrown even when exceptions on error status was disabled
4-Oct-2002
|
|
From: Russell G. <rus...@us...> - 2002-10-08 17:45:51
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv29043/test/com/meterware/httpunit
Modified Files:
FormSubmitTest.java
Log Message:
add test for multiple script hiding comments
Index: FormSubmitTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/FormSubmitTest.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- FormSubmitTest.java 5 Sep 2002 14:46:56 -0000 1.26
+++ FormSubmitTest.java 8 Oct 2002 17:45:13 -0000 1.27
@@ -29,6 +29,10 @@
import java.util.StringTokenizer;
import java.util.Vector;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import com.meterware.pseudoserver.PseudoServlet;
+import com.meterware.pseudoserver.WebResource;
/**
@@ -484,6 +488,26 @@
req.setParameter( "aTextField", "test" );
assertEquals( getHostPath() + "/abc/go?size=3&time=now",
req.getURL().toExternalForm() );
+ }
+
+
+ public void testPostParameterEncoding() throws Exception {
+ defineWebPage( "abc/form", "<form name=\"test\" method='POST' action='/doit'>" +
+ " <input type='text' name='text_field-name*'>" +
+ " <input type='submit' name='apply' value='Apply'>" +
+ "</form>" );
+ setResourceCharSet( "abc/form.html", "iso-8859-3", true );
+ defineResource( "doit", new PseudoServlet() {
+ public WebResource getPostResponse() throws IOException {
+ return new WebResource( new String( getBody() ) );
+ }
+ } );
+
+ WebResponse wr = _wc.getResponse( getHostPath() + "/abc/form.html" );
+ WebForm form = wr.getForms()[0];
+ form.setParameter( "text_field-name*", "a value" );
+ WebResponse response = form.submit();
+ assertEquals( "posted parameters", "text_field-name*=a+value&apply=Apply", response.getText() );
}
|
|
From: Russell G. <rus...@us...> - 2002-10-08 17:45:46
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv29043/src/com/meterware/httpunit
Modified Files:
WebRequest.java
Log Message:
add test for multiple script hiding comments
Index: WebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- WebRequest.java 4 Oct 2002 00:40:28 -0000 1.49
+++ WebRequest.java 8 Oct 2002 17:45:12 -0000 1.50
@@ -586,7 +586,8 @@
result.append( '+' );
} else if ((candidate >= 'A' && candidate <= 'Z') ||
(candidate >= 'a' && candidate <= 'z') ||
- (candidate == '.') ||
+ (candidate == '.') || (candidate == '-' ) ||
+ (candidate == '*') || (candidate == '_') ||
(candidate >= '0' && candidate <= '9')) {
result.append( (char) rawBytes[i] );
} else if (candidate < 16) {
|
|
From: Russell G. <rus...@us...> - 2002-10-08 17:45:46
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv29043/doc
Modified Files:
release_notes.txt
Log Message:
add test for multiple script hiding comments
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -r1.179 -r1.180
--- release_notes.txt 8 Oct 2002 14:36:00 -0000 1.179
+++ release_notes.txt 8 Oct 2002 17:45:11 -0000 1.180
@@ -21,6 +21,9 @@
2. The navigator object now supports the readable 'platform' property.
3. The screen object is now supported, with properties availHeight and availWidth
+Problems fixed:
+ 1. When not using Latin-1 encoding, URL string characters *, _, and - were improperly being encoded
+
4-Oct-2002
Additions:
|
|
From: Russell G. <rus...@us...> - 2002-10-08 17:45:26
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv29043/test/com/meterware/httpunit/javascript
Modified Files:
ScriptingTest.java
Log Message:
add test for multiple script hiding comments
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ScriptingTest.java 8 Oct 2002 14:36:00 -0000 1.30
+++ ScriptingTest.java 8 Oct 2002 17:45:15 -0000 1.31
@@ -196,9 +196,13 @@
defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
"<!-- hide this\n" +
"function sayCheese() { alert( \"Cheese!\" ); }" +
- "// end hiding -->" +
+ "// end hiding -->\n" +
"</script></head>" +
- "<body onLoad='sayCheese()'></body>" );
+ "<body'><script language='JavaScript'>\n" +
+ "<!-- hide this\n" +
+ "sayCheese();" +
+ "// end hiding -->" +
+ "</script></body></html>" );
WebConversation wc = new WebConversation();
WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "Cheese!", wc.popNextAlert() );
|
|
From: Russell G. <rus...@us...> - 2002-10-08 14:36:04
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv11174/src/com/meterware/httpunit
Modified Files:
ClientProperties.java
Log Message:
from Richard Harris: added support for the JavaScript screen object
Index: ClientProperties.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ClientProperties.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ClientProperties.java 8 Oct 2002 14:01:10 -0000 1.2
+++ ClientProperties.java 8 Oct 2002 14:36:00 -0000 1.3
@@ -100,6 +100,35 @@
}
+ /**
+ * A shortcut for setting both availableScreenWidth and availableScreenHeight at one time.
+ */
+ public void setAvailableScreenSize( int width, int height ) {
+ _availWidth = width;
+ _availHeight = height;
+ }
+
+
+ public int getAvailableScreenWidth() {
+ return _availWidth;
+ }
+
+
+ public void setAvailableScreenWidth( int availWidth ) {
+ _availWidth = availWidth;
+ }
+
+
+ public int getAvailHeight() {
+ return _availHeight;
+ }
+
+
+ public void setAvailHeight( int availHeight ) {
+ _availHeight = availHeight;
+ }
+
+
static ClientProperties cloneProperties() {
return new ClientProperties( getDefaultProperties() );
}
@@ -110,6 +139,8 @@
private String _applicationVersion = "1.4";
private String _userAgent;
private String _platform = "Java";
+ private int _availWidth = 800;
+ private int _availHeight = 600;
private static ClientProperties _defaultProperties = new ClientProperties();
|
|
From: Russell G. <rus...@us...> - 2002-10-08 14:36:04
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv11174/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
from Richard Harris: added support for the JavaScript screen object
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- JavaScript.java 8 Oct 2002 14:01:10 -0000 1.25
+++ JavaScript.java 8 Oct 2002 14:36:00 -0000 1.26
@@ -19,12 +19,7 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import com.meterware.httpunit.HTMLPage;
-import com.meterware.httpunit.WebForm;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.httpunit.WebLink;
-import com.meterware.httpunit.WebImage;
-import com.meterware.httpunit.ScriptException;
+import com.meterware.httpunit.*;
import com.meterware.httpunit.scripting.ScriptingEngine;
import com.meterware.httpunit.scripting.ScriptableDelegate;
@@ -94,6 +89,7 @@
ScriptableObject.defineClass( scope, Window.class );
ScriptableObject.defineClass( scope, Document.class );
ScriptableObject.defineClass( scope, Navigator.class );
+ ScriptableObject.defineClass( scope, Screen.class );
ScriptableObject.defineClass( scope, Link.class );
ScriptableObject.defineClass( scope, Form.class );
ScriptableObject.defineClass( scope, Control.class );
@@ -270,6 +266,7 @@
private Document _document;
private Navigator _navigator;
+ private Screen _screen;
public String getClassName() {
@@ -297,6 +294,11 @@
}
+ public Screen jsGet_screen() {
+ return _screen;
+ }
+
+
void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable )
throws JavaScriptException, NotAFunctionException, PropertyException, SAXException {
super.initialize( parent, scriptable );
@@ -304,7 +306,10 @@
_document.initialize( this, getDelegate().getDocument() );
_navigator = (Navigator) Context.getCurrentContext().newObject( this, "Navigator" );
- _navigator.initialize( this, getDelegate() );
+ _navigator.setClientProperties( getDelegate().getClientProperties() );
+
+ _screen = (Screen) Context.getCurrentContext().newObject( this, "Screen" );
+ _screen.setClientProperties( getDelegate().getClientProperties() );
getDelegate().load();
}
@@ -440,40 +445,40 @@
static public class Navigator extends JavaScriptEngine {
+ private ClientProperties _clientProperties;
+
public String getClassName() {
return "Navigator";
}
- void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable )
- throws JavaScriptException, NotAFunctionException, PropertyException, SAXException {
- _scriptable = scriptable;
- if (parent != null) setParentScope( parent );
+ void setClientProperties( ClientProperties clientProperties ) {
+ _clientProperties = clientProperties;
}
public String jsGet_appName() {
- return getDelegate().getClientProperties().getApplicationName();
+ return _clientProperties.getApplicationName();
}
public String jsGet_appCodeName() {
- return getDelegate().getClientProperties().getApplicationCodeName();
+ return _clientProperties.getApplicationCodeName();
}
public String jsGet_appVersion() {
- return getDelegate().getClientProperties().getApplicationVersion();
+ return _clientProperties.getApplicationVersion();
}
public String jsGet_userAgent() {
- return getDelegate().getClientProperties().getUserAgent();
+ return _clientProperties.getUserAgent();
}
public String jsGet_platform() {
- return getDelegate().getClientProperties().getPlatform();
+ return _clientProperties.getPlatform();
}
@@ -487,9 +492,33 @@
}
- private WebResponse.Scriptable getDelegate() {
- return (WebResponse.Scriptable) _scriptable;
+ }
+
+
+ static public class Screen extends JavaScriptEngine {
+
+ private ClientProperties _clientProperties;
+
+
+ void setClientProperties( ClientProperties clientProperties ) {
+ _clientProperties = clientProperties;
+ }
+
+
+ public String getClassName() {
+ return "Screen";
}
+
+
+ public int jsGet_availWidth() {
+ return _clientProperties.getAvailableScreenWidth();
+ }
+
+
+ public int jsGet_availHeight() {
+ return _clientProperties.getAvailHeight();
+ }
+
}
|
|
From: Russell G. <rus...@us...> - 2002-10-08 14:36:04
|
Update of /cvsroot/httpunit/httpunit/doc
In directory usw-pr-cvs1:/tmp/cvs-serv11174/doc
Modified Files:
Javascript-support.html release_notes.txt
Log Message:
from Richard Harris: added support for the JavaScript screen object
Index: Javascript-support.html
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Javascript-support.html 8 Oct 2002 14:01:10 -0000 1.18
+++ Javascript-support.html 8 Oct 2002 14:36:00 -0000 1.19
@@ -34,8 +34,19 @@
<li>appName - the name of the browser, as set in ClientProperties.setApplicationName()</li>
<li>appVersion - the browser version, set in ClientProperties.setApplicationVersion()</li>
<li>plugins - an empty array of objects, since plugins are not universally supported</li>
-<li>platform - the platform for the browser, set in ClientProperties.setPlatform</li>
+<li>platform - the platform for the browser, set in ClientProperties.setPlatform (1.2 feature)</li>
<li>userAgent - the name of the user agent, set by ClientProperties.setUserAgent or derived from the code name and version</li>
+</ul>
+<h4>methods</h4>
+<ul>
+<li>javaEnabled - always returns false to indicate that applets are not supported</li>
+</ul>
+
+<h3>Screen (1.2 feature)</h3>
+<h4>properties</h4>
+<ul>
+<li>availWidth - the available screen width, set in ClientProperties.setAvailableScreenWidth()</li>
+<li>availHeight - the available screen height, set in ClientProperties.setAvailableScreenHeight()</li>
</ul>
<h4>methods</h4>
<ul>
Index: release_notes.txt
===================================================================
RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -r1.178 -r1.179
--- release_notes.txt 8 Oct 2002 14:01:10 -0000 1.178
+++ release_notes.txt 8 Oct 2002 14:36:00 -0000 1.179
@@ -13,11 +13,13 @@
8-Oct-2002
Acknowledgements:
Thanks to Richard Harris for adding support for the title attribute for links,
- and for adding the JavaScript Navigator.platform property.
+ for adding the JavaScript Navigator.platform property,
+ and for adding Javascript support for the Screen object.
Additions:
1. Links, forms, and images now have a readable title property.
2. The navigator object now supports the readable 'platform' property.
+ 3. The screen object is now supported, with properties availHeight and availWidth
4-Oct-2002
|