[Httpunit-commit] SF.net SVN: httpunit: [914] trunk/httpunit
Brought to you by:
russgold
|
From: <rus...@us...> - 2008-04-06 16:35:15
|
Revision: 914
http://httpunit.svn.sourceforge.net/httpunit/?rev=914&view=rev
Author: russgold
Date: 2008-04-06 09:35:03 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
bug #1110071: javascript cannot increase length of a select control
Modified Paths:
--------------
trunk/httpunit/build.xml
trunk/httpunit/doc/release_notes.txt
trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java
trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java
Modified: trunk/httpunit/build.xml
===================================================================
--- trunk/httpunit/build.xml 2008-04-06 07:42:13 UTC (rev 913)
+++ trunk/httpunit/build.xml 2008-04-06 16:35:03 UTC (rev 914)
@@ -98,7 +98,7 @@
<target name="prepare_repository_classpath" depends="check_jars_dir" unless="have.local.jars">
<echo message="using repository classpath"/>
<!-- Russell's proxy -->
- <setproxy proxyhost="www-proxy.us.oracle.com" proxyport="80"/>
+ <!--<setproxy proxyhost="www-proxy.us.oracle.com" proxyport="80"/>-->
<typedef classpath="${jars.dir}/ant-dependencies.jar" resource="dependencies.properties" />
<dependencies pathId="base.classpath" fileSetId="distributed.jars">
<!-- get from http://www.ibiblio.org/maven/rhino/jars/ -->
Modified: trunk/httpunit/doc/release_notes.txt
===================================================================
--- trunk/httpunit/doc/release_notes.txt 2008-04-06 07:42:13 UTC (rev 913)
+++ trunk/httpunit/doc/release_notes.txt 2008-04-06 16:35:03 UTC (rev 914)
@@ -15,6 +15,8 @@
Revision History:
=================
+06-Apr-2008 bugfix 1110071: cannot increase length of a select control
+
for a full subversion log you might want to issue the subversion command:
svn log https://httpunit.svn.sourceforge.net/svnroot/httpunit
02-Apr-2008:
Modified: trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java
===================================================================
--- trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java 2008-04-06 07:42:13 UTC (rev 913)
+++ trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java 2008-04-06 16:35:03 UTC (rev 914)
@@ -185,7 +185,7 @@
public static class Option extends ScriptableDelegate implements SelectionOption {
- private String _text;
+ private String _text ="";
private String _value;
private boolean _defaultSelected;
private boolean _selected;
@@ -385,21 +385,16 @@
* Bug corrected : The length can be greater than the original length
*/
public void setLength( int length ) {
- if (length < 0) return;
- Option[] newArray = new Option[length ];
- if (length <= _options.length) {
- System.arraycopy( _options, 0,
- newArray, 0, length );
- } else {
- System.arraycopy( _options, 0, newArray, 0, _options.length );
- for (int i = _options.length; i < length; i++) {
- newArray[i] = new Option();
- newArray[i].setIndex(this, i);
- }
- }
- _options = newArray;
+ if (length < 0) return;
+ Option[] newArray = new Option[ length ];
+ System.arraycopy( _options, 0, newArray, 0, Math.min( length, _options.length ) );
+ for (int i = _options.length; i < length; i++) {
+ newArray[i] = new Option();
+ }
+ _options = newArray;
}
+
public void put( int i, SelectionOption option ) {
if (i < 0) return;
Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java 2008-04-06 07:42:13 UTC (rev 913)
+++ trunk/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java 2008-04-06 16:35:03 UTC (rev 914)
@@ -1154,6 +1154,8 @@
response.getLinks()[0].mouseOver();
assertEquals( "after change message", "selected #0", wc.popNextAlert() );
}
+
+
/**
* test that in case of an Index out of bounds problem an exception is thrown
* with a meaningful message (not nullpointer exception)
@@ -1601,6 +1603,43 @@
}
/**
+ * Verifies that it is possible to increase the size of a select control.
+ * @throws Exception on any unexpected error
+ */
+ public void testIncreaseSelectLength() throws Exception {
+ defineWebPage("Default", "<script language=JavaScript>\n" +
+ "function extend()\n"+
+ "{\n"+
+ "document.myForm.jobRoleID.options.length=2;\n" +
+ "document.myForm.jobRoleID.options[1].text='here';" +
+ "return true;\n" +
+ "}\n" +
+ "function viewSelect( choice ) {\n" +
+ " alert ('select has ' + choice.options.length + ' options' );\n" +
+ " alert ('last option is ' + choice.options[choice.options.length-1].text );\n" +
+ "}\n" +
+ "</script>" +
+ "<form name=myForm method=POST>" +
+ " <select name=\"jobRoleID\">" +
+ " <option value=\"0\" selected=\"selected\">Select Job Role</option>" +
+ " </select>" +
+ " <input type=\"text\" name=\"last_name\" value=\"Bloggs\">" +
+ "</form>" +
+ "<a href='#' onClick='viewSelect(document.myForm.jobRoleID); return false;'>a</href>\n" +
+ "<a href='#' onClick='extend(); return false;'>a</href>\n");
+ WebConversation wc = new WebConversation();
+ WebResponse wr = wc.getResponse( getHostPath() + "/Default.html" );
+ wr.getLinks()[ 0 ].click();
+ assertEquals( "1st message", "select has 1 options", wc.popNextAlert() );
+ assertEquals( "2nd message", "last option is Select Job Role", wc.popNextAlert() );
+ wr.getLinks()[ 1 ].click();
+ wr.getLinks()[ 0 ].click();
+ assertEquals( "3rd message", "select has 2 options", wc.popNextAlert() );
+ assertEquals( "4th message", "last option is here", wc.popNextAlert() );
+ }
+
+
+ /**
* 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'.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|