[Httpunit-commit] SF.net SVN: httpunit: [975] trunk/httpunit
Brought to you by:
russgold
|
From: <rus...@us...> - 2008-05-16 19:45:10
|
Revision: 975
http://httpunit.svn.sourceforge.net/httpunit/?rev=975&view=rev
Author: russgold
Date: 2008-05-16 12:44:48 -0700 (Fri, 16 May 2008)
Log Message:
-----------
moved all pending tests to new pending-tests directory
Modified Paths:
--------------
trunk/httpunit/build.xml
trunk/httpunit/doc/release_notes.html
trunk/httpunit/src/com/meterware/httpunit/WebTable.java
trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java
trunk/httpunit/test/com/meterware/httpunit/FormParametersTest.java
trunk/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java
trunk/httpunit/test/com/meterware/httpunit/WebFrameTest.java
trunk/httpunit/test/com/meterware/httpunit/WebLinkTest.java
trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java
trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java
trunk/httpunit/test/com/meterware/servletunit/HttpServletResponseTest.java
trunk/httpunit/test/com/meterware/servletunit/ServletUnitSuite.java
Added Paths:
-----------
trunk/httpunit/pending-tests/
trunk/httpunit/pending-tests/com/
trunk/httpunit/pending-tests/com/meterware/
trunk/httpunit/pending-tests/com/meterware/httpunit/
trunk/httpunit/pending-tests/com/meterware/httpunit/NewParsingTests.java
trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/
trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingEngineTests.java
trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingTests.java
trunk/httpunit/pending-tests/com/meterware/httpunit/servletunit/
trunk/httpunit/pending-tests/com/meterware/httpunit/servletunit/NewServletUnitTests.java
trunk/httpunit/test/com/meterware/httpunit/javascript/AbstractJavaScriptTest.java
Removed Paths:
-------------
trunk/httpunit/test/com/meterware/servletunit/FormTableTest.java
Modified: trunk/httpunit/build.xml
===================================================================
--- trunk/httpunit/build.xml 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/build.xml 2008-05-16 19:44:48 UTC (rev 975)
@@ -105,7 +105,7 @@
< dependency group="rhino" artifact="rhino" version="1.5R4.1" website="http://www.mozilla.org/rhino/download.html" />
-->
<dependency group="junit" version="3.8.1" />
- <dependency group="nekohtml" version="1.9.6" unless="use.jtidy"/>
+ <dependency group="nekohtml" version="0.9.5" unless="use.jtidy"/>
<dependency group="servletapi" version="2.4" />
<dependency group="jtidy" version="4aug2000r7-dev"/>
<dependency group="xerces" version="2.6.1" artifact="xercesImpl"/>
Modified: trunk/httpunit/doc/release_notes.html
===================================================================
--- trunk/httpunit/doc/release_notes.html 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/doc/release_notes.html 2008-05-16 19:44:48 UTC (rev 975)
@@ -45,7 +45,7 @@
<h4>Notes:</h4>
<ol>
- <li>Upgraded NekoHTML to 1.9.6</li>
+ <li>Upgraded NekoHTML to 0.9.5</li>
<li>Upgraded Xerces to 2.6.1</li>
<li>Upgraded Rhino to 1.6R5</li>
<li>The PostMethodWebRequest.setMimeEncoded method has been removed. Mime encoding, if desired, should now be
@@ -61,6 +61,7 @@
keeping the dependent jars in cvs.
</li>
<li>When using the nekoHtml parser, tag and attribute names now default to lower case, rather than upper case as before</li>
+ <li>Empty cells from tables are no longer automatically purged when searching for a table by its first non-blank cell</li>
</ol>
<h4>Problems fixed:</h4>
<h5>Content and Parsing:</h5>
Added: trunk/httpunit/pending-tests/com/meterware/httpunit/NewParsingTests.java
===================================================================
--- trunk/httpunit/pending-tests/com/meterware/httpunit/NewParsingTests.java (rev 0)
+++ trunk/httpunit/pending-tests/com/meterware/httpunit/NewParsingTests.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -0,0 +1,133 @@
+package com.meterware.httpunit;
+/********************************************************************************************************************
+* $Id$
+*
+* Copyright (c) 2007-2008, 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
+* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
+* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or substantial portions
+* of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*
+*******************************************************************************************************************/
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class NewParsingTests extends HttpUnitTest {
+
+ private WebClient _wc;
+
+
+ public static void main(String args[]) {
+ junit.textui.TestRunner.run( suite() );
+ }
+
+
+ public static Test suite() {
+ return new TestSuite( NewParsingTests.class );
+ }
+
+
+ public NewParsingTests( String name ) {
+ super( name );
+ }
+
+
+ public void setUp() throws Exception {
+ super.setUp();
+ _wc = new WebConversation();
+ }
+
+
+
+ /**
+ * test a link that has a line break included
+ * @throws Exception on an unexpected exception - requires nekohtml 1.9.6 to pass
+ */
+ public void testLinkUrlAcrossLineBreaks() throws Exception {
+ WebConversation wc = new WebConversation();
+ defineWebPage( "Initial", "<a id='midbreak' href='http://loc\nalhost/somewhere'</a>" +
+ "<a id='endbreak' href='http://localhost/somewhere\n'</a>" );
+
+ WebResponse response = wc.getResponse( getHostPath() + "/Initial.html" );
+ String endbreak=response.getLinkWithID( "endbreak" ).getRequest().getURL().toExternalForm() ;
+ assertEquals( "URL with break at end", endbreak,"http://localhost/somewhere");
+ //System.err.println("endbreak='"+endbreak+"'");
+ String midbreak=response.getLinkWithID( "midbreak" ).getRequest().getURL().toExternalForm() ;
+ //System.err.println("midbreak='"+midbreak+"'");
+ assertEquals( "URL across linebreak", midbreak,"http://loc\nalhost/somewhere");
+ }
+
+
+ /**
+ * test for bug report [ 1393144 ] URL args in form action are sent for GET forms
+ * by Nathan Jakubiak
+ * @throws Exception on an uncaught error
+ */
+ public void testParamReplacement() throws Exception {
+ String expected = "/cgi-bin/bar?foo=a";
+ String nogood = "/cgi-bin/bar?arg=replaced&foo=a";
+ defineResource( nogood, "not good" );
+ defineResource( expected, "excellent" );
+ String html =
+ "<FORM NAME=Bethsheba METHOD=GET ACTION=/cgi-bin/bar?arg=replaced>" +
+ "<INPUT TYPE=TEXT NAME=foo>" +
+ "<INPUT TYPE=SUBMIT>" +
+ "</FORM>" +
+ "<br>" +
+ "<!--JavaScript submit:" +
+ "<a href=\"javascript:document.Bethsheba.submit()\">go</a>" +
+ "-->";
+ defineWebPage( "test", html );
+ WebResponse resp = _wc.getResponse( getHostPath() + "/test.html" );
+ WebForm form = resp.getFormWithName( "Bethsheba" );
+ form.setParameter( "foo", "a" );
+ resp = form.submit();
+ String foundURL = resp.getURL().toString();
+ assertTrue( foundURL.equals( expected ) );
+ }
+
+
+ /**
+ * test bug report [ 1376739 ] iframe tag not recognized if Javascript code contains '<'
+ * by Nathan Jakubiak
+ * @throws Exception on an uncaught error
+ */
+ public void testIFrameBug() throws Exception {
+ String html = "\"<SCRIPT LANGUAGE=\"JavaScript\">\n" +
+ "var b = 0 < 1;\n" +
+ "</SCRIPT>\n" +
+ "<iframe name=\"iframe_after_lessthan_in_javascript\"\n" +
+ "src=\"c.html\"></iframe>";
+ defineWebPage( "iframe", html );
+ WebResponse response = _wc.getFrameContents( "iframe_after_lessthan_in_javascript" );
+ assertNotNull( "Iframe was not recognized", response );
+ }
+
+
+ /**
+ * test for bug report [ 1156972 ] isWebLink doesn't recognize all anchor tags
+ * by fregienj
+ * @throws Exception on anuncaught error
+ */
+ public void testFindNonHrefLinks() throws Exception {
+ defineResource( "NonHref.html", "<html><head><title>NonHref Links</title></head><body>\n" +
+ "<a onclick='javascript:followlink()'>I am a clickable link after all</a>\n" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/NonHref.html" );
+ WebLink[] links = response.getLinks();
+ assertNotNull( links );
+ assertEquals( "number of non-href anchor tags", 1, links.length );
+ }
+
+}
Property changes on: trunk/httpunit/pending-tests/com/meterware/httpunit/NewParsingTests.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingEngineTests.java
===================================================================
--- trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingEngineTests.java (rev 0)
+++ trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingEngineTests.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -0,0 +1,120 @@
+package com.meterware.httpunit.javascript;
+/********************************************************************************************************************
+ * $Id$
+ *
+ * Copyright (c) 2007-2008, 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *******************************************************************************************************************/
+import com.meterware.httpunit.*;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * New features promised for scripting, but only implemented for new scripting engine.
+ */
+public class NewScriptingEngineTests extends AbstractJavaScriptTest {
+
+ public static void main( String args[] ) {
+ TestRunner.run( suite() );
+ }
+
+
+ public static TestSuite suite() {
+ return new TestSuite( NewScriptingEngineTests.class );
+ }
+
+
+ public NewScriptingEngineTests( String name ) {
+ super( name );
+ }
+
+
+ /**
+ * test jsFunction_createElement() - supplied by Mark Childerson
+ * also for bug report [ 1430378 ] createElement not found in JavaScript by Saliya Jinadasa
+ * @since 2008-03-26
+ * @throws Exception on uncaught problem
+ */
+ public void testCreateElement() throws Exception {
+ defineResource( "OnCommand.html",
+ "<html><head><title>Amazing!</title></head>" +
+ "<body onLoad='var elem=document.createElement(\"input\");elem.id=\"hellothere\";alert(elem.id);'></body>" );
+ WebConversation wc = new WebConversation();
+ boolean oldDebug = HttpUnitUtils.setEXCEPTION_DEBUG( false );
+ try {
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
+ // used to throw:
+ // com.meterware.httpunit.ScriptException: Event 'var elem=document.createElement("input");elem.id="hellothere";alert(elem.id);' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot find function createElement.
+ assertEquals( "Alert message", "hellothere", wc.popNextAlert() );
+ } finally {
+ HttpUnitUtils.setEXCEPTION_DEBUG( oldDebug );
+ }
+ }
+
+ /**
+ * test for cloneNode feature (asked for by Mark Childeson on 2008-04-01)
+ * @throws Exception on any uncaught problem
+ */
+ public void testCloneNode() throws Exception {
+ doTestJavaScript(
+ "dolly1=document.getElementById('Dolly');\n" +
+ "dolly2=dolly1.cloneNode(true);\n" +
+ "dolly1.firstChild.nodeValue += dolly2.firstChild.nodeValue;\n" +
+ "alert(dolly1.firsthChild.nodeValue);\n",
+ "<div id='Dolly'>Dolly </div>" );
+ }
+
+
+ /**
+ * test for bug report [ 1396877 ] Javascript:properties parentNode,firstChild, .. returns null
+ * by gklopp 2006-01-04 15:15
+ * @throws Exception on any uncaught problem
+ */
+ public void testDOM() throws Exception {
+ defineResource( "testSelect.html", "<html><head><script type='text/javascript'>\n" +
+ "<!--\n" +
+ "function testDOM() {\n" +
+ " var sel = document.getElementById('the_select');\n" +
+ " var p = sel.parentNode;\n" +
+ " var child = p.firstChild;\n" +
+ " alert('Parent : ' + p.nodeName);\n" +
+ " alert('First child : ' + child.nodeName);\n" +
+ "}\n" +
+ "-->\n" +
+ "</script></head>" +
+ "<body>" +
+ "<form name='the_form'>" +
+ " <table>" +
+ " <tr>" +
+ " <td>Selection :</td>" +
+ " <td>" +
+ " <select name='the_select'>" +
+ " <option value='option1Value'>option1</option>" +
+ " </select>" +
+ " </td>" +
+ " </tr>" +
+ " </table>" +
+ "</form>" +
+ "<script type='text/javascript'>testDOM();</script>" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ wc.getResponse( getHostPath() + "/testSelect.html" );
+ assertEquals( "Message 1", "TD", wc.popNextAlert().toUpperCase() );
+ assertEquals( "Message 2", "SELECT", wc.popNextAlert().toUpperCase() );
+ }
+
+}
Property changes on: trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingEngineTests.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingTests.java
===================================================================
--- trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingTests.java (rev 0)
+++ trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingTests.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -0,0 +1,190 @@
+package com.meterware.httpunit.javascript;
+/********************************************************************************************************************
+ * $Id$
+ *
+ * Copyright (c) 2007-2008, 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *******************************************************************************************************************/
+
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.HttpUnitOptions;
+import junit.textui.TestRunner;
+import junit.framework.TestSuite;
+
+/**
+ * Tests designed to track promised new features.
+ */
+public class NewScriptingTests extends AbstractJavaScriptTest {
+
+
+ public static void main( String args[] ) {
+ TestRunner.run( suite() );
+ }
+
+
+ public static TestSuite suite() {
+ return new TestSuite( NewScriptingTests.class );
+ }
+
+
+ public NewScriptingTests( String name ) {
+ super( name );
+ }
+
+
+ /**
+ * bug report [ 1286018 ] EcmaError in seemingly valid function
+ * by Stephane Mikaty
+ *
+ * @throws Exception on uncaught error
+ */
+ public void testArgumentsProperty() throws Exception {
+ String html = "<html><head><script language='JavaScript'> " +
+ " function dumpargs() { " +
+ " var args=dumpargs.arguments; " +
+ " var argdump=args.length; " +
+ " alert( args.length + ' arguments') " +
+ " for (i=0; i<args.length; i+=1) { " +
+ " alert( i + ': ' + args[i]') " +
+ " } " +
+ " } " +
+ "</script> " +
+ "<body onload=\"dumpargs('a','b')\"> " +
+ "</body></html> ";
+
+ defineResource( "OnCommand.html", html );
+ WebConversation wc = new WebConversation();
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "alert message 1", "2 arguments", wc.popNextAlert() );
+ assertEquals( "alert message 2", "0: a", wc.popNextAlert() );
+ assertEquals( "alert message 3", "1: b", wc.popNextAlert() );
+ }
+
+
+ /**
+ * test for bug report [ 1216567 ] Exception for large javascripts
+ * by Grzegorz Lukasik
+ * and bug report [ 1572117 ] ClassFormatError
+ * by Walter Meier
+ *
+ * @author Wolfgang Fahl 2008-04-05
+ */
+ public void testLargeJavaScript() throws Exception {
+ // create at least 64 KByte worth of Java script of the form
+ // var1000=1000;
+ // let's check the length;
+ // 1
+ // 12345678901234
+ // var1000=1000+1;
+ // so that is 14 chars avg per line - we'll do that many times for good measure ...
+ // you might want to adjust the numbers to your environment
+ // we do tests with 1000,10000,100000,1000000 lines in a logarithmic manner
+ // we do the optimization levels according to rhino docs:
+ //
+ // -2: with continuation
+ // -1: interpret
+ // 0: compile to Java bytecode, don't optimize
+ // 1..9: compile to Java bytecode, optimize
+ //
+ // set quicktest to false to get the full extent of the test
+ // the quick version only runs 1000 and 1000 lines for the levels -2 to 1
+ boolean quicktest = true;
+ boolean showProgress = false;
+ int linesToTest[] = {1000, 10000, 100000, 1000000};
+ int numTests = linesToTest.length;
+ int minOptLevel = -2;
+ int maxOptLevel = 9;
+ // when to expect a memory error
+ int expectMemoryExceededForLinesOver = 100000;
+ if (quicktest) {
+ numTests = 2;
+ minOptLevel = -1;
+ maxOptLevel = 1;
+ showProgress = false;
+ } else {
+ showProgress = true;
+ }
+ for (int optimizationLevel = minOptLevel; optimizationLevel <= maxOptLevel; optimizationLevel++) {
+ HttpUnitOptions.setJavaScriptOptimizationLevel( optimizationLevel );
+ // allow for different number of lines
+ for (int i = 1; i < numTests; i++) {
+ int fromj = 1;
+ int toj = linesToTest[i] + 1;
+ int lines = toj - fromj;
+ String testDesc = "test " + i + " for " + lines + " Lines (" + fromj + "-" + toj + ") at optlevel " + optimizationLevel;
+ if (showProgress)
+ System.out.println( testDesc );
+ int midj = (fromj + toj) / 2;
+ WebConversation wc = null;
+ StringBuffer prepareScript = new StringBuffer();
+ try {
+ // prepare code lines like
+ // var1000=1000+1;
+ // with the var<j>=<j>+1;\n pattern ...
+ // should be fun for the optimizer to remove all that unused code :-)
+ // we'll only use one variable later ...
+ for (int j = fromj; j < toj; j++) {
+ prepareScript.append( "var" );
+ prepareScript.append( j );
+ prepareScript.append( "=" );
+ prepareScript.append( j );
+ prepareScript.append( "+1;\n" );
+ }
+ prepareScript.append( "alert(var" + midj + ");" );
+ // off we go ... see what happens ...
+ wc = this.doTestJavaScript( prepareScript.toString() );
+ } catch (RuntimeException re) {
+ // currently we get:
+ // alert(var25500);}' failed: java.lang.IllegalArgumentException: out of range index
+ // for 50000 lines and opt level 0
+ if ((optimizationLevel >= 0) && (lines >= 50000)) {
+ this.warnDisabled( "testLargeJavaScript",
+ "fails with runtime Exception for " + lines + " lines at optimizationLevel " + optimizationLevel + " the default is level -1 so we only warn" );
+ } else {
+ throw re;
+ }
+ } catch (java.lang.OutOfMemoryError ome) {
+ if (lines >= expectMemoryExceededForLinesOver) {
+ this.warnDisabled( "testLargeJavaScript",
+ "fails with out of memory error for " + lines + " lines at optimizationLevel " + optimizationLevel + " we expect this for more than " + expectMemoryExceededForLinesOver + " lines" );
+ break;
+ } else {
+ throw ome;
+ }
+ } catch (java.lang.ClassFormatError cfe) {
+ // java.lang.ClassFormatError: Invalid method Code length 223990 in class file org/mozilla/javascript/gen/c1
+ if (optimizationLevel >= 0)
+ this.warnDisabled( "testLargeJavaScript",
+ "fails with class format error for " + lines + " lines at optimizationLevel " + optimizationLevel + " the default is level -1 so we only warn" );
+ else
+ throw cfe;
+ } // try
+
+ if (wc != null) {
+ String expected = "" + (midj + 1);
+ expected = expected.trim();
+ // if we get here the big javascript was actually executed
+ // e.g. interpreted and compiled and the alert message at it's end
+ // was fired to show the content of a variable in the far middle of the script
+ assertEquals( testDesc, expected, wc.popNextAlert() );
+ }
+ } // for
+ HttpUnitOptions.reset();
+ } // for optimizationLevel
+ }
+
+}
Property changes on: trunk/httpunit/pending-tests/com/meterware/httpunit/javascript/NewScriptingTests.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/httpunit/pending-tests/com/meterware/httpunit/servletunit/NewServletUnitTests.java
===================================================================
--- trunk/httpunit/pending-tests/com/meterware/httpunit/servletunit/NewServletUnitTests.java (rev 0)
+++ trunk/httpunit/pending-tests/com/meterware/httpunit/servletunit/NewServletUnitTests.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -0,0 +1,92 @@
+package com.meterware.httpunit.servletunit;
+/********************************************************************************************************************
+ * $Id$
+ *
+ * Copyright (c) 2007-2008, 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
+ * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+ * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *******************************************************************************************************************/
+import com.meterware.httpunit.HttpUnitTest;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.servletunit.ServletRunner;
+import com.meterware.servletunit.StatelessTest;
+
+import junit.framework.TestSuite;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * Tests for features pending addition to ServletUnit.
+ */
+public class NewServletUnitTests extends HttpUnitTest {
+
+ public static void main( String args[] ) {
+ junit.textui.TestRunner.run( suite() );
+ }
+
+
+ public static TestSuite suite() {
+ return new TestSuite( NewServletUnitTests.class );
+ }
+
+
+ public NewServletUnitTests( String name ) {
+ super( name );
+ }
+
+
+ /**
+ * test bug report [ 1534234 ] HttpServletResponse.isCommitted() always false? (+patch)
+ * by Olaf Klischat?
+ * @throws Exception on unexpected error
+ */
+ public void testIsCommitted() throws Exception {
+ ServletRunner sr = new ServletRunner();
+
+ WebRequest request = new GetMethodWebRequest(
+ "http://localhost/servlet/" + CheckIsCommittedServlet.class.getName() );
+ WebResponse response = sr.getResponse( request );
+ assertTrue( "The response should be committed", CheckIsCommittedServlet.isCommitted );
+ }
+
+
+ /**
+ * helper Servlet for bug report 1534234
+ */
+ public static class CheckIsCommittedServlet extends HttpServlet {
+
+ public static boolean isCommitted;
+
+
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
+ resp.setContentType( "text/html" );
+
+ PrintWriter pw = resp.getWriter();
+ pw.println( "anything" );
+ pw.flush();
+ pw.close();
+ isCommitted = resp.isCommitted();
+ }
+ }
+
+}
Property changes on: trunk/httpunit/pending-tests/com/meterware/httpunit/servletunit/NewServletUnitTests.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/httpunit/src/com/meterware/httpunit/WebTable.java
===================================================================
--- trunk/httpunit/src/com/meterware/httpunit/WebTable.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/src/com/meterware/httpunit/WebTable.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -336,23 +336,29 @@
static {
- MATCH_FIRST_NONBLANK_CELL = new HTMLElementPredicate() { // XXX find a way to do this w/o purging the table cells
+ MATCH_FIRST_NONBLANK_CELL = new HTMLElementPredicate() {
public boolean matchesCriteria( Object htmlElement, Object criteria ) {
WebTable table = ((WebTable) htmlElement);
- table.purgeEmptyCells();
- return table.getRowCount() > 0 &&
- HttpUnitUtils.matches( table.getCellAsText(0,0).trim(), (String) criteria );
- };
+ for (int row = 0; row < table.getRowCount(); row++) {
+ for (int col = 0; col < table.getColumnCount(); col++) {
+ if (HttpUnitUtils.matches( table.getCellAsText( row, col ).trim(), (String) criteria)) return true;
+ }
+ }
+ return false;
+ }
};
MATCH_FIRST_NONBLANK_CELL_PREFIX = new HTMLElementPredicate() { // XXX find a way to do this w/o purging the table cells
public boolean matchesCriteria( Object htmlElement, Object criteria ) {
WebTable table = ((WebTable) htmlElement);
- table.purgeEmptyCells();
- return table.getRowCount() > 0 &&
- HttpUnitUtils.hasPrefix( table.getCellAsText(0,0).toUpperCase().trim(), (String) criteria );
- };
+ for (int row = 0; row < table.getRowCount(); row++) {
+ for (int col = 0; col < table.getColumnCount(); col++) {
+ if (HttpUnitUtils.hasPrefix( table.getCellAsText( row, col ).trim(), (String) criteria)) return true;
+ }
+ }
+ return false;
+ }
};
Modified: trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java
===================================================================
--- trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/src/com/meterware/httpunit/controls/SelectionFormControl.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -144,9 +144,7 @@
if (!(value instanceof Number)) throw new RuntimeException( "selectedIndex must be set to an integer" );
_selectionOptions.setSelectedIndex( ((Number) value).intValue() );
} else if (propertyName.equalsIgnoreCase( "length" )) {
- // [ 1396896 ] Javascript: length property of a select element not writable
- // what now?
- throw new RuntimeException( "Options.setLength Not implemented yet" );
+ _selectionOptions.setLength( ((Number) value).intValue() );
} else {
super.set( propertyName, value );
}
Modified: trunk/httpunit/test/com/meterware/httpunit/FormParametersTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/FormParametersTest.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/test/com/meterware/httpunit/FormParametersTest.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -592,40 +592,9 @@
String paramValue=form.getParameterValue("submitButton");
assertTrue("the parameter value should be buttonLabel",paramValue.equals("buttonLabel"));
}
+
/**
- * test for bug report [ 1393144 ] URL args in form action are sent for GET forms
- * by Nathan Jakubiak
- */
- public void testParamReplacement() throws Exception {
- String expected="/cgi-bin/bar?foo=a";
- String nogood ="/cgi-bin/bar?arg=replaced&foo=a";
- defineResource( nogood , "not good" );
- defineResource( expected, "excellent" );
- String html=
- "<FORM NAME=Bethsheba METHOD=GET ACTION=/cgi-bin/bar?arg=replaced>"+
- "<INPUT TYPE=TEXT NAME=foo>"+
- "<INPUT TYPE=SUBMIT>"+
- "</FORM>"+
- "<br>"+
- "<!--JavaScript submit:"+
- "<a href=\"javascript:document.Bethsheba.submit()\">go</a>"+
- "-->";
- defineWebPage( "test", html);
- WebResponse resp= _wc.getResponse( getHostPath() + "/test.html" );
- WebForm form = resp.getFormWithName("Bethsheba");
- form.setParameter("foo", "a");
- resp = form.submit();
- String foundURL=resp.getURL().toString();
- boolean disabled=true;
- if (disabled) {
- this.warnDisabled("testParamReplacement","A",2, "bug 1393144 pending - waiting for patch");
- } else {
- // System.out.println("url: " + foundURL);
- assertTrue(foundURL.equals(expected));
- }
- }
- /**
* test for bug report
* [ 1510582 ] setParameter fails with <input type="file">
* by Julien HENRY
Modified: trunk/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/test/com/meterware/httpunit/HtmlTablesTest.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -19,9 +19,6 @@
* DEALINGS IN THE SOFTWARE.
*
*******************************************************************************************************************/
-import com.meterware.servletunit.ServletRunner;
-import com.meterware.servletunit.FormTableTest.FormTableServlet;
-
import junit.framework.TestSuite;
@@ -261,19 +258,13 @@
"</head>\n<body>\n"+
"<FORM METHOD=\"POST\" ACTION=\"/some/action\">\n"+
"<TABLE>\n"+
- "<TR><TD colspan=\"4\">Test Form:</TD></TR>\n\n"+
- "<TR>\n"+
- "<TD>*Contact Name:</TD>\n"+
- "<TD>"+
- "<input type=\"text\" size=\"21\" " +
- "name=\"CONTACT_NAME\" value=\"TIMOTHY O'LEARY\">"+
- "</TD>\n"+
- "<TD>Building Number:</TD>\n"+
- "<TD>"+
- "<input type=\"text\" size=\"7\" " +
- "name=\"BUILDING_NUMBER\" value=\"355\">"+
- "</TD>\n"+
- "</TR>\n"+
+ " <TR><TD colspan=\"4\">Test Form:</TD></TR>\n\n"+
+ " <TR>\n"+
+ " <TD>*Contact Name:</TD>\n"+
+ " <TD><input type=\"text\" size=\"21\" name=\"CONTACT_NAME\" value=\"TIMOTHY O'LEARY\"></TD>\n"+
+ " <TD>Building Number:</TD>\n"+
+ " <TD><input type=\"text\" size=\"7\" name=\"BUILDING_NUMBER\" value=\"355\"></TD>\n"+
+ " </TR>\n"+
"</TABLE>\n"+
"</FORM>";
@@ -282,13 +273,13 @@
* by AutoTest
*/
public void testColumnNumberInTable() throws Exception {
- defineWebPage( "Default",htmlForBug1043368);
- WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
- WebTable table = page.getTables()[0];
- assertNotNull( "didn't find table", table );
- // System.out.println( table.toString() );
- assertFalse( "wrong table",table.getCellAsText( 1, 0 ).indexOf("Contact Name") == -1 );
- assertEquals( "wrong column count", 4, table.getColumnCount());
+ defineWebPage( "Default", htmlForBug1043368 );
+ WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
+ WebTable table = page.getTableStartingWithPrefix( "Test Form" );
+ assertNotNull( "didn't find table", table );
+ // System.out.println( table.toString() );
+ assertFalse( "wrong table", table.getCellAsText( 1, 0 ).indexOf( "Contact Name" ) == -1 );
+ assertEquals( "wrong column count", 4, table.getColumnCount() );
}
@@ -341,6 +332,7 @@
WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
WebTable wt = page.getTableStartingWith( "Red" );
assertNotNull( "Did not find table starting with 'Red'", wt );
+ wt.purgeEmptyCells();
String[][] cells = wt.asText();
assertEquals( "Non-blank rows", 2, cells.length );
assertEquals( "Non-blank columns", 2, cells[0].length );
@@ -378,7 +370,9 @@
"</table>" );
WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
- String[][] cells = page.getTableStartingWith( "Title" ).asText();
+ WebTable table = page.getTableStartingWith( "Title" );
+ table.purgeEmptyCells();
+ String[][] cells = table.asText();
assertEquals( "Non-blank rows", 3, cells.length );
assertEquals( "Non-blank columns", 2, cells[0].length );
assertEquals( "cell at 1,1", "Value", cells[1][1] );
@@ -394,7 +388,9 @@
"</table>" );
WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
- String[][] cells = page.getTableStartingWith( "Title" ).asText();
+ WebTable table = page.getTableStartingWith( "Title" );
+ table.purgeEmptyCells();
+ String[][] cells = table.asText();
assertEquals( "Non-blank rows", 3, cells.length );
assertEquals( "Non-blank columns", 2, cells[0].length );
assertEquals( "cell at 1,1", "Value", cells[1][1] );
Modified: trunk/httpunit/test/com/meterware/httpunit/WebFrameTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/WebFrameTest.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/test/com/meterware/httpunit/WebFrameTest.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -512,25 +512,6 @@
assertEquals( "Number of links in iframe", 1, _wc.getFrameContents( "center" ).getLinks().length );
}
- /**
- * test bug report [ 1376739 ] iframe tag not recognized if Javascript code contains '<'
- * by Nathan Jakubiak
- * @throws Exception
- */
- public void testIFrameBug() throws Exception {
- String html="\"<SCRIPT LANGUAGE=\"JavaScript\">\n"+
- "var b = 0 < 1;\n"+
- "</SCRIPT>\n"+
- "<iframe name=\"iframe_after_lessthan_in_javascript\"\n"+
- "src=\"c.html\"></iframe>";
- defineWebPage( "iframe", html);
- try {
- WebResponse response = _wc.getFrameContents("iframe_after_lessthan_in_javascript");
- assertTrue(response!=null);
- } catch (Throwable th) {
- this.warnDisabled("testIFrameBug", "B",2,"patch needed for '"+th.getMessage()+"'");
- }
- }
/**
* test I Frame with a Form according to mail to mailinglist of 2008-03-25
Modified: trunk/httpunit/test/com/meterware/httpunit/WebLinkTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/WebLinkTest.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/test/com/meterware/httpunit/WebLinkTest.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -72,29 +72,6 @@
/**
- * test for bug report [ 1156972 ] isWebLink doesn't recognize all anchor tags
- * by fregienj
- * @throws Exception
- */
- public void testFindNonHrefLinks() throws Exception {
- defineResource( "NonHref.html", "<html><head><title>NonHref Links</title></head><body>\n"+
- "<a onclick='javascript:followlink()'>I am a clickable link after all</a>\n"+
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response=wc.getResponse( getHostPath() + "/NonHref.html" );
- WebLink[] links = response.getLinks();
- // TODO implement and test this
- // WebLink[] links = response.getAnchors();
- assertNotNull( links );
- boolean decided=true;
- if (decided) {
- assertEquals( 0, links.length );
- } else {
- this.warnDisabled("testFindNonHrefLinks()","C",2,"pending decision for bug report [ 1156972 ] -> does an <a> node to have href to be considered a link?");
- }
- }
-
- /**
* test for Bug report 1908117 by firebird74
* http://www.w3.org/Addressing/URL/url-spec.html
* says
@@ -159,25 +136,6 @@
}
- /**
- * test a link that has a line break included
- * @throws Exception
- */
- public void testLinkUrlAcrossLineBreaks() throws Exception {
- WebConversation wc = new WebConversation();
- defineWebPage( "Initial", "<a id='midbreak' href='http://loc\nalhost/somewhere'</a>" +
- "<a id='endbreak' href='http://localhost/somewhere\n'</a>" );
-
- WebResponse response = wc.getResponse( getHostPath() + "/Initial.html" );
- String endbreak=response.getLinkWithID( "endbreak" ).getRequest().getURL().toExternalForm() ;
- assertEquals( "URL with break at end", endbreak,"http://localhost/somewhere");
- //System.err.println("endbreak='"+endbreak+"'");
- String midbreak=response.getLinkWithID( "midbreak" ).getRequest().getURL().toExternalForm() ;
- //System.err.println("midbreak='"+midbreak+"'");
- assertEquals( "URL across linebreak", midbreak,"http://loc\nalhost/somewhere");
- }
-
-
public void testLinkReference() throws Exception {
WebLink link = _simplePage.getLinks()[0];
assertEquals( "URLString", "/other.html", link.getURLString() );
Added: trunk/httpunit/test/com/meterware/httpunit/javascript/AbstractJavaScriptTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/javascript/AbstractJavaScriptTest.java (rev 0)
+++ trunk/httpunit/test/com/meterware/httpunit/javascript/AbstractJavaScriptTest.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -0,0 +1,60 @@
+package com.meterware.httpunit.javascript;
+
+import com.meterware.httpunit.HttpUnitTest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebResponse;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: russgold
+ * Date: May 16, 2008
+ * Time: 3:20:40 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class AbstractJavaScriptTest extends HttpUnitTest {// set to true to get the static HTML Code on System.err
+public static boolean debugHTML=false;
+
+
+ public AbstractJavaScriptTest( String name ) {
+ super( name );
+ }
+
+
+ /**
+ * test the given javaScript code by putting it into a function and calling it
+ * as a prerequisite make the html code snippet available in the body of the page
+ * @param script - some javascript code to be called in a function
+ * @param html - a html code snippet
+ * @return
+ * @throws Exception
+ */
+ public WebConversation doTestJavaScript(String script,String html) throws Exception {
+ defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>\n" +
+ "function javaScriptFunction() {\n"+
+ script+
+ "}\n"+
+ "</script></head>" +
+ "<body>" +
+ html+"\n"+
+ "<a href=\"javascript:javaScriptFunction()\">go</a>" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ if (debugHTML) {
+ System.err.println(response.getText()+"\n");
+ }
+ response.getLinkWith( "go" ).click();
+ return wc;
+ }
+
+
+ /**
+ * test the given javaScript code by putting it into a function
+ * and calling it
+ * @param script the script to test
+ * @return the web client on which the test was run
+ */
+ public WebConversation doTestJavaScript(String script) throws Exception {
+ return doTestJavaScript(script,"");
+ }
+}
Property changes on: trunk/httpunit/test/com/meterware/httpunit/javascript/AbstractJavaScriptTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -315,35 +315,6 @@
assertEquals( "changed image source", "new.jpg", image.getSource() );
}
- /**
- * test jsFunction_createElement()
- * @author Mark Childerson
- * also for bug report [ 1430378 ] createElement not found in JavaScript
- * by Saliya Jinadasa
- * @since 2008-03-26
- * @throws Exception
- */
- public void testCreateElement() throws Exception {
- defineResource("OnCommand.html",
- "<html><head><title>Amazing!</title></head>"+
- "<body onLoad='var elem=document.createElement(\"input\");elem.id=\"hellothere\";alert(elem.id);'></body>");
- WebConversation wc = new WebConversation();
- boolean oldDebug= HttpUnitUtils.setEXCEPTION_DEBUG(false);
- try {
- wc.getResponse( getHostPath() + "/OnCommand.html" );
- // used to throw:
- // com.meterware.httpunit.ScriptException: Event 'var elem=document.createElement("input");elem.id="hellothere";alert(elem.id);' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot find function createElement.
- assertEquals( "Alert message", "hellothere", wc.popNextAlert() );
- } catch (ScriptException se) {
- if (HttpUnitOptions.DEFAULT_SCRIPT_ENGINE_FACTORY.equals(HttpUnitOptions.ORIGINAL_SCRIPTING_ENGINE_FACTORY)) {
- this.warnDisabled("testCreateElement","B",3, "not fixed for old scripting engine");
- } else {
- throw se;
- }
- } finally {
- HttpUnitUtils.setEXCEPTION_DEBUG(oldDebug);
- }
- }
public void testWriteToNewDocument() throws Exception {
Modified: trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2008-05-15 13:53:47 UTC (rev 974)
+++ trunk/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java 2008-05-16 19:44:48 UTC (rev 975)
@@ -39,7 +39,7 @@
* @author <a href="mailto:rus...@ht...">Russell Gold</a>
* @author Wolfgang Fahl - for compiling patches from the Source Forge web site 2008-03
**/
-public class ScriptingTest extends HttpUnitTest {
+public class ScriptingTest extends AbstractJavaScriptTest {
public static void main( String args[] ) {
TestRunner.run( suite() );
@@ -120,46 +120,9 @@
response.getLinks()[0].click();
assertEquals( "New page", "You made it!", wc.getCurrentPage().getText() );
}
- // set to true to get the static HTML Code on System.err
- public static boolean debugHTML=false;
+
/**
- * test the given javaScript code by putting it into a function and calling it
- * as a prerequisite make the html code snippet available in the body of the page
- * @param script - some javascript code to be called in a function
- * @param html - a html code snippet
- * @return
- * @throws Exception
- */
- public WebConversation doTestJavaScript(String script,String html) throws Exception {
- defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>\n" +
- "function javaScriptFunction() {\n"+
- script+
- "}\n"+
- "</script></head>" +
- "<body>" +
- html+"\n"+
- "<a href=\"javascript:javaScriptFunction()\">go</a>" +
- "</body></html>" );
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- if (debugHTML) {
- System.err.println(response.getText()+"\n");
- }
- response.getLinkWith( "go" ).click();
- return wc;
- }
-
- /**
- * test the given javaScript code by putting it into a function
- * and calling it
- * @param script
- */
- public WebConversation doTestJavaScript(String script) throws Exception {
- return doTestJavaScript(script,"");
- }
-
- /**
* test for bug report [ 1508516 ] Javascript method: "undefined" is not supported
* @throws Exception
*/
@@ -181,23 +144,6 @@
}
/**
- * test for cloneNode feature (asked for by Mark Childeson on 2008-04-01)
- * @throws Exception
- */
- public void testCloneNode() throws Exception {
- if (HttpUnitOptions.DEFAULT_SCRIPT_ENGINE_FACTORY.equals(HttpUnitOptions.ORIGINAL_SCRIPTING_ENGINE_FACTORY)) {
- warnDisabled("testCloneNode","B",3,"not fixed for old javascript engine");
- return;
- }
- WebConversation wc=doTestJavaScript(
- "dolly1=document.getElementById('Dolly');\n"+
- "dolly2=dolly1.cloneNode(true);\n"+
- "dolly1.firstChild.nodeValue += dolly2.firstChild.nodeValue;\n"+
- "alert(dolly1.firsthChild.nodeValue);\n",
- "<div id='Dolly'>Dolly </div>");
- }
-
- /**
* test javascript call to an included function
* @throws Exception
*/
@@ -1066,9 +1012,9 @@
defineResource( "NoScript.html", "No javascript here" );
defineResource( "HasScript.html", "Javascript is enabled!" );
defineResource( "Start.html", "<html><head>" +
-// " <noscript>" +
-// " <meta http-equiv='refresh' content='0;url=NoScript.html'>" +
-// " </noscript>" +
+ " <noscript>" +
+ " <meta http-equiv='refresh' content='0;url=NoScript.html'>" +
+ " </noscript>" +
"</head>" +
"<body onload='document.form.submit()'>" +
"<form name='form' action='HasScript.html'></form>" +
@@ -1077,59 +1023,54 @@
wc.getClientProperties().setAutoRefresh( true );
WebResponse response = wc.getResponse( getHostPath() + "/Start.html" );
assertEquals( "Result page ", "Javascript is enabled!", response.getText() );
- boolean nekoHtmlBugFixed = false; // waiting for response to http://sourceforge.net/tracker/index.php?func=detail&aid=1932445&group_id=195122&atid=952178
- if (!nekoHtmlBugFixed) {
- this.warnDisabled("testJavascriptDetectionTrick","A",2,"waiting for nekoHtml bug #1932445" );
- } else {
- HttpUnitOptions.setScriptingEnabled( false );
- response = wc.getResponse( getHostPath() + "/Start.html" );
- assertEquals( "Result page", "No javascript here", response.getText() );
- }
+ HttpUnitOptions.setScriptingEnabled( false );
+ response = wc.getResponse( getHostPath() + "/Start.html" );
+ assertEquals( "Result page", "No javascript here", response.getText() );
}
/**
- * @see https://sourceforge.net/forum/forum.php?thread_id=1808696&forum_id=20294
+ * https://sourceforge.net/forum/forum.php?thread_id=1808696&forum_id=20294
* by kauffman81
*/
public void testJavaScriptConfirmPopUp() throws Exception {
- String target="<html><body>After click we want to see this!</body></html>";
- defineResource( "Target.html", target);
- defineResource( "Popup.html","<html><head><script language='JavaScript'>"+
- "// This is the javascript that handles the onclick event\n"+
- "function verify_onBorrar(form){\n"+
- " alert(form.id);\n"+
- /* TODO check this javascript code
- * if uncommented it will throw
- com.meterware.httpunit.ScriptException: Event 'verify_onBorrar(this.form)' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "0" from undefined (httpunit#3)
- " for(var i = 0;i<form.selection[i].length;i++){\n"+
- " if(form.selection[i].checked){\n"+
- " if(confirm('blablabla')){\n"+
- " form.action = 'Target.html';\n"+
- " form.submit(); \n"+
- " } // if\n"+
- " } // if\n"+
- " } // for\n"+
- */
- "} // verify_onBorrar\n"+
- "</script></head>\n"+
- "<body>\n"+
- " <form id='someform' name='someform'>"+
- " <input type='button' id='button1' class='button' value='say hi' onclick=\"alert('hi')\"/>"+
- " <input type='button' id='delete' class='button' value='delete' onclick='verify_onBorrar(this.form)'/></form>\n"+
- " </form>\n"+
- "</body></html>");
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/Popup.html" );
- Button button1 = (Button) response.getElementWithID( "button1" );
- button1.click();
- String alert1=wc.popNextAlert();
- assertEquals("hi",alert1);
- Button button2 = (Button) response.getElementWithID( "delete" );
- button2.click();
- String alert2=wc.popNextAlert();
- // TODO activate this check
- // System.err.println("alert 2 is "+alert2);
- // assertEquals("someform",alert2);
+ String target = "<html><body>After click we want to see this!</body></html>";
+ defineResource( "Target.html", target );
+ defineResource( "Popup.html", "<html><head><script language='JavaScript'>" +
+ "// This is the javascript that handles the onclick event\n" +
+ "function verify_onBorrar(form){\n" +
+ " alert(form.id);\n" +
+ /* TODO check this javascript code
+ * if uncommented it will throw
+ com.meterware.httpunit.ScriptException: Event 'verify_onBorrar(this.form)' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "0" from undefined (httpunit#3)
+ " for(var i = 0;i<form.selection[i].length;i++){\n"+
+ " if(form.selection[i].checked){\n"+
+ " if(confirm('blablabla')){\n"+
+ " form.action = 'Target.html';\n"+
+ " form.submit(); \n"+
+ " } // if\n"+
+ " } // if\n"+
+ " } // for\n"+
+ */
+ "} // verify_onBorrar\n" +
+ "</script></head>\n" +
+ "<body>\n" +
+ " <form id='someform' name='someform'>" +
+ " <input type='button' id='button1' class='button' value='say hi' onclick=\"alert('hi')\"/>" +
+ " <input type='button' id='delete' class='button' value='delete' onclick='verify_onBorrar(this.form)'/></form>\n" +
+ " </form>\n" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/Popup.html" );
+ Button button1 = (Button) response.getElementWithID( "button1" );
+ button1.click();
+ String alert1 = wc.popNextAlert();
+ assertEquals( "hi", alert1 );
+ Button button2 = (Button) response.getElementWithID( "delete" );
+ button2.click();
+ String alert2 = wc.popNextAlert();
+ // TODO activate this check
+ // System.err.println("alert 2 is "+alert2);
+ // assertEquals("someform",alert2);
}
/**
@@ -1154,49 +1095,6 @@
String alert1=wc.popNextAlert();
assertEquals("somefunction called",alert1);
}
-
- /**
- * test for bug report [ 1396877 ] Javascript:properties parentNode,firstChild, .. returns null
- * by gklopp 2006-01-04 15:15
- * @throws Exception
- */
- public void testDOM() throws Exception {
- if (HttpUnitOptions.DEFAULT_SCRIPT_ENGINE_FACTORY.equals(HttpUnitOptions.ORIGINAL_SCRIPTING_ENGINE_FACTORY)) {
- warnDisabled("testDOM","B",3,"not fixed for old javascript engine");
- return;
- }
- defineResource( "testSelect.html", "<html><head><script type='text/javascript'>\n" +
- "<!--\n" +
- "function testDOM() {\n" +
- " var sel = document.getElementById('the_select');\n" +
- " var p = sel.parentNode;\n" +
- " var child = p.firstChild;\n" +
- " alert('Parent : ' + p.nodeName);\n" +
- " alert('First child : ' + child.nodeName);\n" +
- "}\n" +
- "-->\n" +
- "</script></head>" +
- "<body>" +
- "<form name='the_form'>" +
- " <table>" +
- " <tr>" +
- " <td>Selection :</td>" +
- " <td>" +
- " <select name='the_select'>" +
- " <option value='option1Value'>option1</option>" +
- " </select>" +
- " </td>" +
- " </tr>" +
- " </table>" +
- "</form>" +
- "<script type='text/javascript'>testDOM();</script>" +
- "</body></html>");
- WebConversation wc = new WebConversation();
- WebResponse response = wc.getRespo...
[truncated message content] |