httpunit-commit Mailing List for httpunit (Page 48)
Brought to you by:
russgold
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(31) |
Oct
(39) |
Nov
(18) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(8) |
Feb
(5) |
Mar
(8) |
Apr
(25) |
May
(20) |
Jun
(23) |
Jul
(28) |
Aug
(10) |
Sep
(3) |
Oct
(32) |
Nov
(61) |
Dec
(24) |
2002 |
Jan
(50) |
Feb
(34) |
Mar
(35) |
Apr
(3) |
May
(25) |
Jun
(25) |
Jul
(30) |
Aug
(146) |
Sep
(49) |
Oct
(156) |
Nov
(121) |
Dec
(54) |
2003 |
Jan
(12) |
Feb
(79) |
Mar
(88) |
Apr
(26) |
May
(67) |
Jun
(29) |
Jul
(8) |
Aug
(16) |
Sep
(20) |
Oct
(17) |
Nov
|
Dec
(5) |
2004 |
Jan
|
Feb
(40) |
Mar
(30) |
Apr
(5) |
May
|
Jun
(83) |
Jul
(34) |
Aug
(20) |
Sep
(44) |
Oct
(46) |
Nov
|
Dec
(14) |
2005 |
Jan
(4) |
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
|
Feb
|
Mar
(26) |
Apr
(8) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
(36) |
May
(38) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
|
Nov
(18) |
Dec
(4) |
2009 |
Jan
|
Feb
(2) |
Mar
(3) |
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(35) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(9) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
(18) |
Nov
(1) |
Dec
|
From: Russell G. <rus...@us...> - 2002-10-13 23:53:51
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting In directory usw-pr-cvs1:/tmp/cvs-serv17745/src/com/meterware/httpunit/scripting Modified Files: ScriptableDelegate.java ScriptingEngine.java Added Files: Input.java Log Message: Refactored to permit partial evaluation of scripts ***** Error reading new file[Errno 2] No such file or directory: 'Input.java' Index: ScriptableDelegate.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting/ScriptableDelegate.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ScriptableDelegate.java 9 Oct 2002 13:50:10 -0000 1.4 +++ ScriptableDelegate.java 13 Oct 2002 23:53:48 -0000 1.5 @@ -1,5 +1,4 @@ package com.meterware.httpunit.scripting; - /******************************************************************************************************************** * $Id$ * @@ -24,7 +23,7 @@ /** * An interface for objects which will be accessible via scripting. * - * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ abstract public class ScriptableDelegate { @@ -34,6 +33,7 @@ public void executeScript( String script ) {} public boolean performEvent( String eventScript ) { return true; } public String getURLContents( String urlString ) { return null; } + public ScriptingEngine newScriptingEngine( ScriptableDelegate child ) { return this; } }; @@ -98,6 +98,11 @@ public ScriptingEngine getScriptEngine() { return _scriptEngine != null ? _scriptEngine : NULL_SCRIPT_ENGINE; + } + + + public ScriptingEngine getScriptEngine( ScriptableDelegate child ) { + return getScriptEngine().newScriptingEngine( child ); } } Index: ScriptingEngine.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/scripting/ScriptingEngine.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ScriptingEngine.java 23 Aug 2002 19:33:13 -0000 1.2 +++ ScriptingEngine.java 13 Oct 2002 23:53:48 -0000 1.3 @@ -23,7 +23,7 @@ /** * - * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ public interface ScriptingEngine { @@ -44,5 +44,11 @@ * Evaluates the specified string as JavaScript. Will return null if the script has no return value. */ public String getURLContents( String urlString ); + + + /** + * Returns a new scripting engine for the specified delegate. + */ + public ScriptingEngine newScriptingEngine( ScriptableDelegate child ); } |
From: Russell G. <rus...@us...> - 2002-10-13 23:53:51
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv17745/src/com/meterware/httpunit Modified Files: Button.java FormControl.java FormParameter.java HTMLPage.java SubmitButton.java WebForm.java WebImage.java WebLink.java WebResponse.java Log Message: Refactored to permit partial evaluation of scripts Index: Button.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Button.java 27 Aug 2002 16:26:03 -0000 1.2 +++ Button.java 13 Oct 2002 23:53:48 -0000 1.3 @@ -31,18 +31,16 @@ **/ public class Button extends FormControl { - protected final WebForm _form; private String _onClickEvent = ""; Button( WebForm form ) { - _form = form; + super( form ); } Button( WebForm form, Node node ) { - super( node ); - _form = form; + super( form, node ); _onClickEvent = NodeUtils.getNodeAttribute( node, "onclick" ); } @@ -67,12 +65,6 @@ final protected boolean doOnClickEvent() { return _onClickEvent.length() == 0 || getScriptableObject().doEvent( _onClickEvent ); - } - - - final - protected WebForm getForm() { - return _form; } Index: FormControl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- FormControl.java 2 Oct 2002 16:37:56 -0000 1.27 +++ FormControl.java 13 Oct 2002 23:53:48 -0000 1.28 @@ -19,10 +19,7 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ -import com.meterware.httpunit.scripting.SelectionOptions; -import com.meterware.httpunit.scripting.SelectionOption; -import com.meterware.httpunit.scripting.ScriptableDelegate; -import com.meterware.httpunit.scripting.NamedDelegate; +import com.meterware.httpunit.scripting.*; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; @@ -39,6 +36,8 @@ /** * Represents a control in an HTML form. + * + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ abstract class FormControl { @@ -51,11 +50,13 @@ private final boolean _disabled; private final String _onChangeEvent; private final String _onClickEvent; + private final WebForm _form; private Scriptable _scriptable; - FormControl() { + FormControl( WebForm form ) { + _form = form; _id = ""; _name = ""; _valueAttribute = ""; @@ -66,7 +67,8 @@ } - FormControl( Node node ) { + FormControl( WebForm form, Node node ) { + _form = form; _id = NodeUtils.getNodeAttribute( node, "id" ); _name = NodeUtils.getNodeAttribute( node, "name" ); _valueAttribute = NodeUtils.getNodeAttribute( node, "value" ); @@ -106,11 +108,19 @@ } + final protected WebForm getForm() { + return _form; + } + + /** * Returns a scriptable object which can act as a proxy for this control. */ ScriptableDelegate getScriptableObject() { - if (_scriptable == null) _scriptable = newScriptable(); + if (_scriptable == null) { + _scriptable = newScriptable(); + _scriptable.setScriptEngine( getForm().getScriptableObject().getScriptEngine( _scriptable ) ); + } return _scriptable; } @@ -263,9 +273,9 @@ if (node.getNodeType() != Node.ELEMENT_NODE) { return null; } else if (node.getNodeName().equals( "textarea" )) { - return new TextAreaFormControl( node ); + return new TextAreaFormControl( form, node ); } else if (node.getNodeName().equals( "select" )) { - return new SelectionFormControl( node ); + return new SelectionFormControl( form, node ); } else if (node.getNodeName().equalsIgnoreCase( "button" )) { final String type = NodeUtils.getNodeAttribute( node, "type", "submit" ); if (type.equalsIgnoreCase( "submit" )) { @@ -280,13 +290,13 @@ } else { final String type = NodeUtils.getNodeAttribute( node, "type", "text" ); if (type.equalsIgnoreCase( "text" ) || type.equalsIgnoreCase( "password" )) { - return new TextFieldFormControl( node ); + return new TextFieldFormControl( form, node ); } else if (type.equalsIgnoreCase( "hidden" )) { - return new HiddenFieldFormControl( node ); + return new HiddenFieldFormControl( form, node ); } else if (type.equalsIgnoreCase( "radio" )) { - return new RadioButtonFormControl( node ); + return new RadioButtonFormControl( form, node ); } else if (type.equalsIgnoreCase( "checkbox" )) { - return new CheckboxFormControl( node ); + return new CheckboxFormControl( form, node ); } else if (type.equalsIgnoreCase( "submit" ) || type.equalsIgnoreCase( "image" )) { return new SubmitButton( form, node ); } else if (type.equalsIgnoreCase( "button" )) { @@ -294,15 +304,15 @@ } else if (type.equalsIgnoreCase( "reset" )) { return new ResetButton( form, node ); } else if (type.equalsIgnoreCase( "file" )) { - return new FileSubmitFormControl( node ); + return new FileSubmitFormControl( form, node ); } else { - return new TextFieldFormControl( node ); + return new TextFieldFormControl( form, node ); } } } - class Scriptable extends ScriptableDelegate implements NamedDelegate { + class Scriptable extends ScriptableDelegate implements Input { public String getName() { return FormControl.this.getName(); @@ -367,8 +377,8 @@ } } - public BooleanFormControl( Node node ) { - super( node ); + public BooleanFormControl( WebForm form, Node node ) { + super( form, node ); _isChecked = _isCheckedDefault = NodeUtils.isNodeAttributePresent( node, "checked" ); } @@ -436,8 +446,8 @@ class RadioButtonFormControl extends BooleanFormControl { - public RadioButtonFormControl( Node node ) { - super( node ); + public RadioButtonFormControl( WebForm form, Node node ) { + super( form, node ); } @@ -462,7 +472,8 @@ private String[] _allowedValues; - public RadioGroupFormControl() { + public RadioGroupFormControl( WebForm form ) { + super( form ); } @@ -560,8 +571,8 @@ class CheckboxFormControl extends BooleanFormControl { - public CheckboxFormControl( Node node ) { - super( node ); + public CheckboxFormControl( WebForm form, Node node ) { + super( form, node ); } @@ -609,8 +620,8 @@ private String[] _defaultValue; - public TextFormControl( Node node, String defaultValue ) { - super( node ); + public TextFormControl( WebForm form, Node node, String defaultValue ) { + super( form, node ); _defaultValue = new String[] { defaultValue }; } @@ -693,16 +704,16 @@ class TextFieldFormControl extends TextFormControl { - public TextFieldFormControl( Node node ) { - super( node, NodeUtils.getNodeAttribute( node, "value" ) ); + public TextFieldFormControl( WebForm form, Node node ) { + super( form, node, NodeUtils.getNodeAttribute( node, "value" ) ); } } class HiddenFieldFormControl extends TextFieldFormControl { - public HiddenFieldFormControl( Node node ) { - super( node ); + public HiddenFieldFormControl( WebForm form, Node node ) { + super( form, node ); } @@ -719,8 +730,8 @@ class TextAreaFormControl extends TextFormControl { - public TextAreaFormControl( Node node ) { - super( node, getDefaultValue( node ) ); + public TextAreaFormControl( WebForm form, Node node ) { + super( form, node, getDefaultValue( node ) ); if (!node.getNodeName().equalsIgnoreCase( "textarea" )) { throw new RuntimeException( "Not a textarea element" ); @@ -740,8 +751,8 @@ private UploadFileSpec _fileToUpload; - public FileSubmitFormControl( Node node ) { - super( node ); + public FileSubmitFormControl( WebForm form, Node node ) { + super( form, node ); } @@ -790,8 +801,8 @@ private Options _selectionOptions; - SelectionFormControl( Node node ) { - super( node ); + SelectionFormControl( WebForm form, Node node ) { + super( form, node ); if (!node.getNodeName().equalsIgnoreCase( "select" )) throw new RuntimeException( "Not a select element" ); _multiSelect = NodeUtils.isNodeAttributePresent( node, "multiple" ); Index: FormParameter.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormParameter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FormParameter.java 3 Oct 2002 12:35:18 -0000 1.1 +++ FormParameter.java 13 Oct 2002 23:53:48 -0000 1.2 @@ -30,7 +30,7 @@ * Represents the aggregate of all form controls with a particular name. This permits us to abstract setting * values so that changing a control type does not break a test. * - * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ class FormParameter { @@ -46,7 +46,7 @@ if (_name == null) _name = control.getName(); if (!_name.equalsIgnoreCase( control.getName() )) throw new RuntimeException( "all controls should have the same name" ); if (control.isExclusive()) { - getRadioGroup().addRadioButton( (RadioButtonFormControl) control ); + getRadioGroup( control.getForm() ).addRadioButton( (RadioButtonFormControl) control ); } else { _controlList.add( control ); } @@ -178,9 +178,9 @@ } - private RadioGroupFormControl getRadioGroup() { + private RadioGroupFormControl getRadioGroup( WebForm form ) { if (_group == null) { - _group = new RadioGroupFormControl(); + _group = new RadioGroupFormControl( form ); _controlList.add( _group ); } return _group; Index: HTMLPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- HTMLPage.java 13 Oct 2002 01:09:32 -0000 1.11 +++ HTMLPage.java 13 Oct 2002 23:53:48 -0000 1.12 @@ -41,11 +41,13 @@ /** * This class represents an HTML page returned from a request. * - * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> * @author <a href="mailto:bx...@bi...">Benoit Xhenseval</a> **/ public class HTMLPage extends ParsedHTML { + private Scriptable _scriptable; + public HTMLPage( WebResponse response, URL url, String parentTarget, String pageText, String characterSet ) throws SAXException { super( response, url, parentTarget, getDOM( url, pageText ), characterSet ); @@ -227,7 +229,11 @@ Scriptable getScriptableObject() { - return new Scriptable(); + if (_scriptable == null) { + _scriptable = new Scriptable(); + _scriptable.setScriptEngine( getResponse().getScriptableObject().getScriptEngine( _scriptable ) ); + } + return _scriptable; } //---------------------------------- private members -------------------------------- Index: SubmitButton.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/SubmitButton.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- SubmitButton.java 20 Aug 2002 15:09:28 -0000 1.12 +++ SubmitButton.java 13 Oct 2002 23:53:48 -0000 1.13 @@ -45,7 +45,7 @@ * submits the form. */ public void click() throws IOException, SAXException { - if (doOnClickEvent()) _form.submit( this ); + if (doOnClickEvent()) getForm().submit( this ); } Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- WebForm.java 4 Oct 2002 15:18:37 -0000 1.67 +++ WebForm.java 13 Oct 2002 23:53:48 -0000 1.68 @@ -39,6 +39,8 @@ * This class represents a form in an HTML page. Users of this class may examine the parameters * defined for the form, the structure of the form (as a DOM), or the text of the form. They * may also create a {@link WebRequest} to simulate the submission of the form. + * + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ public class WebForm extends WebRequestSource { private static final FormParameter UNKNOWN_PARAMETER = new FormParameter(); @@ -347,7 +349,10 @@ * Returns an object which provides scripting access to this form. **/ public Scriptable getScriptableObject() { - if (_scriptable == null) _scriptable = new Scriptable(); + if (_scriptable == null) { + _scriptable = new Scriptable(); + _scriptable.setScriptEngine( getBaseResponse().getScriptableObject().getDocument().getScriptEngine( _scriptable ) ); + } return _scriptable; } @@ -427,7 +432,7 @@ * Records a parameter defined by including it in the destination URL. **/ protected void addPresetParameter( String name, String value ) { - _presets.add( new PresetFormParameter( name, value ) ); + _presets.add( new PresetFormParameter( this, name, value ) ); } @@ -796,7 +801,8 @@ class PresetFormParameter extends FormControl { - PresetFormParameter( String name, String value ) { + PresetFormParameter( WebForm form, String name, String value ) { + super( form ); _name = name; _value = value; } Index: WebImage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebImage.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WebImage.java 4 Oct 2002 02:16:00 -0000 1.7 +++ WebImage.java 13 Oct 2002 23:53:48 -0000 1.8 @@ -28,8 +28,9 @@ /** + * Represents an image in an HTML document. * - * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> **/ public class WebImage extends FixedURLWebRequestSource { @@ -83,7 +84,10 @@ * Returns an object which provides scripting access to this link. **/ public Scriptable getScriptableObject() { - if (_scriptable == null) _scriptable = new Scriptable(); + if (_scriptable == null) { + _scriptable = new Scriptable(); + _scriptable.setScriptEngine( getBaseResponse().getScriptableObject().getDocument().getScriptEngine( _scriptable ) ); + } return _scriptable; } Index: WebLink.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebLink.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- WebLink.java 4 Oct 2002 15:18:37 -0000 1.31 +++ WebLink.java 13 Oct 2002 23:53:48 -0000 1.32 @@ -34,7 +34,7 @@ * structure of the link (as a DOM), or create a {@link WebRequest} to simulate clicking * on the link. * - * @author <a href="mailto:rus...@ac...">Russell Gold</a> + * @author <a href="mailto:rus...@ht...">Russell Gold</a> * @author <a href="mailto:ben...@av...>Benoit Xhenseval</a> **/ public class WebLink extends FixedURLWebRequestSource { @@ -157,7 +157,10 @@ * Returns an object which provides scripting access to this link. **/ Scriptable getScriptableObject() { - if (_scriptable == null) _scriptable = new Scriptable(); + if (_scriptable == null) { + _scriptable = new Scriptable(); + _scriptable.setScriptEngine( getBaseResponse().getScriptableObject().getDocument().getScriptEngine( _scriptable ) ); + } return _scriptable; } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.90 retrieving revision 1.91 diff -u -r1.90 -r1.91 --- WebResponse.java 13 Oct 2002 01:09:32 -0000 1.90 +++ WebResponse.java 13 Oct 2002 23:53:48 -0000 1.91 @@ -560,8 +560,12 @@ } - public HTMLPage.Scriptable getDocument() throws SAXException { - return getReceivedPage().getScriptableObject(); + public HTMLPage.Scriptable getDocument() { + try { + return getReceivedPage().getScriptableObject(); + } catch (SAXException e) { + throw new RuntimeException( e.toString() ); + } } |
From: Russell G. <rus...@us...> - 2002-10-13 01:09:35
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv510/doc Modified Files: release_notes.txt Log Message: Handle comments in script sections one at a time Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.190 retrieving revision 1.191 diff -u -r1.190 -r1.191 --- release_notes.txt 11 Oct 2002 01:26:22 -0000 1.190 +++ release_notes.txt 13 Oct 2002 01:09:31 -0000 1.191 @@ -10,6 +10,13 @@ Revision History: +12-Oct-2002 +Acknowledgements: + Thanks to Richard Harris for finding a case where the handling of JavaScript comments was not working. + +Problems fixed: + 1. Under certain circumstances, the first line of a JavaScript section was being treated as though commented out. + 10-Oct-2002 Problems fixed: 1. Window.open was implemented with parameters backwards in 8-Oct-2002 build |
From: Russell G. <rus...@us...> - 2002-10-13 01:09:35
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv510/src/com/meterware/httpunit Modified Files: HTMLPage.java WebResponse.java Log Message: Handle comments in script sections one at a time Index: HTMLPage.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HTMLPage.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- HTMLPage.java 4 Oct 2002 00:40:28 -0000 1.10 +++ HTMLPage.java 13 Oct 2002 01:09:32 -0000 1.11 @@ -28,6 +28,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Vector; +import java.util.ArrayList; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -76,24 +77,24 @@ /** * Returns the contents of any script tags on the page, concatenated. */ - public String getScripts() throws SAXException { + public String[] getScripts() throws SAXException { NodeList nl = ((Document) getOriginalDOM()).getElementsByTagName( "script" ); - StringBuffer sb = new StringBuffer(); + ArrayList scripts = new ArrayList(); for (int i = 0; i < nl.getLength(); i++) { Node scriptNode = nl.item(i); String src = NodeUtils.getNodeAttribute( scriptNode, "src", null ); if (src == null) { - sb.append( NodeUtils.asText( scriptNode.getChildNodes() ) ); + scripts.add( NodeUtils.asText( scriptNode.getChildNodes() ) ); } else { try { WebRequest req = new GetMethodWebRequest( getBaseURL(), src ); - sb.append( getResponse().getWindow().getResource( req ).getText() ); + scripts.add( getResponse().getWindow().getResource( req ).getText() ); } catch (IOException e) { throw new RuntimeException( "Error loading included script: " + e ); } } } - return sb.toString(); + return (String[]) scripts.toArray( new String[ scripts.size() ] ); } Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.89 retrieving revision 1.90 diff -u -r1.89 -r1.90 --- WebResponse.java 11 Oct 2002 01:26:22 -0000 1.89 +++ WebResponse.java 13 Oct 2002 01:09:32 -0000 1.90 @@ -576,7 +576,10 @@ public void load() throws SAXException { - runScript( getReceivedPage().getScripts() ); + final String[] scripts = getReceivedPage().getScripts(); + for (int i = 0; i < scripts.length; i++) { + runScript( scripts[i] ); + } doEvent( getReceivedPage().getOnLoadEvent() ); } |
From: Russell G. <rus...@us...> - 2002-10-13 01:09:35
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv510/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Handle comments in script sections one at a time Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- ScriptingTest.java 11 Oct 2002 01:26:22 -0000 1.39 +++ ScriptingTest.java 13 Oct 2002 01:09:32 -0000 1.40 @@ -211,6 +211,17 @@ } + public void testComment() throws Exception { + defineResource( "OnCommand.html", "<html><head><script language='JavaScript'><!--" + + "//--></script><script language='JavaScript'>" + "\n" + + "var n=0;" + "\n" + + "parseInt(n,32);" + + "</script></head></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + } + + public void testIncludedFunction() throws Exception { defineResource( "saycheese.js", "function sayCheese() { alert( \"Cheese!\" ); }" ); defineResource( "OnCommand.html", "<html><head><script language='JavaScript' src='saycheese.js'>" + |
From: Russell G. <rus...@us...> - 2002-10-11 01:26:26
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv1468/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Added support for closing windows Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- ScriptingTest.java 11 Oct 2002 00:23:20 -0000 1.38 +++ ScriptingTest.java 11 Oct 2002 01:26:22 -0000 1.39 @@ -225,8 +225,10 @@ public void testWindowOpen() throws Exception { defineResource( "Target.html", "You made it!" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + - "<body>" + - "<a href='#' onClick=\"window.open( '" + getHostPath() + "/Target.html', 'sample' );\">go</a>" + + "<body><script language='JavaScript'>var otherWindow;</script>" + + "<a href='#' onClick=\"otherWindow = window.open( '" + getHostPath() + "/Target.html', 'sample' );\">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(); @@ -238,8 +240,15 @@ response.getLinks()[0].click(); assertFalse( "No window opened", windowsOpened.isEmpty() ); - assertEquals( "New window message", "You made it!", ((WebWindow) windowsOpened.get( 0 )).getCurrentPage().getText() ); - assertEquals( "New window name", "sample", ((WebWindow) windowsOpened.get( 0 )).getName() ); + final WebWindow openedWindow = (WebWindow) windowsOpened.get( 0 ); + assertEquals( "New window message", "You made it!", openedWindow.getCurrentPage().getText() ); + assertEquals( "New window name", "sample", 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() ); } |
From: Russell G. <rus...@us...> - 2002-10-11 01:26:26
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv1468/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: Added support for closing windows Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- JavaScript.java 10 Oct 2002 20:20:36 -0000 1.30 +++ JavaScript.java 11 Oct 2002 01:26:22 -0000 1.31 @@ -319,11 +319,6 @@ } - public boolean jsGet_closed() { - return false; - } - - public Screen jsGet_screen() { return _screen; } @@ -373,6 +368,7 @@ public void jsFunction_close() { + getDelegate().close(); } |
From: Russell G. <rus...@us...> - 2002-10-11 01:26:26
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv1468/src/com/meterware/httpunit Modified Files: WebClient.java WebResponse.java WebWindow.java Log Message: Added support for closing windows Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- WebClient.java 11 Oct 2002 00:23:20 -0000 1.41 +++ WebClient.java 11 Oct 2002 01:26:22 -0000 1.42 @@ -464,6 +464,15 @@ } + void close( WebWindow window ) { + if (!_openWindows.contains( window )) throw new IllegalStateException( "Window is already closed" ); + _openWindows.remove( window ); + if (_openWindows.isEmpty()) _openWindows.add( new WebWindow( this ) ); + if (window.equals( _mainWindow )) _mainWindow = (WebWindow) _openWindows.get(0); + reportWindowClosed( window ); + } + + private WebWindow getTargetWindow( WebWindow requestWindow, String target ) { return WebRequest.NEW_WINDOW.equalsIgnoreCase( target ) ? null : requestWindow; } @@ -482,6 +491,17 @@ } + private void reportWindowClosed( WebWindow window ) { + List listeners; + + synchronized (_windowListeners) { + listeners = new ArrayList( _windowListeners ); + } + + for (Iterator i = listeners.iterator(); i.hasNext();) { + ((WebWindowListener) i.next()).windowClosed( this, window ); + } + } //------------------------------------------ package members ------------------------------------ Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- WebResponse.java 11 Oct 2002 00:08:10 -0000 1.88 +++ WebResponse.java 11 Oct 2002 01:26:22 -0000 1.89 @@ -596,6 +596,11 @@ } + public void close() { + if (getFrameName().equals( WebRequest.TOP_FRAME )) _window.close(); + } + + /** * Returns the value of the named property. Will return null if the property does not exist. **/ @@ -611,6 +616,8 @@ return WebResponse.this._url.toExternalForm(); } else if (propertyName.equalsIgnoreCase( "opener" )) { return getFrameName().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null; + } else if (propertyName.equalsIgnoreCase( "closed" )) { + return (getFrameName().equals( WebRequest.TOP_FRAME ) && _window.isClosed()) ? Boolean.TRUE : Boolean.FALSE; } else { try { return getSubframeContents( propertyName ).getScriptableObject(); Index: WebWindow.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- WebWindow.java 10 Oct 2002 21:10:19 -0000 1.6 +++ WebWindow.java 11 Oct 2002 01:26:22 -0000 1.7 @@ -44,9 +44,25 @@ /** The web response containing the reference that opened this window **/ private WebResponse _opener; + /** True if this window has been closed. **/ + private boolean _closed; + /** + * Returns the web client associated with this window. + */ public WebClient getClient() { return _client; + } + + + public boolean isClosed() { + return _closed; + } + + + public void close() { + if (!_closed) _client.close( this ); + _closed = true; } |
From: Russell G. <rus...@us...> - 2002-10-11 01:26:26
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv1468/doc Modified Files: Javascript-support.html release_notes.txt todo.txt Log Message: Added support for closing windows Index: Javascript-support.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- Javascript-support.html 11 Oct 2002 00:08:09 -0000 1.24 +++ Javascript-support.html 11 Oct 2002 01:26:22 -0000 1.25 @@ -9,6 +9,7 @@ <h3>Window</h3> <h4>properties</h4> <ul> +<li>closed - true if the window has been closed</li> <li>document - the associated Document object</li> <li>frames - an array of subframes of this window</li> <li>location - r/w full URL only</li> @@ -28,6 +29,7 @@ <h4>methods</h4> <ul> <li>alert() - queues up an alert message, accessible via WebResponse.getNextAlert() or popNextAlert()</li> +<li>close() - closes the window</li> <li>confirm() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response. By default, the callback returns true. Users may change this by supplying an implementation of DialogResponder.</li> <li>prompt() - invokes a callback supplied via WebClient.setDialogResponder to return the user's response</li> Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.189 retrieving revision 1.190 diff -u -r1.189 -r1.190 --- release_notes.txt 11 Oct 2002 00:23:20 -0000 1.189 +++ release_notes.txt 11 Oct 2002 01:26:22 -0000 1.190 @@ -19,6 +19,9 @@ 1. Added support for Window.parent 2. Added support for Window.<subframe-name> 3. Added WebWindow.getOpenedWindow() to return a window by its name. + 4. You may now close a window by calling window.close(). This will trigger any active listeners. If the window closed + the main window, another window will be promoted to that status. + 5. Added support for Window.close() and Window.closed 9-Oct-2002 Acknowledgements: Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- todo.txt 11 Oct 2002 00:23:20 -0000 1.36 +++ todo.txt 11 Oct 2002 01:26:22 -0000 1.37 @@ -1,5 +1,4 @@ High priority: -o closing windows o better support for use with proxy server Medium priority: |
From: Russell G. <rus...@us...> - 2002-10-11 01:26:25
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv1468/test/com/meterware/httpunit Modified Files: WebWindowTest.java Log Message: Added support for closing windows Index: WebWindowTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebWindowTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- WebWindowTest.java 4 Oct 2002 15:19:25 -0000 1.2 +++ WebWindowTest.java 11 Oct 2002 01:26:22 -0000 1.3 @@ -44,8 +44,6 @@ public WebWindowTest( String name ) { super( name ); } - - public void testNewTarget() throws Exception { defineResource( "goHere", "You made it!" ); defineWebPage( "start", "<a href='goHere' id='go' target='_blank'>here</a>" ); @@ -59,6 +57,23 @@ assertEquals( "Main page in original window", initialPage, main.getCurrentPage() ); WebWindow other = wc.getOpenWindows()[1]; assertEquals( "New window contents", "You made it!", other.getCurrentPage().getText() ); + + main.close(); + assertTrue( "Original main window is not closed", main.isClosed() ); + assertFalse( "New window has been closed", other.isClosed() ); + + assertEquals( "Num open windows", 1, wc.getOpenWindows().length ); + assertEquals( "Main window", other, wc.getMainWindow() ); + } + + + public void testCloseOnlyWindow() throws Exception { + defineResource( "goHere", "You made it!" ); + WebConversation wc = new WebConversation(); + WebWindow original = wc.getMainWindow(); + wc.getMainWindow().close(); + assertTrue( "Main window did not close", original.isClosed() ); + assertNotNull( "No main window was created", wc.getMainWindow() ); } @@ -67,6 +82,7 @@ defineWebPage( "start", "<a href='goHere' id='go' target='_blank'>here</a>" ); final ArrayList newWindowContents = new ArrayList(); + final ArrayList closedWindows = new ArrayList(); WebClient wc = new WebConversation(); wc.addWindowListener( new WebWindowListener() { public void windowOpened( WebClient client, WebWindow window ) { @@ -77,12 +93,21 @@ } } public void windowClosed( WebClient client, WebWindow window ) { + closedWindows.add( window ); } }); WebResponse initialPage = wc.getResponse( getHostPath() + "/start.html" ); initialPage.getLinkWithID( "go" ).click(); assertFalse( "No window opened", newWindowContents.isEmpty() ); assertEquals( "New window contents", "You made it!", newWindowContents.get(0) ); + assertTrue( "Window already reported closed", closedWindows.isEmpty() ); + + WebWindow main = wc.getMainWindow(); + WebWindow other = wc.getOpenWindows()[1]; + other.close(); + assertEquals( "Main window", main, wc.getMainWindow() ); + assertFalse( "No windows reported closed", closedWindows.isEmpty() ); + assertEquals( "Window reported closed", other, closedWindows.get(0) ); } |
From: Russell G. <rus...@us...> - 2002-10-11 00:23:23
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv15699/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Added WebClient.getOpenWindow function Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- ScriptingTest.java 11 Oct 2002 00:08:10 -0000 1.37 +++ ScriptingTest.java 11 Oct 2002 00:23:20 -0000 1.38 @@ -258,8 +258,10 @@ response.getLinks()[0].click(); assertFalse( "No window opened", windowsOpened.isEmpty() ); - assertEquals( "New window message", "", ((WebWindow) windowsOpened.get( 0 )).getCurrentPage().getText() ); - assertEquals( "New window name", "sample", ((WebWindow) windowsOpened.get( 0 )).getName() ); + final WebWindow openedWindow = (WebWindow) windowsOpened.get( 0 ); + assertEquals( "New window message", "", openedWindow.getCurrentPage().getText() ); + assertEquals( "New window name", "sample", openedWindow.getName() ); + assertEquals( "Window by name", openedWindow, wc.getOpenWindow( "sample" ) ); } |
From: Russell G. <rus...@us...> - 2002-10-11 00:23:23
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv15699/src/com/meterware/httpunit Modified Files: WebClient.java Log Message: Added WebClient.getOpenWindow function Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- WebClient.java 10 Oct 2002 21:10:19 -0000 1.40 +++ WebClient.java 11 Oct 2002 00:23:20 -0000 1.41 @@ -65,6 +65,16 @@ } + public WebWindow getOpenWindow( String name ) { + if (name == null || name.length() == 0) return null; + for (Iterator i = _openWindows.iterator(); i.hasNext();) { + WebWindow window = (WebWindow) i.next(); + if (name.equals( window.getName() )) return window; + } + return null; + } + + /** * Submits a GET method request and returns a response. * @exception SAXException thrown if there is an error parsing the retrieved page |
From: Russell G. <rus...@us...> - 2002-10-11 00:23:22
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv15699/doc Modified Files: release_notes.txt todo.txt Log Message: Added WebClient.getOpenWindow function Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.188 retrieving revision 1.189 diff -u -r1.188 -r1.189 --- release_notes.txt 11 Oct 2002 00:08:09 -0000 1.188 +++ release_notes.txt 11 Oct 2002 00:23:20 -0000 1.189 @@ -18,6 +18,7 @@ Additions: 1. Added support for Window.parent 2. Added support for Window.<subframe-name> + 3. Added WebWindow.getOpenedWindow() to return a window by its name. 9-Oct-2002 Acknowledgements: Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- todo.txt 11 Oct 2002 00:08:09 -0000 1.35 +++ todo.txt 11 Oct 2002 00:23:20 -0000 1.36 @@ -1,12 +1,9 @@ High priority: o closing windows -o WebClient.getOpenWindow( name ) o better support for use with proxy server Medium priority: o replace JTidy with a simpler custom parser or NekoHTML -o Enable client code to write directly to the output stream of a message body request -o Provide customization for table to text o Support optional tags which hide their contents (as in IFRAME, OBJECT, etc.) o Check conformance with RFC 2109 - not currently sending $Version=1 string o Documentation, Documentation @@ -16,6 +13,8 @@ Possibles: +o Enable client code to write directly to the output stream of a message body request +o Provide customization for table to text Low priority: |
From: Russell G. <rus...@us...> - 2002-10-11 00:08:15
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv10738/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Added support for window.<frame-name> Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- ScriptingTest.java 10 Oct 2002 21:10:19 -0000 1.36 +++ ScriptingTest.java 11 Oct 2002 00:08:10 -0000 1.37 @@ -319,7 +319,7 @@ " alert( 'name=' + window.name );" + " alert( 'top url=' + window.top.location );" + " alert( '1st frame=' + top.frames[0].name );" + - " alert( '2nd frame=' + window.parent.frames[1].name );" + + " alert( '2nd frame=' + window.parent.blue.name );" + "}" + "</script></head><body>" + "<a href=# onclick='show_properties()'>show</a>" + |
From: Russell G. <rus...@us...> - 2002-10-11 00:08:14
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv10738/src/com/meterware/httpunit Modified Files: WebResponse.java Log Message: Added support for window.<frame-name> Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.87 retrieving revision 1.88 diff -u -r1.87 -r1.88 --- WebResponse.java 10 Oct 2002 21:10:19 -0000 1.87 +++ WebResponse.java 11 Oct 2002 00:08:10 -0000 1.88 @@ -612,7 +612,11 @@ } else if (propertyName.equalsIgnoreCase( "opener" )) { return getFrameName().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null; } else { - return super.get( propertyName ); + try { + return getSubframeContents( propertyName ).getScriptableObject(); + } catch (NoSuchFrameException e) { + return super.get( propertyName ); + } } } |
From: Russell G. <rus...@us...> - 2002-10-11 00:08:14
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv10738/doc Modified Files: Javascript-support.html release_notes.txt todo.txt Log Message: Added support for window.<frame-name> Index: Javascript-support.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- Javascript-support.html 10 Oct 2002 21:10:19 -0000 1.23 +++ Javascript-support.html 11 Oct 2002 00:08:09 -0000 1.24 @@ -19,6 +19,7 @@ <li>self - the Window itself</li> <li>top - the top frame in the frameset containing this window <li>window - a synonym for self</li> +<li><name> - the subframe of this window with the specified name </ul> <h4>events</h4> <ul> Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.187 retrieving revision 1.188 diff -u -r1.187 -r1.188 --- release_notes.txt 10 Oct 2002 21:10:19 -0000 1.187 +++ release_notes.txt 11 Oct 2002 00:08:09 -0000 1.188 @@ -17,6 +17,7 @@ Additions: 1. Added support for Window.parent + 2. Added support for Window.<subframe-name> 9-Oct-2002 Acknowledgements: Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- todo.txt 10 Oct 2002 21:10:19 -0000 1.34 +++ todo.txt 11 Oct 2002 00:08:09 -0000 1.35 @@ -1,8 +1,10 @@ High priority: o closing windows +o WebClient.getOpenWindow( name ) o better support for use with proxy server Medium priority: +o replace JTidy with a simpler custom parser or NekoHTML o Enable client code to write directly to the output stream of a message body request o Provide customization for table to text o Support optional tags which hide their contents (as in IFRAME, OBJECT, etc.) @@ -10,11 +12,10 @@ o Documentation, Documentation JavaScript priorities: -o Document.write - may required substantial parser rewrite +o Document.write - will require replacing JTidy Possibles: -o replace JTidy with a simpler custom parser or NekoHTML Low priority: |
From: Russell G. <rus...@us...> - 2002-10-10 22:44:38
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv13200/src/com/meterware/httpunit Modified Files: FrameHolder.java Log Message: Handle multiple frames in non-main window Index: FrameHolder.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FrameHolder.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- FrameHolder.java 4 Oct 2002 00:40:28 -0000 1.4 +++ FrameHolder.java 10 Oct 2002 22:44:34 -0000 1.5 @@ -35,16 +35,14 @@ **/ class FrameHolder { - private WebClient _client; private Hashtable _contents = new Hashtable(); private Hashtable _subFrames = new Hashtable(); private String _frameName; FrameHolder( WebClient client, String name ) { - _client = client; _frameName = name; - DefaultWebResponse blankResponse = new DefaultWebResponse( _client, null, WebResponse.BLANK_HTML ); + DefaultWebResponse blankResponse = new DefaultWebResponse( client, null, WebResponse.BLANK_HTML ); _contents.put( WebRequest.TOP_FRAME, blankResponse ); HttpUnitOptions.getScriptingEngine().associate( blankResponse ); } @@ -83,7 +81,7 @@ if (response.isHTML()) { createSubFrames( target, response.getFrameNames() ); WebRequest[] requests = response.getFrameRequests(); - for (int i = 0; i < requests.length; i++) _client.getResponse( requests[ i ] ); + for (int i = 0; i < requests.length; i++) response.getWindow().getResponse( requests[ i ] ); HttpUnitOptions.getScriptingEngine().associate( response ); } } |
From: Russell G. <rus...@us...> - 2002-10-10 21:10:23
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv3031/src/com/meterware/httpunit Modified Files: WebClient.java WebFrame.java WebRequest.java WebResponse.java WebWindow.java Log Message: Added window.parent support Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- WebClient.java 9 Oct 2002 17:16:30 -0000 1.39 +++ WebClient.java 10 Oct 2002 21:10:19 -0000 1.40 @@ -598,7 +598,7 @@ RedirectWebRequest( WebResponse response ) throws MalformedURLException { - super( response.getURL(), response.getHeaderField( "Location" ), response.getTarget() ); + super( response.getURL(), response.getHeaderField( "Location" ), response.getFrameName() ); } Index: WebFrame.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebFrame.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- WebFrame.java 1 Aug 2002 14:58:59 -0000 1.9 +++ WebFrame.java 10 Oct 2002 21:10:19 -0000 1.10 @@ -65,7 +65,7 @@ * */ static String getTargetFrameName( String sourceFrameName, final String relativeName ) { - if (relativeName.equalsIgnoreCase( "_parent" )) return getParentFrameName( sourceFrameName ); + if (relativeName.equalsIgnoreCase( WebRequest.PARENT_FRAME )) return getParentFrameName( sourceFrameName ); if (sourceFrameName.indexOf( ':' ) < 0) return relativeName; return getParentFrameName( sourceFrameName ) + ':' + relativeName; } Index: WebRequest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequest.java,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- WebRequest.java 8 Oct 2002 17:45:12 -0000 1.50 +++ WebRequest.java 10 Oct 2002 21:10:19 -0000 1.51 @@ -440,7 +440,7 @@ final static String TOP_FRAME = "_top"; /** The target indicating the parent of a frame. **/ - final static String PARENT_FRAME = "_frame"; + final static String PARENT_FRAME = "_parent"; /** The target indicating a new, empty window. **/ final static String NEW_WINDOW = "_blank"; Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- WebResponse.java 10 Oct 2002 20:20:36 -0000 1.86 +++ WebResponse.java 10 Oct 2002 21:10:19 -0000 1.87 @@ -111,10 +111,20 @@ return getReceivedPage().getMetaTagContent(attribute, attributeValue); } + /** * Returns the target of the page. + * @deprecated use getFrameName **/ public String getTarget() { + return getFrameName(); + } + + + /** + * Returns the name of the frame containing this page. + **/ + public String getFrameName() { return _frameName; } @@ -591,13 +601,16 @@ **/ public Object get( String propertyName ) { if (propertyName.equals( "name" )) { - return getTarget().equals( WebRequest.TOP_FRAME ) ? _window.getName() : getTarget(); + return getFrameName().equals( WebRequest.TOP_FRAME ) ? _window.getName() : getFrameName(); } else if (propertyName.equalsIgnoreCase( "top" )) { return _window.getFrameContents( WebRequest.TOP_FRAME ).getScriptableObject(); + } else if (propertyName.equalsIgnoreCase( "parent" )) { + return getFrameName().equals( WebRequest.TOP_FRAME ) ? null + : _window.getFrameContents( WebFrame.getParentFrameName( getFrameName() ) ).getScriptableObject(); } else if (propertyName.equalsIgnoreCase( "location" )) { return WebResponse.this._url.toExternalForm(); } else if (propertyName.equalsIgnoreCase( "opener" )) { - return getTarget().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null; + return getFrameName().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null; } else { return super.get( propertyName ); } @@ -616,7 +629,7 @@ public void set( String propertyName, Object value ) { if (propertyName.equals( "name" )) { if (value == null) value = ""; - if (getTarget().equals( WebRequest.TOP_FRAME )) { + if (getFrameName().equals( WebRequest.TOP_FRAME )) { _window.setName( value.toString() ); } } else if (propertyName.equalsIgnoreCase( "location" )) { @@ -1084,105 +1097,105 @@ -} - - //======================================================================================= -class ByteTag { + class ByteTag { - ByteTag( byte[] buffer, int start, int length ) throws UnsupportedEncodingException { - _buffer = new String( buffer, start, length, WebResponse.getDefaultEncoding() ).toCharArray(); - _name = nextToken(); - - String attribute = ""; - String token = nextToken(); - while (token.length() != 0) { - if (token.equals( "=" ) && attribute.length() != 0) { - getAttributes().put( attribute.toLowerCase(), nextToken() ); - attribute = ""; - } else { - if (attribute.length() > 0) getAttributes().put( attribute.toLowerCase(), "" ); - attribute = token; + ByteTag( byte[] buffer, int start, int length ) throws UnsupportedEncodingException { + _buffer = new String( buffer, start, length, WebResponse.getDefaultEncoding() ).toCharArray(); + _name = nextToken(); + + String attribute = ""; + String token = nextToken(); + while (token.length() != 0) { + if (token.equals( "=" ) && attribute.length() != 0) { + getAttributes().put( attribute.toLowerCase(), nextToken() ); + attribute = ""; + } else { + if (attribute.length() > 0) getAttributes().put( attribute.toLowerCase(), "" ); + attribute = token; + } + token = nextToken(); } - token = nextToken(); } - } - public String getName() { - return _name; - } + public String getName() { + return _name; + } - public String getAttribute( String attributeName ) { - return (String) getAttributes().get( attributeName ); - } + public String getAttribute( String attributeName ) { + return (String) getAttributes().get( attributeName ); + } - public String toString() { - return "ByteTag[ name=" + _name + ";attributes = " + _attributes + ']'; - } + public String toString() { + return "ByteTag[ name=" + _name + ";attributes = " + _attributes + ']'; + } - private Hashtable getAttributes() { - if (_attributes == null) _attributes = new Hashtable(); - return _attributes; - } + private Hashtable getAttributes() { + if (_attributes == null) _attributes = new Hashtable(); + return _attributes; + } - private String _name = ""; - private Hashtable _attributes; + private String _name = ""; + private Hashtable _attributes; - private char[] _buffer; - private int _start; - private int _end = -1; + private char[] _buffer; + private int _start; + private int _end = -1; - private String nextToken() { - _start = _end+1; - while (_start < _buffer.length && Character.isWhitespace( _buffer[ _start ] )) _start++; - if (_start >= _buffer.length) { - return ""; - } else if (_buffer[ _start ] == '"') { - for (_end = _start+1; _end < _buffer.length && _buffer[ _end ] != '"'; _end++); - return new String( _buffer, _start+1, _end-_start-1 ); - } else if (_buffer[ _start ] == '\'') { - for (_end = _start+1; _end < _buffer.length && _buffer[ _end ] != '\''; _end++); - return new String( _buffer, _start+1, _end-_start-1 ); - } else if (_buffer[ _start ] == '=') { - _end = _start; - return "="; - } else { - for (_end = _start+1; _end < _buffer.length && _buffer[ _end ] != '=' && !Character.isWhitespace( _buffer[ _end ] ); _end++); - return new String( _buffer, _start, (_end--)-_start ); + private String nextToken() { + _start = _end+1; + while (_start < _buffer.length && Character.isWhitespace( _buffer[ _start ] )) _start++; + if (_start >= _buffer.length) { + return ""; + } else if (_buffer[ _start ] == '"') { + for (_end = _start+1; _end < _buffer.length && _buffer[ _end ] != '"'; _end++); + return new String( _buffer, _start+1, _end-_start-1 ); + } else if (_buffer[ _start ] == '\'') { + for (_end = _start+1; _end < _buffer.length && _buffer[ _end ] != '\''; _end++); + return new String( _buffer, _start+1, _end-_start-1 ); + } else if (_buffer[ _start ] == '=') { + _end = _start; + return "="; + } else { + for (_end = _start+1; _end < _buffer.length && _buffer[ _end ] != '=' && !Character.isWhitespace( _buffer[ _end ] ); _end++); + return new String( _buffer, _start, (_end--)-_start ); + } } } -} //======================================================================================= -class ByteTagParser { + class ByteTagParser { - ByteTagParser( byte[] buffer ) { - _buffer = buffer; - } + ByteTagParser( byte[] buffer ) { + _buffer = buffer; + } - ByteTag getNextTag() throws UnsupportedEncodingException { - _start = _end+1; - while (_start < _buffer.length && _buffer[ _start ] != '<') _start++; - for (_end =_start+1; _end < _buffer.length && _buffer[ _end ] != '>'; _end++); - if (_end >= _buffer.length || _end < _start) return null; - return new ByteTag( _buffer, _start+1, _end-_start-1 ); - } + ByteTag getNextTag() throws UnsupportedEncodingException { + _start = _end+1; + while (_start < _buffer.length && _buffer[ _start ] != '<') _start++; + for (_end =_start+1; _end < _buffer.length && _buffer[ _end ] != '>'; _end++); + if (_end >= _buffer.length || _end < _start) return null; + return new ByteTag( _buffer, _start+1, _end-_start-1 ); + } - private int _start = 0; - private int _end = -1; + private int _start = 0; + private int _end = -1; + + private byte[] _buffer; + } + - private byte[] _buffer; } Index: WebWindow.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebWindow.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- WebWindow.java 9 Oct 2002 13:50:08 -0000 1.5 +++ WebWindow.java 10 Oct 2002 21:10:19 -0000 1.6 @@ -165,7 +165,7 @@ void updateFrameContents( WebResponse response ) throws IOException, SAXException { response.setWindow( this ); - _frameContents.updateFrames( response, response.getTarget() ); + _frameContents.updateFrames( response, response.getFrameName() ); } |
From: Russell G. <rus...@us...> - 2002-10-10 21:10:22
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv3031/test/com/meterware/httpunit Modified Files: RequestTargetTest.java WebClientTest.java Log Message: Added window.parent support Index: RequestTargetTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/RequestTargetTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RequestTargetTest.java 2 Oct 2000 16:32:10 -0000 1.1 +++ RequestTargetTest.java 10 Oct 2002 21:10:19 -0000 1.2 @@ -42,7 +42,7 @@ assertEquals( "new link target", WebRequest.TOP_FRAME, request.getTarget() ); WebResponse response = _wc.getResponse( request ); - assertEquals( "default response target", WebRequest.TOP_FRAME, response.getTarget() ); + assertEquals( "default response target", WebRequest.TOP_FRAME, response.getFrameName() ); WebLink link = response.getLinks()[0]; assertEquals( "default link target", WebRequest.TOP_FRAME, link.getTarget() ); assertEquals( "default request target", WebRequest.TOP_FRAME, link.getRequest().getTarget() ); @@ -67,7 +67,7 @@ assertEquals( "request target", "subframe", link.getRequest().getTarget() ); WebResponse response = _wc.getResponse( link.getRequest() ); - assertEquals( "response target", "subframe", response.getTarget() ); + assertEquals( "response target", "subframe", response.getFrameName() ); link = response.getLinks()[0]; assertEquals( "inherited link target", "subframe", link.getTarget() ); } @@ -82,7 +82,7 @@ assertEquals( "request target", "subframe", link.getRequest().getTarget() ); WebResponse response = _wc.getResponse( link.getRequest() ); - assertEquals( "response target", "subframe", response.getTarget() ); + assertEquals( "response target", "subframe", response.getFrameName() ); WebTable table = response.getTables()[0]; TableCell cell = table.getTableCell(0,0); link = cell.getLinks()[0]; @@ -144,7 +144,7 @@ assertEquals( "request target", "subframe", link.getRequest().getTarget() ); WebResponse response = _wc.getResponse( link.getRequest() ); - assertEquals( "response target", "subframe", response.getTarget() ); + assertEquals( "response target", "subframe", response.getFrameName() ); WebForm form = response.getForms()[0]; assertEquals( "inherited form target", "subframe", form.getTarget() ); } Index: WebClientTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/WebClientTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- WebClientTest.java 1 Oct 2002 16:11:48 -0000 1.7 +++ WebClientTest.java 10 Oct 2002 21:10:19 -0000 1.8 @@ -262,7 +262,7 @@ messageLog.get( i ) instanceof WebRequest ); assertTrue( "Logged item " + (i + 1) + " is not a web response, but " + messageLog.get( i + 1 ).getClass(), messageLog.get( i + 1 ) instanceof WebResponse ); - assertEquals( "Response target", ((WebRequest) messageLog.get( i )).getTarget(), ((WebResponse) messageLog.get( i + 1 )).getTarget() ); + assertEquals( "Response target", ((WebRequest) messageLog.get( i )).getTarget(), ((WebResponse) messageLog.get( i + 1 )).getFrameName() ); assertEquals( "Response URL", ((WebRequest) messageLog.get( i )).getURL(), ((WebResponse) messageLog.get( i + 1 )).getURL() ); } |
From: Russell G. <rus...@us...> - 2002-10-10 21:10:22
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv3031/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Added window.parent support Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- ScriptingTest.java 10 Oct 2002 20:20:37 -0000 1.35 +++ ScriptingTest.java 10 Oct 2002 21:10:19 -0000 1.36 @@ -319,7 +319,7 @@ " alert( 'name=' + window.name );" + " alert( 'top url=' + window.top.location );" + " alert( '1st frame=' + top.frames[0].name );" + - " alert( '2nd frame=' + window.top.frames[1].name );" + + " alert( '2nd frame=' + window.parent.frames[1].name );" + "}" + "</script></head><body>" + "<a href=# onclick='show_properties()'>show</a>" + |
From: Russell G. <rus...@us...> - 2002-10-10 21:10:21
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv3031/doc Modified Files: Javascript-support.html release_notes.txt todo.txt Log Message: Added window.parent support Index: Javascript-support.html =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/Javascript-support.html,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- Javascript-support.html 9 Oct 2002 17:16:30 -0000 1.22 +++ Javascript-support.html 10 Oct 2002 21:10:19 -0000 1.23 @@ -15,6 +15,7 @@ <li>name - r/w the name of the window</li> <li>navigator - the Navigator object</li> <li>opener - r/o the window which opened this one (top-level frames only)</li> +<li>parent - the window which is a parent of this one. <li>self - the Window itself</li> <li>top - the top frame in the frameset containing this window <li>window - a synonym for self</li> Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.186 retrieving revision 1.187 diff -u -r1.186 -r1.187 --- release_notes.txt 10 Oct 2002 20:20:36 -0000 1.186 +++ release_notes.txt 10 Oct 2002 21:10:19 -0000 1.187 @@ -10,6 +10,14 @@ Revision History: +10-Oct-2002 +Problems fixed: + 1. Window.open was implemented with parameters backwards in 8-Oct-2002 build + 2. Window.opener property was not returning undefined value for non-top-level windows in 8-Oct-2002 build + +Additions: + 1. Added support for Window.parent + 9-Oct-2002 Acknowledgements: Thanks to Richard Harris for adding stubs for various unimplemented JavaScript Window properties. @@ -18,11 +26,6 @@ 2. Added do-nothing stubs for the Window properties and functions: closed, close(), moveTo(), focus(), setTimeout() Problems fixed: 1. ServletUnit was not supporting mappings for the default servlet. - -10-Oct-2002 -Problems fixed: - 1. Window.open was implemented with parameters backwards in 8-Oct-2002 build - 2. Window.opener property was not returning undefined value for non-top-level windows in 8-Oct-2002 build 8-Oct-2002 Acknowledgements: Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- todo.txt 10 Oct 2002 20:20:36 -0000 1.33 +++ todo.txt 10 Oct 2002 21:10:19 -0000 1.34 @@ -10,7 +10,6 @@ o Documentation, Documentation JavaScript priorities: -o Window.parent o Document.write - may required substantial parser rewrite |
From: Russell G. <rus...@us...> - 2002-10-10 20:20:39
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv14389/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: Corrected reversed Window.open params Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- JavaScript.java 9 Oct 2002 17:16:31 -0000 1.29 +++ JavaScript.java 10 Oct 2002 20:20:36 -0000 1.30 @@ -376,9 +376,9 @@ } - public Window jsFunction_open( String name, Object url, String features, boolean replace ) + public Window jsFunction_open( Object url, String name, String features, boolean replace ) throws PropertyException, JavaScriptException, NotAFunctionException, IOException, SAXException { - return (Window) toScriptable( getDelegate().open( name, toStringIfNotUndefined( url ), features, replace ) ); + return (Window) toScriptable( getDelegate().open( toStringIfNotUndefined( url ), name, features, replace ) ); } |
From: Russell G. <rus...@us...> - 2002-10-10 20:20:39
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv14389/test/com/meterware/httpunit/javascript Modified Files: ScriptingTest.java Log Message: Corrected reversed Window.open params Index: ScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- ScriptingTest.java 9 Oct 2002 17:16:31 -0000 1.34 +++ ScriptingTest.java 10 Oct 2002 20:20:37 -0000 1.35 @@ -226,7 +226,7 @@ defineResource( "Target.html", "You made it!" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + "<body>" + - "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Target.html' );\">go</a>" + + "<a href='#' onClick=\"window.open( '" + getHostPath() + "/Target.html', 'sample' );\">go</a>" + "</body></html>" ); final ArrayList windowsOpened = new ArrayList(); WebConversation wc = new WebConversation(); @@ -244,10 +244,9 @@ public void testWindowOpenNoContents() throws Exception { - defineResource( "Target.html", "You made it!" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + "<body>" + - "<a href='#' onClick=\"window.open( 'sample' );\">go</a>" + + "<a href='#' onClick=\"window.open( null, 'sample' );\">go</a>" + "</body></html>" ); final ArrayList windowsOpened = new ArrayList(); WebConversation wc = new WebConversation(); @@ -269,8 +268,8 @@ defineResource( "Revise.html", "You changed it!" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + "<body>" + - "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Target.html' );\">go</a>" + - "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Revise.html' );\">go</a>" + + "<a href='#' onClick=\"window.open( '" + getHostPath() + "/Target.html', 'sample' );\">go</a>" + + "<a href='#' onClick=\"window.open( '" + getHostPath() + "/Revise.html', 'sample' );\">go</a>" + "</body></html>" ); final ArrayList windowsOpened = new ArrayList(); WebConversation wc = new WebConversation(); @@ -297,13 +296,14 @@ "</script></head><body onload='show_properties()'>" + "</body></html>" ); defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" + - "<body onload='window.name=\"main\"'>" + - "<a href='#' onClick=\"window.open( 'sample', '" + getHostPath() + "/Target.html' );\">go</a>" + + "<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() ); + assertEquals( "main window alert", "opener not defined", wc.popNextAlert() ); response.getLinks()[0].click(); assertEquals( "1st alert", "name=sample", wc.popNextAlert() ); |
From: Russell G. <rus...@us...> - 2002-10-10 20:20:39
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv14389/src/com/meterware/httpunit Modified Files: WebResponse.java Log Message: Corrected reversed Window.open params Index: WebResponse.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v retrieving revision 1.85 retrieving revision 1.86 diff -u -r1.85 -r1.86 --- WebResponse.java 9 Oct 2002 17:16:30 -0000 1.85 +++ WebResponse.java 10 Oct 2002 20:20:36 -0000 1.86 @@ -571,7 +571,7 @@ } - public Scriptable open( String name, String urlString, String features, boolean replace ) + public Scriptable open( String urlString, String name, String features, boolean replace ) throws IOException, SAXException { if (urlString == null || urlString.trim().length() == 0) urlString = "about:"; GetMethodWebRequest request = new GetMethodWebRequest( getURL(), urlString ); @@ -597,10 +597,15 @@ } else if (propertyName.equalsIgnoreCase( "location" )) { return WebResponse.this._url.toExternalForm(); } else if (propertyName.equalsIgnoreCase( "opener" )) { - return getTarget().equals( WebRequest.TOP_FRAME ) ? _window.getOpener().getScriptableObject() : null; + return getTarget().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null; } else { return super.get( propertyName ); } + } + + + private Scriptable getScriptable( WebResponse opener ) { + return opener == null ? null : opener.getScriptableObject(); } |
From: Russell G. <rus...@us...> - 2002-10-10 20:20:39
|
Update of /cvsroot/httpunit/httpunit/doc In directory usw-pr-cvs1:/tmp/cvs-serv14389/doc Modified Files: release_notes.txt todo.txt Log Message: Corrected reversed Window.open params Index: release_notes.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/release_notes.txt,v retrieving revision 1.185 retrieving revision 1.186 diff -u -r1.185 -r1.186 --- release_notes.txt 9 Oct 2002 19:15:29 -0000 1.185 +++ release_notes.txt 10 Oct 2002 20:20:36 -0000 1.186 @@ -19,6 +19,10 @@ Problems fixed: 1. ServletUnit was not supporting mappings for the default servlet. +10-Oct-2002 +Problems fixed: + 1. Window.open was implemented with parameters backwards in 8-Oct-2002 build + 2. Window.opener property was not returning undefined value for non-top-level windows in 8-Oct-2002 build 8-Oct-2002 Acknowledgements: Index: todo.txt =================================================================== RCS file: /cvsroot/httpunit/httpunit/doc/todo.txt,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- todo.txt 9 Oct 2002 17:16:30 -0000 1.32 +++ todo.txt 10 Oct 2002 20:20:36 -0000 1.33 @@ -10,10 +10,7 @@ o Documentation, Documentation JavaScript priorities: -o Window.name for frames -o Window.frames[] o Window.parent -o Window.top o Document.write - may required substantial parser rewrite |