[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript DocumentScriptingTest.java,1.
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-03-09 20:35:51
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv26420/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java NekoEnhancedScriptingTest.java
Log Message:
support <noscript> tags
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DocumentScriptingTest.java 17 Nov 2002 16:43:41 -0000 1.5
+++ DocumentScriptingTest.java 9 Mar 2003 20:35:48 -0000 1.6
@@ -22,6 +22,7 @@
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import com.meterware.httpunit.*;
+import com.meterware.httpunit.parsing.HTMLParserFactory;
public class DocumentScriptingTest extends HttpUnitTest {
@@ -50,6 +51,7 @@
public void testDocumentFindForms() throws Exception {
+ HTMLParserFactory.useJTidyParser(); // TODO remove this line
defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
"function getFound( object ) {" +
" return (object == null) ? \"did not find \" : \"found \";" +
Index: NekoEnhancedScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/NekoEnhancedScriptingTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NekoEnhancedScriptingTest.java 23 Feb 2003 20:03:39 -0000 1.4
+++ NekoEnhancedScriptingTest.java 9 Mar 2003 20:35:48 -0000 1.5
@@ -21,10 +21,8 @@
*******************************************************************************************************************/
import junit.framework.TestSuite;
import junit.textui.TestRunner;
-import com.meterware.httpunit.HttpUnitTest;
-import com.meterware.httpunit.WebConversation;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.httpunit.WebLink;
+
+import com.meterware.httpunit.*;
/**
@@ -108,6 +106,34 @@
assertNotNull( "No default script link found", wr.getLinkWith( "JavaScript Working" ) );
assertNotNull( "No default script link found", wr.getLinkWith( "JavaScript 1.2 Working" ) );
assertNull( "VBScript link found", wr.getLinkWith( "VBScript" ) );
+ }
+
+
+ public void testNoScriptSections() throws Exception {
+ defineResource( "OnCommand.html", "<html><head><title>something</title></head>" +
+ "<body>" +
+ "<script language='JavaScript'>" +
+ "document.write( '<a id=here href=about:blank>' );" +
+ "document.writeln( document.title );" +
+ "document.write( '</a>' );" +
+ "</script>" +
+ "<noscript>" +
+ "<a href='#' id='there'>anything</a>" +
+ "</noscript>" +
+ "</body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ WebLink link = response.getLinkWithID( "here" );
+ assertNotNull( "The link was not found", link );
+ assertEquals( "Link contents", "something", link.asText() );
+ assertNull( "Should not have found link in noscript", response.getLinkWithID( "there" ) );
+
+ HttpUnitOptions.setScriptingEnabled( false );
+ response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ link = response.getLinkWithID( "there" );
+ assertNotNull( "The link was not found", link );
+ assertEquals( "Link contents", "anything", link.asText() );
+ assertNull( "Should not have found scripted link", response.getLinkWithID( "here" ) );
}
|