[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit/javascript JavaScript.java,1.40,1.41
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-11-29 15:24:15
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript In directory sc8-pr-cvs1:/tmp/cvs-serv18304/src/com/meterware/httpunit/javascript Modified Files: JavaScript.java Log Message: Added support for Location subproperties Index: JavaScript.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- JavaScript.java 17 Nov 2002 16:43:41 -0000 1.40 +++ JavaScript.java 29 Nov 2002 15:23:40 -0000 1.41 @@ -605,6 +605,49 @@ } + public String jsGet_protocol() { + return _url.getProtocol() + ':'; + } + + + public String jsGet_host() { + return _url.getHost() + ':' + _url.getPort(); + } + + + public String jsGet_hostname() { + return _url.getHost(); + } + + + public String jsGet_port() { + return String.valueOf( _url.getPort() ); + } + + + public String jsGet_pathname() { + return _url.getPath(); + } + + + public void jsSet_pathname( String newPath ) throws SAXException, IOException { + if (!newPath.startsWith( "/" )) newPath = '/' + newPath; + URL newURL = new URL( _url, newPath ); + _window.setLocation( newURL.toExternalForm() ); + } + + + public String jsGet_search() { + return '?' + _url.getQuery(); + } + + + public void jsSet_search( String newSearch ) throws SAXException, IOException { + if (!newSearch.startsWith( "?" )) newSearch = '?' + newSearch; + _window.setLocation( jsGet_protocol() + "//" + jsGet_host() + jsGet_pathname() + newSearch ); + } + + /** * Returns the default value of this scriptable object. In this case, it returns simply the URL as a string. * Note that this method is necessary, since Rhino will only call the toString method directly if there are no |