[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript ScriptingTest.java,1.59,1.60
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2004-06-21 23:25:35
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1806/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: bug #974675: Window.open( ..., _self ) now updates current window. Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- ScriptingTest.java 12 Feb 2004 06:23:09 -0000 1.59 +++ ScriptingTest.java 21 Jun 2004 23:25:27 -0000 1.60 @@ -305,6 +305,29 @@ } + public void testWindowOpenWithSelf() 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', '_self' );\">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(); + + assertTrue( "Opened a new window", windowsOpened.isEmpty() ); + assertEquals( "New window message", "You made it!", wc.getCurrentPage().getText() ); + assertEquals( "Number of open windows", 1, wc.getOpenWindows().length ); + } + + public void testJavascriptURLWithFragment() throws Exception { defineResource( "Target.txt", "You made it!", "text/plain" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + |