httpunit-commit Mailing List for httpunit (Page 23)
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...> - 2004-02-12 17:51:32
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24775/doc Modified Files: release_notes.txt Log Message: #890995 - Implemented ServletUnitHttpResponse.containsHeader Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.319 retrieving revision 1.320 diff -u -r1.319 -r1.320 --- release_notes.txt 12 Feb 2004 13:03:23 -0000 1.319 +++ release_notes.txt 12 Feb 2004 17:46:29 -0000 1.320 @@ -16,6 +16,7 @@ 12-Feb-2004 Acknowledgements: Thanks to Jarom Smith for finding some typos in the tutorial. + Thanks to Jay Dunning for providing an implementation of HttpServletResponse.containsHeader Problems fixed: 1. Window.open() using an empty name was replacing the main window rather than creating a new one. @@ -24,6 +25,9 @@ 4. bug #873169 - Cookie headers were generated with no space after the semicolon (unlike IE, Netscape, and Mozilla) 5. Cookie domains without leading dots are now accepted, as per RFC 2965. +Additions: + 1. Patch #890995 - Implemented ServletUnitHttpResponse.containsHeader + 4-Dec-2003 Acknowledgements: Thanks to Andrew Bickerton for adding the following JavaScript support: |
|
From: Russell G. <rus...@us...> - 2004-02-12 17:43:47
|
Update of /cvsroot/httpunit/httpunit/sitedocs/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23141/sitedocs/doc Modified Files: faq.xml Log Message: add Button.click question to FAQ Index: faq.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/sitedocs/doc/faq.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- faq.xml 12 Feb 2004 13:03:24 -0000 1.4 +++ faq.xml 12 Feb 2004 17:38:44 -0000 1.5 @@ -51,7 +51,7 @@ <answer>Badly. Unfortunately, through JDK 1.3, HttpURLConnection (used by HttpUnit to access web servers) has no support for timeouts. Supposedly, this is changed in JDK 1.4, but HttpUnit does not support the new feature as yet.</answer> </faq> - <faq> + <faq id="rejected cookies"> <question>Why isn't HttpUnit seeing cookies from my site?</question> <answer><![CDATA[According to the <a href="http://www.faqs.org/rfcs/rfc2965.html">Cookie specification>/a>, sites may specify a domain and path to restrict the scope of their cookies. These specifications @@ -91,6 +91,14 @@ the underlying value in the form. This will behave the way JavaScript does - resetting the form will now restore this value, rather than the original one.</li></ul>]]></answer> </faq> + <faq id="button click"> + <question>How do I get the response when I click a button?</question> + <answer><![CDATA[When you call Button.click, a number of things can happen, depending on the definition of the button. + Unfortunately, it is then impossible to predict what, if any, response is relevant. The method therefore + does not return WebResponse. In most cases, it is the main window of your browser that you care about + and you can always obtain that by calling + <a href="api/com/meterware/httpunit/WebClient.html#getCurrentPage()"><code>client.getCurrentPage()</code></a>.]]</answer> + </faq> </section> <section title="JavaScript support"> |
|
From: Russell G. <rus...@us...> - 2004-02-12 17:43:47
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23141/doc/tutorial Modified Files: .cvsignore Log Message: add Button.click question to FAQ Index: .cvsignore =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/tutorial/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- .cvsignore 28 Feb 2002 14:30:33 -0000 1.1 +++ .cvsignore 12 Feb 2004 17:38:44 -0000 1.2 @@ -1,3 +1,4 @@ classes jars -task1.zip \ No newline at end of file +task1.zip +index.html \ No newline at end of file |
|
From: Russell G. <rus...@us...> - 2004-02-12 17:43:46
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23141/doc Modified Files: .cvsignore Log Message: add Button.click question to FAQ Index: .cvsignore =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- .cvsignore 17 Dec 2001 14:53:40 -0000 1.1 +++ .cvsignore 12 Feb 2004 17:38:44 -0000 1.2 @@ -1 +1,8 @@ -api \ No newline at end of file +api +developers.html +servletunit-intro.html +javascript-support.html +citations.html +faq.html +cookbook.html +license.html \ No newline at end of file |
|
From: Russell G. <rus...@us...> - 2004-02-12 13:08:18
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20516/src/com/meterware/httpunit/cookies Modified Files: CookieJar.java CookieListener.java CookieProperties.java Log Message: Accept specified cookie domains lacking a leading dot Index: CookieJar.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- CookieJar.java 12 Feb 2004 06:57:52 -0000 1.7 +++ CookieJar.java 12 Feb 2004 13:03:24 -0000 1.8 @@ -365,9 +365,9 @@ private int getDomainAttributeStatus( String domainAttribute, String sourceHost ) { - if (CookieProperties.isDomainMatchingStrict() && !domainAttribute.startsWith(".")) { - return CookieListener.DOMAIN_NO_STARTING_DOT; - } else if (domainAttribute.lastIndexOf('.') == 0) { + if (!domainAttribute.startsWith(".")) domainAttribute = '.' + domainAttribute; + + if (domainAttribute.lastIndexOf('.') == 0) { return CookieListener.DOMAIN_ONE_DOT; } else if (!sourceHost.endsWith( domainAttribute )) { return CookieListener.DOMAIN_NOT_SOURCE_SUFFIX; Index: CookieListener.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CookieListener.java 17 Jun 2003 11:08:25 -0000 1.1 +++ CookieListener.java 12 Feb 2004 13:03:24 -0000 1.2 @@ -3,7 +3,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2003, Russell Gold + * Copyright (c) 2003-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -26,9 +26,6 @@ /** Indicates that the cookie was accepted. **/ public final static int ACCEPTED = 0; - /** Indicates that the domain attribute does not begin with a dot. **/ - public final static int DOMAIN_NO_STARTING_DOT = 1; - /** Indicates that the domain attribute has only one dot. **/ public final static int DOMAIN_ONE_DOT = 2; Index: CookieProperties.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CookieProperties.java 17 Jun 2003 11:08:25 -0000 1.1 +++ CookieProperties.java 12 Feb 2004 13:03:24 -0000 1.2 @@ -6,7 +6,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2003, Russell Gold + * Copyright (c) 2003-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -46,21 +46,36 @@ } + /** + * Returns true (the default) if cookies should be rejected if they specify a domain which is not a suffix + * of the host domain or does not contain all of the dots in that host domain name + * (see <a href="http://www.faqs.org/rfcs/rfc2965.html">RFC2965</a>). + */ public static boolean isDomainMatchingStrict() { return _domainMatchingStrict; } + /** + * Specifies whether strict domain name matching must be followed. + */ public static void setDomainMatchingStrict( boolean domainMatchingStrict ) { _domainMatchingStrict = domainMatchingStrict; } + /** + * Returns true (the default) if cookies should be rejected if they specify a path which is not a prefix + * of the request path (see <a href="http://www.faqs.org/rfcs/rfc2965.html">RFC2965</a>). + */ public static boolean isPathMatchingStrict() { return _pathMatchingStrict; } + /** + * Specifies whether strict path name matching must be followed. + */ public static void setPathMatchingStrict( boolean pathMatchingStrict ) { _pathMatchingStrict = pathMatchingStrict; } |
|
From: Russell G. <rus...@us...> - 2004-02-12 13:08:18
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20516/test/com/meterware/httpunit/cookies Modified Files: CookieTest.java Log Message: Accept specified cookie domains lacking a leading dot Index: CookieTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- CookieTest.java 12 Feb 2004 06:57:52 -0000 1.7 +++ CookieTest.java 12 Feb 2004 13:03:24 -0000 1.8 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002-2003, Russell Gold + * Copyright (c) 2002-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -105,10 +105,10 @@ public void testCookieAcceptance() throws Exception { - checkAcceptance( 1, true, "www.meterware.com/servlets/special", null, null ); - checkAcceptance( 2, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets" ); + checkAcceptance( 1, true, "www.meterware.com/servlets/special", null, null ); + checkAcceptance( 2, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets" ); checkAcceptance( 3, false, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); - checkAcceptance( 4, false, "www.meterware.com/servlets/special", "meterware.com", null ); + checkAcceptance( 4, true, "www.meterware.com/servlets/special", "meterware.com", null ); checkAcceptance( 5, false, "www.meterware.com/servlets/special", "meterware", null ); checkAcceptance( 6, false, "www.meterware.com/servlets/special", ".com", null ); checkAcceptance( 7, false, "www.meterware.com/servlets/special", ".httpunit.org", null ); @@ -196,11 +196,10 @@ CookieProperties.setDomainMatchingStrict( false ); checkAcceptance( 1, true, "www.some.meterware.com/servlets/special", ".meterware.com", null ); checkAcceptance( 2, false, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); - checkAcceptance( 3, true, "www.meterware.com/servlets/special", "meterware.com", "/servlets/special" ); CookieProperties.setPathMatchingStrict( false ); - checkAcceptance( 4, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); - checkMatching( 5, true, new URL( "http://www.meterware.com/servlets/sample" ), "www.meterware.com", "/servlets/sample/data" ); + checkAcceptance( 3, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); + checkMatching( 4, true, new URL( "http://www.meterware.com/servlets/sample" ), "www.meterware.com", "/servlets/sample/data" ); } @@ -210,10 +209,9 @@ checkCallback( listener, 1, 0, "www.meterware.com/servlets/special", null, null ); checkCallback( listener, 2, CookieListener.PATH_NOT_PREFIX, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); - checkCallback( listener, 3, CookieListener.DOMAIN_NO_STARTING_DOT, "www.meterware.com/servlets/special", "meterware.com", null ); - checkCallback( listener, 4, CookieListener.DOMAIN_ONE_DOT, "www.meterware.com/servlets/special", ".com", null ); - checkCallback( listener, 5, CookieListener.DOMAIN_NOT_SOURCE_SUFFIX, "www.meterware.com/servlets/special", ".httpunit.org", null ); - checkCallback( listener, 6, CookieListener.DOMAIN_TOO_MANY_LEVELS, "www.some.meterware.com/servlets/special", ".meterware.com", null ); + checkCallback( listener, 3, CookieListener.DOMAIN_ONE_DOT, "www.meterware.com/servlets/special", ".com", null ); + checkCallback( listener, 4, CookieListener.DOMAIN_NOT_SOURCE_SUFFIX, "www.meterware.com/servlets/special", ".httpunit.org", null ); + checkCallback( listener, 5, CookieListener.DOMAIN_TOO_MANY_LEVELS, "www.some.meterware.com/servlets/special", ".meterware.com", null ); } |
|
From: Russell G. <rus...@us...> - 2004-02-12 13:08:17
|
Update of /cvsroot/httpunit/httpunit/sitedocs/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20516/sitedocs/doc Modified Files: faq.xml Log Message: Accept specified cookie domains lacking a leading dot Index: faq.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/sitedocs/doc/faq.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- faq.xml 21 Aug 2003 11:52:37 -0000 1.3 +++ faq.xml 12 Feb 2004 13:03:24 -0000 1.4 @@ -51,6 +51,18 @@ <answer>Badly. Unfortunately, through JDK 1.3, HttpURLConnection (used by HttpUnit to access web servers) has no support for timeouts. Supposedly, this is changed in JDK 1.4, but HttpUnit does not support the new feature as yet.</answer> </faq> + <faq> + <question>Why isn't HttpUnit seeing cookies from my site?</question> + <answer><![CDATA[According to the <a href="http://www.faqs.org/rfcs/rfc2965.html">Cookie specification>/a>, + sites may specify a domain and path to restrict the scope of their cookies. These specifications + must follow certain rules, and the vast majority of sites do. Unfortunately, there are some + popular sites (such as Yahoo.com) which do not. By default, HttpUnit is very strict about + implementing the spec, and will reject such cookies. You can control this behavior by calls to the + <a href="api/com/meterware/httpunit/cookies/CookieProperties.html">CookieProperties</a> class. + If you suspect that this is happening, you can also register a + <a href="api/com/meterware/httpunit/cookies/CookieListener.html">CookieListener</a> to watch for cookies + being rejected.]]</answer> + </faq> </section> <section title="Form Handling Problems"> @@ -59,7 +71,7 @@ <answer><![CDATA[The setParameter call lets you specify the values per parameter name. An unchecked checkbox has no value to transmit, so you would call: <pre><code> form.setParameter( "checkbox-name", new String[0] );</code></pre> or <pre><code> form.removeParameter( "checkbox-name" );</code></pre> - As of 1.5.4, you have alternatives. If the checkbox's name is unique, you can say: + If the checkbox's name is unique, you can say: <pre><code> form.setCheckbox( "checkbox-name", false );</code></pre> or <pre><code> form.toggleCheckbox( "checkbox-name" );</code></pre>]]></answer> </faq> |
|
From: Russell G. <rus...@us...> - 2004-02-12 13:08:17
|
Update of /cvsroot/httpunit/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20516 Modified Files: build.xml Log Message: Accept specified cookie domains lacking a leading dot Index: build.xml =================================================================== RCS file: /cvsroot/httpunit/httpunit/build.xml,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- build.xml 23 Sep 2003 12:13:43 -0000 1.69 +++ build.xml 12 Feb 2004 13:03:23 -0000 1.70 @@ -5,7 +5,7 @@ <project name="httpunit" default="jar" basedir="."> <property name="name" value="httpunit" /> <property name="Name" value="HttpUnit" /> - <property name="version" value="1.5.4" /> + <property name="version" value="1.5.5" /> <property name="debug" value="on" /> <property name="deprecation" value="off" /> @@ -194,7 +194,7 @@ <javadoc packagenames="${packages}" sourcepath="${basedir}/${src.dir}" destdir="${javadoc.dir}" author="true" version="true" windowtitle="${Name} ${version} API" doctitle="${Name}" - footer="Copyright &copy; 2000-2003 Russell Gold. See <a target="_top" href="../license.html">license agreement</A> for rights granted." > + footer="Copyright &copy; 2000-2004 Russell Gold. See <a target="_top" href="../license.html">license agreement</A> for rights granted." > <classpath refid="base.classpath"/> </javadoc> </target> |
|
From: Russell G. <rus...@us...> - 2004-02-12 13:08:17
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20516/doc Modified Files: release_notes.txt Log Message: Accept specified cookie domains lacking a leading dot Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.318 retrieving revision 1.319 diff -u -r1.318 -r1.319 --- release_notes.txt 12 Feb 2004 06:57:51 -0000 1.318 +++ release_notes.txt 12 Feb 2004 13:03:23 -0000 1.319 @@ -22,7 +22,7 @@ 2. bug #883293 - typos in tutorial task 1 step 4 3. bug #883301 - more typos in tutorial task 1 step 4 4. bug #873169 - Cookie headers were generated with no space after the semicolon (unlike IE, Netscape, and Mozilla) - 5. The CookieProperties.domainMatchingStrict flag now controls whether cookie domains without leading dots are accepted + 5. Cookie domains without leading dots are now accepted, as per RFC 2965. 4-Dec-2003 Acknowledgements: |
|
From: Russell G. <rus...@us...> - 2004-02-12 07:02:34
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16536/doc Modified Files: release_notes.txt Log Message: Allow lenient cookie domain matching to permit domains w/o leading dots Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.317 retrieving revision 1.318 diff -u -r1.317 -r1.318 --- release_notes.txt 12 Feb 2004 06:23:08 -0000 1.317 +++ release_notes.txt 12 Feb 2004 06:57:51 -0000 1.318 @@ -22,6 +22,7 @@ 2. bug #883293 - typos in tutorial task 1 step 4 3. bug #883301 - more typos in tutorial task 1 step 4 4. bug #873169 - Cookie headers were generated with no space after the semicolon (unlike IE, Netscape, and Mozilla) + 5. The CookieProperties.domainMatchingStrict flag now controls whether cookie domains without leading dots are accepted 4-Dec-2003 Acknowledgements: |
|
From: Russell G. <rus...@us...> - 2004-02-12 07:02:34
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16536/test/com/meterware/httpunit/cookies Modified Files: CookieTest.java Log Message: Allow lenient cookie domain matching to permit domains w/o leading dots Index: CookieTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CookieTest.java 12 Feb 2004 06:23:09 -0000 1.6 +++ CookieTest.java 12 Feb 2004 06:57:52 -0000 1.7 @@ -121,7 +121,7 @@ CookieJar jar = newJar( urlString, specifiedDomain, specifiedPath ); if (shouldAccept) { - assertNotNull( "Rejected cookie " + index, jar.getCookie( "name" ) ); + assertNotNull( "Rejected cookie " + index + "( " + specifiedDomain + " from " + urlString + ")", jar.getCookie( "name" ) ); } else { assertNull( "Cookie " + index + " should have been rejected", jar.getCookie( "name" ) ); } @@ -196,10 +196,11 @@ CookieProperties.setDomainMatchingStrict( false ); checkAcceptance( 1, true, "www.some.meterware.com/servlets/special", ".meterware.com", null ); checkAcceptance( 2, false, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); + checkAcceptance( 3, true, "www.meterware.com/servlets/special", "meterware.com", "/servlets/special" ); CookieProperties.setPathMatchingStrict( false ); - checkAcceptance( 3, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); - checkMatching( 4, true, new URL( "http://www.meterware.com/servlets/sample" ), "www.meterware.com", "/servlets/sample/data" ); + checkAcceptance( 4, true, "www.meterware.com/servlets/special", ".meterware.com", "/servlets/ordinary" ); + checkMatching( 5, true, new URL( "http://www.meterware.com/servlets/sample" ), "www.meterware.com", "/servlets/sample/data" ); } |
|
From: Russell G. <rus...@us...> - 2004-02-12 07:02:34
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16536/src/com/meterware/httpunit/cookies Modified Files: CookieJar.java Log Message: Allow lenient cookie domain matching to permit domains w/o leading dots Index: CookieJar.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CookieJar.java 12 Feb 2004 06:23:08 -0000 1.6 +++ CookieJar.java 12 Feb 2004 06:57:52 -0000 1.7 @@ -365,7 +365,7 @@ private int getDomainAttributeStatus( String domainAttribute, String sourceHost ) { - if (!domainAttribute.startsWith(".")) { + if (CookieProperties.isDomainMatchingStrict() && !domainAttribute.startsWith(".")) { return CookieListener.DOMAIN_NO_STARTING_DOT; } else if (domainAttribute.lastIndexOf('.') == 0) { return CookieListener.DOMAIN_ONE_DOT; |
|
From: Russell G. <rus...@us...> - 2004-02-12 06:27:49
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11592/test/com/meterware/httpunit/cookies Modified Files: CookieTest.java Log Message: bug #873169: Add space between multiple cookies to match browser behavior Index: CookieTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/cookies/CookieTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- CookieTest.java 17 Jun 2003 23:26:38 -0000 1.5 +++ CookieTest.java 12 Feb 2004 06:23:09 -0000 1.6 @@ -161,8 +161,8 @@ jar.updateCookies( newJar( "www.httpunit.org", "zero=go; domain=.httpunit.org" ) ); jar.updateCookies( newJar( "meterware.com", "fourth=money" ) ); - checkHeader( 1, jar, "first=ready;second=set;zero=nil", "www.meterware.com/servlets/standard/Count" ); - checkHeader( 2, jar, "second=set;zero=nil", "www.meterware.com/servlets/special/Divide" ); + checkHeader( 1, jar, "first=ready; second=set; zero=nil", "www.meterware.com/servlets/standard/Count" ); + checkHeader( 2, jar, "second=set; zero=nil", "www.meterware.com/servlets/special/Divide" ); checkHeader( 3, jar, "zero=go", "fancy.httpunit.org/servlets/AskMe" ); HttpUserAgentTest.assertMatchingSet( "Cookie names", @@ -183,7 +183,7 @@ jar.updateCookies( newJar( "www.meterware.com/servlets", "third=day" ) ); jar.updateCookies( newJar( "www.meterware.com/servlets", "third=tomorrow" ) ); - checkHeader( 1, jar, "first=ready;third=tomorrow", "www.meterware.com/servlets/standard" ); + checkHeader( 1, jar, "first=ready; third=tomorrow", "www.meterware.com/servlets/standard" ); } |
|
From: Russell G. <rus...@us...> - 2004-02-12 06:27:49
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11592/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: bug #873169: Add space between multiple cookies to match browser behavior Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- ScriptingTest.java 12 Feb 2004 05:36:29 -0000 1.58 +++ ScriptingTest.java 12 Feb 2004 06:23:09 -0000 1.59 @@ -683,7 +683,7 @@ WebConversation wc = new WebConversation(); wc.addCookie( "height", "tall" ); wc.getResponse( getHostPath() + "/OnCommand.html" ); - assertEquals( "Alert message 1", "cookies: age=12;height=tall", wc.popNextAlert() ); + assertEquals( "Alert message 1", "cookies: age=12; height=tall", wc.popNextAlert() ); assertNull( "Alert should have been removed", wc.getNextAlert() ); } |
|
From: Russell G. <rus...@us...> - 2004-02-12 06:27:49
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11592/src/com/meterware/httpunit/cookies Modified Files: CookieJar.java Log Message: bug #873169: Add space between multiple cookies to match browser behavior Index: CookieJar.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/cookies/CookieJar.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- CookieJar.java 17 Jun 2003 23:26:38 -0000 1.5 +++ CookieJar.java 12 Feb 2004 06:23:08 -0000 1.6 @@ -155,13 +155,13 @@ Cookie cookie = (Cookie) i.next(); if (!cookie.mayBeSentTo( targetURL )) continue; restrictedCookies.add( cookie.getName() ); - if (sb.length() != 0) sb.append( ';' ); + if (sb.length() != 0) sb.append( "; " ); sb.append( cookie.getName() ).append( '=' ).append( cookie.getValue() ); } for (Iterator i = _globalCookies.iterator(); i.hasNext();) { Cookie cookie = (Cookie) i.next(); if (restrictedCookies.contains( cookie.getName() )) continue; - if (sb.length() != 0) sb.append( ';' ); + if (sb.length() != 0) sb.append( "; " ); sb.append( cookie.getName() ).append( '=' ).append( cookie.getValue() ); } return sb.length() == 0 ? null : sb.toString(); |
|
From: Russell G. <rus...@us...> - 2004-02-12 06:27:48
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11592/doc Modified Files: release_notes.txt Log Message: bug #873169: Add space between multiple cookies to match browser behavior Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.316 retrieving revision 1.317 diff -u -r1.316 -r1.317 --- release_notes.txt 12 Feb 2004 06:07:27 -0000 1.316 +++ release_notes.txt 12 Feb 2004 06:23:08 -0000 1.317 @@ -21,6 +21,7 @@ 1. Window.open() using an empty name was replacing the main window rather than creating a new one. 2. bug #883293 - typos in tutorial task 1 step 4 3. bug #883301 - more typos in tutorial task 1 step 4 + 4. bug #873169 - Cookie headers were generated with no space after the semicolon (unlike IE, Netscape, and Mozilla) 4-Dec-2003 Acknowledgements: |
|
From: Russell G. <rus...@us...> - 2004-02-12 06:12:07
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9097/doc Modified Files: release_notes.txt Log Message: Fix typos in tutorial (bugs #883293, 883301) Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.315 retrieving revision 1.316 diff -u -r1.315 -r1.316 --- release_notes.txt 12 Feb 2004 05:36:29 -0000 1.315 +++ release_notes.txt 12 Feb 2004 06:07:27 -0000 1.316 @@ -14,8 +14,13 @@ Revision History: 12-Feb-2004 +Acknowledgements: + Thanks to Jarom Smith for finding some typos in the tutorial. + Problems fixed: 1. Window.open() using an empty name was replacing the main window rather than creating a new one. + 2. bug #883293 - typos in tutorial task 1 step 4 + 3. bug #883301 - more typos in tutorial task 1 step 4 4-Dec-2003 Acknowledgements: |
|
From: Russell G. <rus...@us...> - 2004-02-12 06:12:07
|
Update of /cvsroot/httpunit/httpunit/doc/tutorial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9097/doc/tutorial Modified Files: task1editor-validation.html Log Message: Fix typos in tutorial (bugs #883293, 883301) Index: task1editor-validation.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/tutorial/task1editor-validation.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- task1editor-validation.html 23 May 2003 03:07:30 -0000 1.6 +++ task1editor-validation.html 12 Feb 2004 06:07:27 -0000 1.7 @@ -101,17 +101,18 @@ WebResponse response = client.getResponse( "http://localhost/PoolEditor" ); WebForm form = response.getFormWithID( "pool" ); - form.setParameter( "away1", "Detroit Lions" ); // (1) enter bad values into the form + form.setParameter( "away1", "Detroit Lions" ); // (1) enter bad values into the form form.setParameter( "home1", "Denver Broncos" ); form.setParameter( "home2", "Baltimore Ravens" ); form.setParameter( "tiebreaker", "3" ); - SubmitButton openButton = getSubmitButton( "save", "Open Pool" ); // (2) select the desired submit button - response = form.submit( saveButton ); // (3) submit the form + SubmitButton openButton = form.getSubmitButton( "save", "Open Pool" ); // (2) select the desired submit button + response = form.submit( saveButton ); // (3) submit the form - WebTable errorTable = response.getTableWithID( "errors" ); // (4) Look for the error table + WebTable errorTable = response.getTableWithID( "errors" ); // (4) Look for the error table assertNotNull( "No errors reported", errorTable ); - String[][] cells = errorTable.asText(); // (5) Convert non-empty cells to text + errorTable.purgeEmptyCells(); // (5) Remove any empty cells from the table + String[][] cells = errorTable.asText(); // (6) Convert non-empty cells to text assertEquals( "Number of error messages provided", 2, cells.length - 1 ); assertEquals( "Error message", "Tiebreaker is not a valid game", cells[1][0] ); assertEquals( "Error message", "Game 2 has no away team", cells[2][0] ); @@ -122,6 +123,7 @@ <li>We then select the "Open Pool" button to be included with the form submission.</li> <li>We want the response when we submit the form changes.</li> <li>We expect to find them in a table with "errors" as its ID.</li> +<li>We are not interested in any empty cells used for formatting.</li> <li>Since we want to examine the textual content of any non-empty cells in the table, we ask that the table be converted to a two-dimensional string array. In this case, there should only be one non-blank cell in each row.</li></ol></p> @@ -177,7 +179,7 @@ assertNull( "Could still update the pool", form.getSubmitButton( "save" ) ); // (3) look for the buttons try { - request = form.getRequest(); + WebRequest request = form.getRequest(); request.setParameter( "home3", "Philadelphia Eagles" ); // (4) try to change an entry fail( "Could still edit the pool" ); } catch (IllegalRequestParameterException e) {} |
|
From: Russell G. <rus...@us...> - 2004-02-12 05:41:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3036/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Do not replace main window on Window.open with null name Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- ScriptingTest.java 27 Oct 2003 21:16:10 -0000 1.57 +++ ScriptingTest.java 12 Feb 2004 05:36:29 -0000 1.58 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002, Russell Gold + * Copyright (c) 2002-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -275,6 +275,36 @@ } + public void testWindowOpenWithEmptyName() throws Exception { + defineResource( "Target.txt", "You made it!", "text/plain" ); + defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + + "<body><script language='JavaScript'>var otherWindow;</script>" + + "<a href='#' onClick=\"otherWindow = window.open( '" + getHostPath() + "/Target.txt', '' );\">go</a>" + + "<a href='#' onClick=\"otherWindow.close();\">go</a>" + + "<a href='#' onClick=\"alert( 'window is ' + (otherWindow.closed ? '' : 'not ') + 'closed' );\">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() ); + final WebWindow openedWindow = (WebWindow) windowsOpened.get( 0 ); + assertEquals( "New window message", "You made it!", openedWindow.getCurrentPage().getText() ); + assertEquals( "New window name", "", openedWindow.getName() ); + response.getLinks()[2].click(); + assertEquals( "Alert message", "window is not closed", wc.popNextAlert() ); + response.getLinks()[1].click(); + assertTrue( "Window was not closed", openedWindow.isClosed() ); + response.getLinks()[2].click(); + assertEquals( "Alert message", "window is closed", wc.popNextAlert() ); + } + + public void testJavascriptURLWithFragment() throws Exception { defineResource( "Target.txt", "You made it!", "text/plain" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + |
|
From: Russell G. <rus...@us...> - 2004-02-12 05:41:08
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3036/src/com/meterware/httpunit Modified Files: WebClient.java WebResponse.java WebWindow.java Log Message: Do not replace main window on Window.open with null name Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- WebClient.java 20 Aug 2003 12:06:15 -0000 1.52 +++ WebClient.java 12 Feb 2004 05:36:29 -0000 1.53 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -45,10 +45,10 @@ abstract public class WebClient { + private ArrayList _openWindows = new ArrayList(); /** The current main window. **/ private WebWindow _mainWindow = new WebWindow( this ); - private ArrayList _openWindows = new ArrayList(); private String _authorizationString; Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.123 retrieving revision 1.124 diff -u -r1.123 -r1.124 --- WebResponse.java 5 Dec 2003 04:06:53 -0000 1.123 +++ WebResponse.java 12 Feb 2004 05:36:29 -0000 1.124 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * -* Copyright (c) 2000-2003, Russell Gold +* Copyright (c) 2000-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -668,7 +668,8 @@ public String getName() { - return getFrameName().equals( WebRequest.TOP_FRAME ) ? _window.getName() : getFrameName(); + String windowName = getFrameName().equals( WebRequest.TOP_FRAME ) ? _window.getName() : getFrameName(); + return windowName.startsWith( WebWindow.NO_NAME ) ? "" : windowName; } Index: WebWindow.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- WebWindow.java 5 Dec 2003 04:06:53 -0000 1.16 +++ WebWindow.java 12 Feb 2004 05:36:29 -0000 1.17 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002-2003, Russell Gold + * Copyright (c) 2002-2004, Russell Gold * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated * documentation files (the "Software"), to deal in the Software without restriction, including without limitation @@ -49,6 +49,9 @@ private boolean _closed; + static final String NO_NAME = "$$HttpUnit_Window$$_"; + + /** * Returns the web client associated with this window. */ @@ -216,6 +219,7 @@ WebWindow( WebClient client ) { _client = client; _frameContents = new FrameHolder( _client, WebRequest.TOP_FRAME ); + _name = NO_NAME + _client.getOpenWindows().length; } |
|
From: Russell G. <rus...@us...> - 2004-02-12 05:41:07
|
Update of /cvsroot/httpunit/httpunit/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3036/doc Modified Files: release_notes.txt Log Message: Do not replace main window on Window.open with null name Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.314 retrieving revision 1.315 diff -u -r1.314 -r1.315 --- release_notes.txt 5 Dec 2003 04:06:52 -0000 1.314 +++ release_notes.txt 12 Feb 2004 05:36:29 -0000 1.315 @@ -13,6 +13,10 @@ Revision History: +12-Feb-2004 +Problems fixed: + 1. Window.open() using an empty name was replacing the main window rather than creating a new one. + 4-Dec-2003 Acknowledgements: Thanks to Andrew Bickerton for adding the following JavaScript support: |
|
From: Russell G. <rus...@us...> - 2003-12-05 04:06:58
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv27254/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java FormScriptingTest.java
FrameScriptingTest.java
Log Message:
from Andrew Bickerton: Support form.length, control.type, control.defaultValue
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DocumentScriptingTest.java 2 Apr 2003 15:31:12 -0000 1.10
+++ DocumentScriptingTest.java 5 Dec 2003 04:06:53 -0000 1.11
@@ -273,7 +273,7 @@
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()\" >" );
+ defineWebPage( "OnCommand", "<a href='#' onclick=\"window.open( '', 'empty' );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];
@@ -283,6 +283,7 @@
assertEquals( "Content Type", "text/plain", ww.getCurrentPage().getContentType() );
link.click();
assertEquals( "Generated page", "You made it!", ww.getCurrentPage().getText() );
+ assertEquals( "Empty page", "", wc.getOpenWindow("empty").getCurrentPage().getText() );
}
Index: FormScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- FormScriptingTest.java 19 Sep 2003 18:53:43 -0000 1.25
+++ FormScriptingTest.java 5 Dec 2003 04:06:54 -0000 1.26
@@ -25,6 +25,8 @@
import java.io.IOException;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import junit.textui.TestRunner;
import junit.framework.TestSuite;
@@ -839,6 +841,149 @@
WebResponse response = wc.getResponse( getHostPath() + "/index.html" );
WebForm form = response.getFormWithName( "formName" );
assertEquals( "Changed value", "Hello World!", form.getParameterValue( "inputName" ) );
+ }
+
+ /**
+ * Test that JavaScript can correctly access the 'type' property for every kind of form control.
+ * @throws Exception
+ */
+ public void testElementTypeAccess() throws Exception {
+ defineWebPage( "Default", "<script language=JavaScript>\n" +
+ "function CheckForm() {\n" +
+ " var len = document.myForm.elements.length;\n" +
+ " for (var index = 0; index < len; index++) {\n" +
+ " var control = document.myForm.elements[index];\n" +
+ " confirm(control.type);\n" +
+ " }\n" +
+ " return true;\n" +
+ "}\n" +
+ "</script>" +
+ "<form name=myForm method=POST>" +
+ " <input type=\"text\" name=\"textfield\">" +
+ " <textarea name=\"textarea\"></textarea>" +
+ " <input type=\"password\" name=\"password\">" +
+ " <input type=\"submit\" name=\"submit\" value=\"Submit\" onClick=\"return Check()\">" +
+ " <input type=\"reset\" name=\"reset\" value=\"Reset\">" +
+ " <input type=\"button\" name=\"button\" value=\"Button\">" +
+ " <input type=\"checkbox\" name=\"checkbox\" value=\"checkbox\">" +
+ " <input type=\"radio\" name=\"radiobutton\" value=\"radiobutton\">" +
+ " <select name=\"select\">" +
+ " <option value=\"1\">One</option>" +
+ " <option value=\"2\">Two</option>" +
+ " </select>" +
+ " <select name=\"select2\" size=\"2\" multiple>" +
+ " <option value=\"1\">One</option>" +
+ " <option value=\"2\">Two</option>" +
+ " </select>" +
+ " <input type=\"file\" name=\"fileField\">" +
+ " <input type=\"image\" name=\"imageField\" src=\"img.gif\">" +
+ " <input type=\"hidden\" name=\"hiddenField\">" +
+ " <button name=\"html4-button\" type=\"button\">html4-button</button>" +
+ " <button name=\"html4-submit\" type=\"submit\">html4-submit</button>" +
+ " <button name=\"html4-reset\" type=\"reset\">html4-reset</button>" +
+ " <button name=\"html4-default\">html4-default</button>" +
+ "</form>" +
+ "<script language=JavaScript>\n" +
+ " CheckForm();\n" +
+ "</script>\n");
+
+ String[] expectedTypes = new String[]{
+ "text", "textarea", "password", "submit", "reset", "button",
+ "checkbox", "radio", "select-one", "select-multiple", "file",
+ "image", "hidden", "button", "submit", "reset", "submit"
+ };
+
+ final PromptCollector collector = new PromptCollector();
+ WebConversation wc = new WebConversation();
+ wc.setDialogResponder(collector);
+ wc.getResponse( getHostPath() + "/Default.html" );
+ assertMatchingSet("Set of types on form", expectedTypes, collector.confirmPromptsSeen.toArray());
+ }
+
+ static class PromptCollector implements DialogResponder {
+ public List confirmPromptsSeen = new ArrayList();
+ public List responsePromptSeen = new ArrayList();
+ public boolean getConfirmation(String confirmationPrompt) {
+ confirmPromptsSeen.add(confirmationPrompt);
+ return true;
+ }
+
+ public String getUserResponse(String prompt, String defaultResponse) {
+ responsePromptSeen.add(prompt);
+ return null;
+ }
+ }
+
+ /**
+ * Test that the length (number of controls) of a form can be accessed from JavaScript.
+ * @throws Exception
+ */
+ public void testFormLength () throws Exception {
+ defineWebPage("Default", "<script language=JavaScript>\n" +
+ "function CheckForm()\n"+
+ "{\n"+
+ "confirm (document.myForm.length);\n" +
+ "return true;\n" +
+ "}\n" +
+ "</script>" +
+ "<form name=myForm method=POST>" +
+ " <input type=\"text\" name=\"first_name\" value=\"Fred\">" +
+ " <input type=\"text\" name=\"last_name\" value=\"Bloggs\">" +
+ "</form>" +
+ "<script language=JavaScript>\n" +
+ " CheckForm();\n" +
+ "</script>\n");
+
+ String[] expectedPrompts = new String[]{"2"};
+
+ final PromptCollector collector = new PromptCollector();
+ WebConversation wc = new WebConversation();
+ wc.setDialogResponder(collector);
+ wc.getResponse( getHostPath() + "/Default.html" );
+ assertMatchingSet("Length of form", expectedPrompts, collector.confirmPromptsSeen.toArray());
+ }
+
+ /**
+ * Test that the JavaScript 'value' and 'defaultValue' properties of a text input are distinct.
+ * 'defaultValue' should represent the 'value' attribute of the input element.
+ * 'value' should initially match 'defaultValue', but setting it should not affect the 'defaultValue'.
+ * @throws Exception
+ */
+ public void testElementDefaultValue () throws Exception {
+ defineWebPage("Default", "<script language=JavaScript>\n" +
+ "function CheckForm()\n"+
+ "{\n"+
+ "var i;\n" +
+ "var form_length=document.myForm.elements.length;\n" +
+ "for ( i=0 ; i< form_length; i++ )\n" +
+ "{\n"+
+ " confirm (document.myForm.elements[i].value);\n " +
+ "}\n"+
+ "document.myForm.elements[2].value = \"Charles\"\n" +
+ "for ( i=0 ; i< form_length; i++ )\n" +
+ "{\n"+
+ " confirm (document.myForm.elements[i].defaultValue);\n " +
+ "}\n"+
+ "confirm(document.myForm.elements[2].value);\n" +
+ "return true;\n" +
+ "}\n" +
+ "</script>" +
+ "<form name=myForm method=POST>" +
+ " <input type=\"text\" name=\"first_name\" value=\"Alpha\">" +
+ " <input type=\"text\" name=\"last_name\" value=\"Bravo\">" +
+ " <input type=\"text\" name=\"last_name\" value=\"Charlie\">" +
+ "</form>" +
+ "<script language=JavaScript>\n" +
+ " CheckForm();\n" +
+ "</script>\n");
+
+ String[] expectedValues = new String[]{"Alpha", "Bravo", "Charlie", "Alpha", "Bravo", "Charlie", "Charles"};
+
+ final PromptCollector collector = new PromptCollector();
+ WebConversation wc = new WebConversation();
+ wc.setDialogResponder(collector);
+ wc.getResponse( getHostPath() + "/Default.html" );
+ assertMatchingSet("Values seen by JavaScript", expectedValues, collector.confirmPromptsSeen.toArray());
}
}
Index: FrameScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FrameScriptingTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FrameScriptingTest.java 24 Mar 2003 15:04:33 -0000 1.2
+++ FrameScriptingTest.java 5 Dec 2003 04:06:54 -0000 1.3
@@ -196,5 +196,27 @@
assertEquals( "Result of click", "You made it!", result.getText() );
}
+ /**
+ * Verifies that when JavaScript overwrites an empty frame, other empty frames stay empty.
+ */
+ public void testJavaScriptOverwritingBlankFrame() throws Exception {
+ defineResource("Frames.html",
+ "<HTML><HEAD><TITLE>Initial</TITLE></HEAD>" +
+ "<FRAMESET>" +
+ " <FRAME src='Writer.html' name='red'>" +
+ " <FRAME name=green>" +
+ " <FRAME name=blue>" +
+ "</FRAMESET></HTML>");
+ defineWebPage("Writer", "This page overwrites an empty frame. <script language=\"JavaScript\">"
+ + " window.parent.green.document.open(\"text/html\")\n"
+ + " window.parent.green.document.write(\"Generated <a href=\\\"#\\\">link</a>\")\n"
+ + " window.parent.green.document.close()\n"
+ + "</script>");
+
+ _wc.getResponse(getHostPath() + "/Frames.html");
+ assertEquals("Links in green frame", 1, _wc.getFrameContents("green").getLinks().length);
+ assertEquals("Links in blue frame", 0, _wc.getFrameContents("blue").getLinks().length);
+ }
+
private WebConversation _wc;
}
|
|
From: Russell G. <rus...@us...> - 2003-12-05 04:06:57
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv27254/src/com/meterware/httpunit
Modified Files:
Button.java FormControl.java FrameHolder.java ResetButton.java
SubmitButton.java TableCell.java WebForm.java WebResponse.java
WebWindow.java
Log Message:
from Andrew Bickerton: Support form.length, control.type, control.defaultValue
Index: Button.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Button.java 23 Jun 2003 23:54:03 -0000 1.10
+++ Button.java 5 Dec 2003 04:06:53 -0000 1.11
@@ -40,6 +40,10 @@
private String _onClickEvent = "";
+ public String getType() {
+ return BUTTON_TYPE;
+ }
+
Button( WebForm form ) {
super( form );
}
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- FormControl.java 19 Sep 2003 18:53:43 -0000 1.43
+++ FormControl.java 5 Dec 2003 04:06:53 -0000 1.44
@@ -50,6 +50,25 @@
private final String _onClickEvent;
private final WebForm _form;
+ public static final String UNDEFINED_TYPE = "undefined";
+ public static final String BUTTON_TYPE = "button";
+ public static final String RESET_BUTTON_TYPE = "reset";
+ public static final String SUBMIT_BUTTON_TYPE = "submit";
+ public static final String IMAGE_BUTTON_TYPE = "image";
+ public static final String RADIO_BUTTON_TYPE = "radio";
+ public static final String CHECKBOX_TYPE = "checkbox";
+ public static final String TEXT_TYPE = "text";
+ public static final String PASSWORD_TYPE = "password";
+ public static final String HIDDEN_TYPE = "hidden";
+ public static final String TEXTAREA_TYPE = "textarea";
+ public static final String FILE_TYPE = "file";
+ public static final String SINGLE_TYPE = "select-one";
+ public static final String MULTIPLE_TYPE = "select-multiple";
+
+ /**
+ * Return the type of the control, as seen from JavaScript.
+ */
+ abstract public String getType();
static ScriptableDelegate newSelectionOption() {
return new SelectionFormControl.Option();
@@ -292,10 +311,10 @@
} else if (node.getNodeName().equalsIgnoreCase( "select" )) {
return new SelectionFormControl( form, node );
} else if (node.getNodeName().equalsIgnoreCase( "button" )) {
- final String type = NodeUtils.getNodeAttribute( node, "type", "submit" );
- if (type.equalsIgnoreCase( "submit" )) {
+ final String type = NodeUtils.getNodeAttribute( node, "type", SUBMIT_BUTTON_TYPE );
+ if (type.equalsIgnoreCase( SUBMIT_BUTTON_TYPE )) {
return new SubmitButton( form, node );
- } else if (type.equalsIgnoreCase( "reset" )) {
+ } else if (type.equalsIgnoreCase( RESET_BUTTON_TYPE )) {
return new ResetButton( form, node );
} else {
return new Button( form, node );
@@ -303,22 +322,24 @@
} else if (!node.getNodeName().equalsIgnoreCase( "input" )) {
return null;
} else {
- final String type = NodeUtils.getNodeAttribute( node, "type", "text" );
- if (type.equalsIgnoreCase( "text" ) || type.equalsIgnoreCase( "password" )) {
+ final String type = NodeUtils.getNodeAttribute( node, "type", TEXT_TYPE );
+ if (type.equalsIgnoreCase( TEXT_TYPE )) {
return new TextFieldFormControl( form, node );
- } else if (type.equalsIgnoreCase( "hidden" )) {
+ } else if (type.equalsIgnoreCase( PASSWORD_TYPE )) {
+ return new PasswordFieldFormControl( form, node );
+ } else if (type.equalsIgnoreCase( HIDDEN_TYPE )) {
return new HiddenFieldFormControl( form, node );
- } else if (type.equalsIgnoreCase( "radio" )) {
+ } else if (type.equalsIgnoreCase( RADIO_BUTTON_TYPE )) {
return new RadioButtonFormControl( form, node );
- } else if (type.equalsIgnoreCase( "checkbox" )) {
+ } else if (type.equalsIgnoreCase( CHECKBOX_TYPE )) {
return new CheckboxFormControl( form, node );
- } else if (type.equalsIgnoreCase( "submit" ) || type.equalsIgnoreCase( "image" )) {
+ } else if (type.equalsIgnoreCase( SUBMIT_BUTTON_TYPE ) || type.equalsIgnoreCase( IMAGE_BUTTON_TYPE )) {
return new SubmitButton( form, node );
- } else if (type.equalsIgnoreCase( "button" )) {
+ } else if (type.equalsIgnoreCase( BUTTON_TYPE )) {
return new Button( form, node );
- } else if (type.equalsIgnoreCase( "reset" )) {
+ } else if (type.equalsIgnoreCase( RESET_BUTTON_TYPE )) {
return new ResetButton( form, node );
- } else if (type.equalsIgnoreCase( "file" )) {
+ } else if (type.equalsIgnoreCase( FILE_TYPE )) {
return new FileSubmitFormControl( form, node );
} else {
return new TextFieldFormControl( form, node );
@@ -347,6 +368,8 @@
public Object get( String propertyName ) {
if (propertyName.equalsIgnoreCase( "name" )) {
return FormControl.this.getName();
+ } else if (propertyName.equalsIgnoreCase( "type" )) {
+ return FormControl.this.getType();
} else {
return super.get( propertyName );
}
@@ -491,6 +514,10 @@
class RadioButtonFormControl extends BooleanFormControl {
+ public String getType() {
+ return RADIO_BUTTON_TYPE;
+ }
+
public RadioButtonFormControl( WebForm form, Node node ) {
super( form, node );
}
@@ -517,6 +544,10 @@
private String[] _allowedValues;
+ public String getType() {
+ return UNDEFINED_TYPE;
+ }
+
public RadioGroupFormControl( WebForm form ) {
super( form );
}
@@ -628,6 +659,9 @@
class CheckboxFormControl extends BooleanFormControl {
+ public String getType() {
+ return CHECKBOX_TYPE;
+ }
public CheckboxFormControl( WebForm form, Node node ) {
super( form, node );
@@ -666,7 +700,7 @@
}
-class TextFormControl extends FormControl {
+abstract class TextFormControl extends FormControl {
private String[] _value = new String[1];
private String[] _defaultValue;
@@ -738,6 +772,8 @@
public Object get( String propertyName ) {
if (propertyName.equalsIgnoreCase( "value" )) {
return getValues()[0];
+ } else if (propertyName.equalsIgnoreCase( "defaultValue" )) {
+ return _defaultValue[0];
} else {
return super.get( propertyName );
}
@@ -746,7 +782,7 @@
public void set( String propertyName, Object value ) {
if (propertyName.equalsIgnoreCase( "value" )) {
- _value[0] =_defaultValue[0] = value.toString();
+ _value[0] = value.toString();
} else {
super.set( propertyName, value );
}
@@ -756,6 +792,11 @@
class TextFieldFormControl extends TextFormControl {
+
+ public String getType() {
+ return TEXT_TYPE;
+ }
+
public TextFieldFormControl( WebForm form, Node node ) {
super( form, node, NodeUtils.getNodeAttribute( node, "value" ) );
supportAttribute( "maxlength" );
@@ -763,8 +804,23 @@
}
+class PasswordFieldFormControl extends TextFieldFormControl {
+
+ public String getType() {
+ return PASSWORD_TYPE;
+ }
+
+ public PasswordFieldFormControl(WebForm form, Node node) {
+ super(form, node);
+ }
+}
class HiddenFieldFormControl extends TextFieldFormControl {
+
+ public String getType() {
+ return HIDDEN_TYPE;
+ }
+
public HiddenFieldFormControl( WebForm form, Node node ) {
super( form, node );
}
@@ -800,11 +856,19 @@
return NodeUtils.asText( node.getChildNodes() );
}
+ public String getType() {
+ return TEXTAREA_TYPE;
+ }
+
}
class FileSubmitFormControl extends FormControl {
+ public String getType() {
+ return FILE_TYPE;
+ }
+
private UploadFileSpec _fileToUpload;
@@ -880,6 +944,10 @@
private Options _selectionOptions;
+
+ public String getType() {
+ return (isMultiValued()?MULTIPLE_TYPE:SINGLE_TYPE);
+ }
SelectionFormControl( WebForm form, Node node ) {
super( form, node );
Index: FrameHolder.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FrameHolder.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FrameHolder.java 27 Feb 2003 23:35:58 -0000 1.8
+++ FrameHolder.java 5 Dec 2003 04:06:53 -0000 1.9
@@ -125,7 +125,7 @@
private void createSubFrames( String targetName, String[] frameNames ) {
_subFrames.put( targetName, frameNames );
for (int i = 0; i < frameNames.length; i++) {
- _contents.put( frameNames[ i ], WebResponse.BLANK_RESPONSE );
+ _contents.put( frameNames[ i ], WebResponse.createBlankResponse() );
}
}
Index: ResetButton.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/ResetButton.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ResetButton.java 17 Feb 2003 23:54:41 -0000 1.3
+++ ResetButton.java 5 Dec 2003 04:06:53 -0000 1.4
@@ -29,6 +29,9 @@
**/
public class ResetButton extends Button {
+ public String getType() {
+ return RESET_BUTTON_TYPE;
+ }
ResetButton( WebForm form, Node node ) {
super( form, node );
Index: SubmitButton.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/SubmitButton.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SubmitButton.java 23 May 2003 03:09:27 -0000 1.16
+++ SubmitButton.java 5 Dec 2003 04:06:53 -0000 1.17
@@ -29,6 +29,10 @@
**/
public class SubmitButton extends Button {
+ public String getType() {
+ return (isImageButton()?IMAGE_BUTTON_TYPE:SUBMIT_BUTTON_TYPE);
+ }
+
/**
* Returns true if this submit button is an image map.
**/
@@ -71,7 +75,7 @@
SubmitButton( WebForm form, Node node ) {
super( form, node );
- _isImageButton = NodeUtils.getNodeAttribute( node, "type" ).equalsIgnoreCase( "image" );
+ _isImageButton = NodeUtils.getNodeAttribute( node, "type" ).equalsIgnoreCase( IMAGE_BUTTON_TYPE );
}
Index: TableCell.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/TableCell.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- TableCell.java 19 Sep 2003 18:53:43 -0000 1.15
+++ TableCell.java 5 Dec 2003 04:06:53 -0000 1.16
@@ -66,6 +66,12 @@
return super.getDOM();
}
+ /**
+ * Returns the underlying HTML Element.
+ */
+ public Element getElement() {
+ return _element;
+ }
//-------------------------------- HTMLElement methods ---------------------------------------
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- WebForm.java 24 Jun 2003 22:40:36 -0000 1.86
+++ WebForm.java 5 Dec 2003 04:06:53 -0000 1.87
@@ -584,6 +584,8 @@
public Object get( String propertyName ) {
if (propertyName.equals( "target" )) {
return getTarget();
+ } else if (propertyName.equals( "length" )) {
+ return new Integer(getFormControls().length);
} else {
final FormParameter parameter = getParameter( propertyName );
if (parameter != UNKNOWN_PARAMETER) return parameter.getScriptableObject();
@@ -937,6 +939,10 @@
if (_value != null) claimValueIsRequired( values, _value );
}
+
+ public String getType() {
+ return UNDEFINED_TYPE;
+ }
/**
* Returns the current value(s) associated with this control. These values will be transmitted to the server
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -r1.122 -r1.123
--- WebResponse.java 27 Aug 2003 02:16:06 -0000 1.122
+++ WebResponse.java 5 Dec 2003 04:06:53 -0000 1.123
@@ -768,8 +768,10 @@
//------------------------------------------ package members ------------------------------------------------
final static String BLANK_HTML = "";
- final static WebResponse BLANK_RESPONSE = new DefaultWebResponse( BLANK_HTML );
+ final static WebResponse createBlankResponse() {
+ return new DefaultWebResponse(BLANK_HTML);
+ }
WebWindow getWindow() {
return _window;
@@ -900,7 +902,7 @@
private void readTags( byte[] rawMessage ) throws UnsupportedEncodingException, MalformedURLException {
ByteTagParser parser = new ByteTagParser( rawMessage );
ByteTag tag = parser.getNextTag();
- while (tag != null) {
+ while (tag != null ) {
if (tag.getName().equalsIgnoreCase( "meta" )) processMetaTag( tag );
if (tag.getName().equalsIgnoreCase( "base" )) processBaseTag( tag );
if (tag.getName().equalsIgnoreCase( "frameset" )) _hasSubframes = true;
@@ -1081,7 +1083,7 @@
//=======================================================================================
- class ByteTag {
+ static class ByteTag {
ByteTag( byte[] buffer, int start, int length ) throws UnsupportedEncodingException {
_buffer = new String( buffer, start, length, WebResponse.getDefaultEncoding() ).toCharArray();
@@ -1155,22 +1157,31 @@
//=======================================================================================
- class ByteTagParser {
-
+ static class ByteTagParser {
ByteTagParser( byte[] buffer ) {
_buffer = buffer;
}
ByteTag getNextTag() throws UnsupportedEncodingException {
- _start = _end+1;
- while (_start < _buffer.length && _buffer[ _start ] != '<') _start++;
- for (_end =_start+1; _end < _buffer.length && _buffer[ _end ] != '>'; _end++);
- if (_end >= _buffer.length || _end < _start) return null;
- return new ByteTag( _buffer, _start+1, _end-_start-1 );
+ ByteTag byteTag = null;
+ do {
+ _start = _end+1;
+ while (_start < _buffer.length && _buffer[ _start ] != '<') _start++;
+ for (_end =_start+1; _end < _buffer.length && _buffer[ _end ] != '>'; _end++);
+ if (_end >= _buffer.length || _end < _start) return null;
+ byteTag = new ByteTag( _buffer, _start+1, _end-_start-1 );
+ if (byteTag.getName().equalsIgnoreCase("script")) {
+ _scriptDepth++;
+ return byteTag;
+ }
+ if (byteTag.getName().equalsIgnoreCase("/script")) _scriptDepth--;
+ } while (_scriptDepth > 0);
+ return byteTag;
}
+ private int _scriptDepth = 0;
private int _start = 0;
private int _end = -1;
Index: WebWindow.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebWindow.java 23 Sep 2003 12:13:43 -0000 1.15
+++ WebWindow.java 5 Dec 2003 04:06:53 -0000 1.16
@@ -157,7 +157,7 @@
final String frameName = getTargetFrame( request );
String urlString = request.getURLString().trim();
if (urlString.startsWith( "about:" )) {
- response = WebResponse.BLANK_RESPONSE;
+ response = WebResponse.createBlankResponse();
} else if (!HttpUnitUtils.isJavaScriptURL( urlString )) {
response = _client.newResponse( request, frameName );
} else {
|
|
From: Russell G. <rus...@us...> - 2003-12-05 04:06:57
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv27254/test/com/meterware/httpunit
Modified Files:
HtmlTablesTest.java WebPageTest.java
Log Message:
from Andrew Bickerton: Support form.length, control.type, control.defaultValue
Index: HtmlTablesTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- HtmlTablesTest.java 24 Mar 2003 03:22:11 -0000 1.17
+++ HtmlTablesTest.java 5 Dec 2003 04:06:53 -0000 1.18
@@ -294,6 +294,15 @@
assertEquals( "value of cell found from page", "value1", cell.asText() );
}
+ /**
+ * Test that the tag name can be extracted for a cell.
+ */
+ public void testCellTagName() throws Exception {
+ WebTable table = _wc.getResponse( getHostPath() + "/OneTable.html" ).getTables()[0];
+ assertEquals("Tag name of header cell", table.getTableCell(0,0).getElement().getTagName().toUpperCase(), "TH");
+ assertEquals("Tag name of non-header cell", table.getTableCell(0,1).getElement().getTagName().toUpperCase(), "TD");
+ }
+
private WebConversation _wc;
}
Index: WebPageTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebPageTest.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- WebPageTest.java 27 Aug 2003 02:16:06 -0000 1.33
+++ WebPageTest.java 5 Dec 2003 04:06:53 -0000 1.34
@@ -26,6 +26,7 @@
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -481,4 +482,99 @@
assertImplement( "elements with id 'link1'", simplePage.getElementsWithAttribute( "id", "link1" ), WebLink.class );
assertImplement( "elements with src '/images/arrow.gif'", simplePage.getElementsWithAttribute( "src", "/images/arrow.gif" ), WebImage.class );
}
+
+ /**
+ * Test the {@link WebResponse.ByteTagParser} to ensure that embedded JavaScript is skipped.
+ */
+ public void testByteTagParser() throws Exception {
+ final URL mainBaseURL = new URL(getHostPath() + "/Main/Base");
+ final URL targetBaseURL = new URL(getHostPath() + "/Target/Base");
+ final String targetWindow = "target";
+ final String document = "<html><head><title>main</title>\n"
+ + scriptToWriteAnotherDocument(simpleDocument(targetBaseURL), targetWindow)
+ + "<base href=\"" + mainBaseURL.toExternalForm() + "\">\n"
+ + "</head>\n<body>\nThis is a <a href=\"Link\">relative link</a>.\n"
+ + "</body>\n</html>\n";
+ WebResponse.ByteTagParser parser = new WebResponse.ByteTagParser(document.getBytes());
+
+ String[] expectedTags = {"html", "head", "title", "/title", "script", "/script", "base", "/head",
+ "body", "a", "/a", "/body", "/html"};
+ for (int i = 0; i < expectedTags.length; i++) {
+ final String tagName = parser.getNextTag().getName();
+ final String expectedTag = expectedTags[i];
+ assertEquals("Tag number "+i, expectedTag, tagName);
+ }
+ final WebResponse.ByteTag nextTag = parser.getNextTag();
+ assertNull("More tags than expected: " + nextTag + "...?", nextTag);
+ }
+
+ /**
+ * Test whether a base tag embedded within JavaScript in the header of a page confuses the parser.
+ */
+ public void testBaseTagWithinJavaScriptInHeader() throws Exception {
+ final URL mainBaseURL = new URL(getHostPath() + "/Main/Base");
+ final URL targetBaseURL = new URL(getHostPath() + "/Target/Base");
+ final String targetWindow = "target";
+ defineResource("main.html", "<html><head><title>main</title>\n"
+ + scriptToWriteAnotherDocument(simpleDocument(targetBaseURL), targetWindow)
+ + "<base href=\"" + mainBaseURL.toExternalForm() + "\">\n"
+ + "</head>\n<body>\nThis is a <a href=\"Link\">relative link</a>.\n"
+ + "</body>\n</html>\n");
+
+ WebConversation wc = new WebConversation();
+ final WebResponse response = wc.getResponse(getHostPath() + "/main.html");
+ assertEquals("Base URL of link in main document", mainBaseURL, response.getLinkWith("relative link").getBaseURL());
+
+ final WebResponse targetResponse = wc.getOpenWindow(targetWindow).getCurrentPage();
+ assertEquals("Base URL of link in target document", targetBaseURL, targetResponse.getLinkWith("relative link").getBaseURL());
+ }
+
+ /**
+ * Test whether a base tag embedded within JavaScript in the body of a page confuses the parser.
+ */
+ public void testBaseTagWithinJavaScriptInBody() throws Exception {
+ final URL mainBaseURL = new URL(getHostPath() + "/Main/Base");
+ final URL targetBaseURL = new URL(getHostPath() + "/Target/Base");
+ final String targetWindow = "target";
+ defineResource("main.html", "<html><head><title>main</title>\n"
+ + "<base href=\"" + mainBaseURL.toExternalForm() + "\">\n"
+ + "</head>\n<body>\nThis is a <a href=\"Link\">relative link</a>.\n"
+ + scriptToWriteAnotherDocument(simpleDocument(targetBaseURL), targetWindow)
+ + "</body>\n</html>\n");
+
+ WebConversation wc = new WebConversation();
+ final WebResponse response = wc.getResponse(getHostPath() + "/main.html");
+ assertEquals("Base URL of link in main document", mainBaseURL, response.getLinkWith("relative link").getBaseURL());
+
+ final WebResponse targetResponse = wc.getOpenWindow(targetWindow).getCurrentPage();
+ assertEquals("Base URL of link in target document", targetBaseURL, targetResponse.getLinkWith("relative link").getBaseURL());
+ }
+
+ /**
+ * Create a fragment of HTML defining JavaScript that writes a document into a different window.
+ * @param document the document to be written
+ * @param targetWindow the name of the target window to open
+ * @return a fragment of HTML text
+ */
+ private String scriptToWriteAnotherDocument(String document, String targetWindow) {
+ StringBuffer buff = new StringBuffer();
+ buff.append("<script language=\"JavaScript\">\n");
+ buff.append("target = window.open('', '" + targetWindow + "');\n");
+ buff.append("target.document.write('" + document + "');\n");
+ buff.append("target.document.close();\n");
+ buff.append("</script>\n");
+ return buff.toString();
+ }
+
+ /**
+ * Create a simple document with or without a 'base' tag and containing a relative link.
+ * @param baseUrl the base URL to insert, or null for no base tag
+ * @return the text of a very simple document
+ */
+ private String simpleDocument(final URL baseUrl) {
+ return "<html><head><title>Simple Page</title>"
+ + (baseUrl == null ? "" : "<base href=\"" + baseUrl.toExternalForm() + "\"></base>")
+ + "</head><body>This is a simple page with a <a href=\"Link\">relative link</a>.</body></html>";
+ }
+
}
|
|
From: Russell G. <rus...@us...> - 2003-12-05 04:06:56
|
Update of /cvsroot/httpunit/httpunit/sitedocs/doc In directory sc8-pr-cvs1:/tmp/cvs-serv27254/sitedocs/doc Modified Files: javascript-support.html Log Message: from Andrew Bickerton: Support form.length, control.type, control.defaultValue Index: javascript-support.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/sitedocs/doc/javascript-support.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- javascript-support.html 2 Oct 2003 02:43:46 -0000 1.5 +++ javascript-support.html 5 Dec 2003 04:06:53 -0000 1.6 @@ -120,6 +120,7 @@ <li>document - r/o the enclosing document</li> <li>elements - r/o an array of controls in the form</li> <li>action - r/w the target for any response from the form</li> +<li>length - r/o the number of controls in the form</li> <li><name> - the name of a control in the form</li> </ul> <h4>events</h4> @@ -157,6 +158,8 @@ <li>form - read-only - the form containing the input</li> <li>name - read-only - the name of the control</li> <li>tabindex - read-only - the index of the control for tabbing +<li>type - read-only - the name of the type of control</li> +<li>defaultValue - read-only - the value predefined for the control (text only)</li> </ul> <h4>methods</h4> <ul> |