[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript DocumentScriptingTest.java,1.
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-10-24 13:29:00
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv28243/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java ScriptingTest.java
Log Message:
Added support for document.write
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DocumentScriptingTest.java 9 Oct 2002 13:50:10 -0000 1.2
+++ DocumentScriptingTest.java 24 Oct 2002 13:28:55 -0000 1.3
@@ -44,7 +44,7 @@
defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
"<body onLoad='alert(\"Window title is \" + document.title)'></body>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "Window title is Amazing!", wc.popNextAlert() );
}
@@ -64,7 +64,7 @@
"<form name='realform'></form>" +
"</body></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "found 1 form(s)", wc.popNextAlert() );
assertEquals( "Alert message", "found form 'realform'", wc.popNextAlert() );
assertEquals( "Alert message", "found form 'forms[\'realform\']'", wc.popNextAlert() );
@@ -90,7 +90,7 @@
"<a href='else'>second</a>" +
"</body></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "found 2 link(s)", wc.popNextAlert() );
assertEquals( "Alert message", "found link 'reallink'", wc.popNextAlert() );
assertEquals( "Alert message", "found link 'links[reallink]'", wc.popNextAlert() );
@@ -99,6 +99,23 @@
}
+ public void testEmbeddedDocumentWrite() throws Exception {
+ defineResource( "OnCommand.html", "<html><head><title>something</title></head>" +
+ "<body>" +
+ "<script language='JavaScript'>" +
+ "document.write( '<a id=here href=about:blank>' );" +
+ "document.write( document.title );" +
+ "document.write( '</a>' );" +
+ "</script>" +
+ "</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() );
+ }
+
+
public void testJavaScriptObjectIdentity() throws Exception {
defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
"function compareLinks() { " +
@@ -114,7 +131,7 @@
"<a href='else'>second</a>" +
"</body></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "they are the same", wc.popNextAlert() );
}
@@ -129,7 +146,6 @@
"</body></html>" );
WebConversation wc = new WebConversation();
WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- WebForm form = response.getFormWithName( "realform" );
response.getLinkWithName( "first" ).mouseOver();
assertEquals( "form action", "run", wc.popNextAlert() );
response.getLinkWithName( "second" ).mouseOver();
@@ -220,7 +236,7 @@
"<a href='sample.html'>green</a>" +
"</body></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", getHostPath() + "/demo.html", wc.popNextAlert() );
assertEquals( "Alert message", getHostPath() + "/guide.html", wc.popNextAlert() );
assertEquals( "Alert message", getHostPath() + "/search.html", wc.popNextAlert() );
@@ -246,7 +262,7 @@
"<img name='2ndimage' src='pict2.gif'>\n" +
"</body></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "found 2 images(s)", wc.popNextAlert() );
assertEquals( "Alert message", "found image 'realimage'", wc.popNextAlert() );
assertEquals( "Alert message", "found image 'images[realimage]'", wc.popNextAlert() );
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- ScriptingTest.java 13 Oct 2002 01:09:32 -0000 1.40
+++ ScriptingTest.java 24 Oct 2002 13:28:55 -0000 1.41
@@ -78,7 +78,7 @@
WebConversation wc = new WebConversation();
GetMethodWebRequest request = new GetMethodWebRequest( "javascript:alert( 'Hi there!' )" );
assertEquals( "Javascript URL", "javascript:alert( 'Hi there!' )", request.getURL().toExternalForm() );
- WebResponse response = wc.getResponse( request );
+ wc.getResponse( request );
assertEquals( "Alert message", "Hi there!", wc.popNextAlert() );
}
@@ -131,7 +131,7 @@
defineResource( "OnCommand.html", "<html><head></head>" +
"<body onLoad='alert(\"Ouch!\")'></body>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertNotNull( "No alert detected", wc.getNextAlert() );
assertEquals( "Alert message", "Ouch!", wc.popNextAlert() );
assertNull( "Alert should have been removed", wc.getNextAlert() );
@@ -206,7 +206,7 @@
"// end hiding -->" +
"</script></body></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "Cheese!", wc.popNextAlert() );
}
@@ -218,7 +218,7 @@
"parseInt(n,32);" +
"</script></head></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
}
@@ -228,7 +228,7 @@
"</script></head>" +
"<body onLoad='sayCheese()'></body>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message", "Cheese!", wc.popNextAlert() );
}
@@ -321,7 +321,6 @@
"<body onload=\"window.name='main'; alert ('opener ' + (window.opener ? 'found' : 'not defined') );\">" +
"<a href='#' onClick=\"window.open( '" + getHostPath() + "/Target.html', 'sample' );\">go</a>" +
"</body></html>" );
- final ArrayList windowsOpened = new ArrayList();
WebConversation wc = new WebConversation();
WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "main window name", "main", wc.getMainWindow().getName() );
@@ -357,7 +356,7 @@
"</frameset></html>" );
WebConversation wc = new WebConversation();
- WebResponse response = wc.getResponse( getHostPath() + "/Frames.html" );
+ wc.getResponse( getHostPath() + "/Frames.html" );
WebResponse blue = wc.getFrameContents( "blue" );
blue.getLinkWith( "show" ).click();
@@ -427,7 +426,7 @@
WebConversation wc = new WebConversation();
wc.getClientProperties().setApplicationID( "Internet Explorer", "Mozilla", "4.0" );
wc.getClientProperties().setPlatform( "JVM" );
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message 1", "appName=Internet Explorer", wc.popNextAlert() );
assertEquals( "Alert message 2", "appCodeName=Mozilla", wc.popNextAlert() );
assertEquals( "Alert message 3", "appVersion=4.0", wc.popNextAlert() );
@@ -450,7 +449,7 @@
HttpUnitOptions.setExceptionsThrownOnScriptError( true );
WebConversation wc = new WebConversation();
wc.getClientProperties().setAvailableScreenSize( 1024, 752 );
- WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ wc.getResponse( getHostPath() + "/OnCommand.html" );
assertEquals( "Alert message 1", "dimensions=1024x752", wc.popNextAlert() );
assertNull( "Alert should have been removed", wc.getNextAlert() );
}
|