[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript ScriptingTest.java,1.57,1.58
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2004-02-12 05:41:08
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3036/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Do not replace main window on Window.open with null name Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- ScriptingTest.java 27 Oct 2003 21:16:10 -0000 1.57 +++ ScriptingTest.java 12 Feb 2004 05:36:29 -0000 1.58 @@ -2,7 +2,7 @@ /******************************************************************************************************************** * $Id$ * - * Copyright (c) 2002, Russell Gold + * Copyright (c) 2002-2004, 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 @@ -275,6 +275,36 @@ } + public void testWindowOpenWithEmptyName() 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', '' );\">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(); + + assertFalse( "No window opened", windowsOpened.isEmpty() ); + final WebWindow openedWindow = (WebWindow) windowsOpened.get( 0 ); + assertEquals( "New window message", "You made it!", openedWindow.getCurrentPage().getText() ); + assertEquals( "New window name", "", openedWindow.getName() ); + response.getLinks()[2].click(); + assertEquals( "Alert message", "window is not closed", wc.popNextAlert() ); + response.getLinks()[1].click(); + assertTrue( "Window was not closed", openedWindow.isClosed() ); + response.getLinks()[2].click(); + assertEquals( "Alert message", "window is closed", wc.popNextAlert() ); + } + + public void testJavascriptURLWithFragment() throws Exception { defineResource( "Target.txt", "You made it!", "text/plain" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + |