[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit/javascript JavaScript.java,1.35,1.36
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-11-01 14:55:06
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript
In directory usw-pr-cvs1:/tmp/cvs-serv21999/src/com/meterware/httpunit/javascript
Modified Files:
JavaScript.java
Log Message:
Prepare for Location object
Index: JavaScript.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/javascript/JavaScript.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- JavaScript.java 31 Oct 2002 00:26:18 -0000 1.35
+++ JavaScript.java 1 Nov 2002 14:55:02 -0000 1.36
@@ -26,6 +26,7 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.io.IOException;
+import java.net.URL;
import org.mozilla.javascript.*;
import org.xml.sax.SAXException;
@@ -84,6 +85,7 @@
InvocationTargetException, ClassDefinitionException, PropertyException {
ScriptableObject.defineClass( scope, Window.class );
ScriptableObject.defineClass( scope, Document.class );
+ ScriptableObject.defineClass( scope, Location.class );
ScriptableObject.defineClass( scope, Navigator.class );
ScriptableObject.defineClass( scope, Screen.class );
ScriptableObject.defineClass( scope, Link.class );
@@ -301,9 +303,10 @@
static public class Window extends JavaScriptEngine {
- private Document _document;
- private Navigator _navigator;
- private Screen _screen;
+ private Document _document;
+ private Navigator _navigator;
+ private Location _location;
+ private Screen _screen;
private ElementArray _frames;
@@ -354,10 +357,18 @@
}
+ public Location jsGet_location() {
+ return _location;
+ }
+
+
void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable )
throws JavaScriptException, NotAFunctionException, PropertyException, SAXException {
super.initialize( parent, scriptable );
+ _location = (Location) Context.getCurrentContext().newObject( this, "Location" );
+ _location.setURL( ((WebResponse.Scriptable) scriptable).getURL() );
+
_navigator = (Navigator) Context.getCurrentContext().newObject( this, "Navigator" );
_navigator.setClientProperties( getDelegate().getClientProperties() );
@@ -499,6 +510,27 @@
private HTMLPage.Scriptable getDelegate() {
return (HTMLPage.Scriptable) _scriptable;
+ }
+
+ }
+
+
+ static public class Location extends JavaScriptEngine {
+
+ private URL _url;
+
+ public String getClassName() {
+ return "Location";
+ }
+
+
+ public void setURL( URL url ) {
+ _url = url;
+ }
+
+
+ public String toString() {
+ return _url.toExternalForm();
}
}
|