Index: JavaScript.java =================================================================== --- JavaScript.java (revision 11097) +++ JavaScript.java (working copy) @@ -19,19 +19,38 @@ * DEALINGS IN THE SOFTWARE. * *******************************************************************************************************************/ -import com.meterware.httpunit.*; - -import com.meterware.httpunit.scripting.*; - +import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.net.URL; import java.util.ArrayList; -import java.io.IOException; -import java.net.URL; -import org.mozilla.javascript.*; +import org.mozilla.javascript.Context; +import org.mozilla.javascript.EcmaError; +import org.mozilla.javascript.EvaluatorException; +import org.mozilla.javascript.Function; +import org.mozilla.javascript.JavaScriptException; +import org.mozilla.javascript.Scriptable; +import org.mozilla.javascript.ScriptableObject; +import org.mozilla.javascript.Undefined; import org.xml.sax.SAXException; +import com.meterware.httpunit.ClientProperties; +import com.meterware.httpunit.HTMLPage; +import com.meterware.httpunit.ScriptException; +import com.meterware.httpunit.WebForm; +import com.meterware.httpunit.WebImage; +import com.meterware.httpunit.WebLink; +import com.meterware.httpunit.WebResponse; +import com.meterware.httpunit.scripting.DocumentElement; +import com.meterware.httpunit.scripting.IdentifiedDelegate; +import com.meterware.httpunit.scripting.Input; +import com.meterware.httpunit.scripting.NamedDelegate; +import com.meterware.httpunit.scripting.ScriptableDelegate; +import com.meterware.httpunit.scripting.ScriptingEngine; +import com.meterware.httpunit.scripting.SelectionOption; +import com.meterware.httpunit.scripting.SelectionOptions; + /** * This class is the Rhino-compatible implementation of the JavaScript DOM objects. * @@ -70,8 +89,7 @@ * Initiates JavaScript execution for the specified web response. */ static void run( WebResponse response ) throws IllegalAccessException, InstantiationException, - InvocationTargetException, ClassDefinitionException, NotAFunctionException, - PropertyException, SAXException, JavaScriptException { + InvocationTargetException, SAXException, JavaScriptException { Context context = Context.enter(); Scriptable scope = context.initStandardObjects( null ); initHTMLObjects( scope ); @@ -84,14 +102,14 @@ /** * Runs the onload event for the specified web response. */ - public static void load( WebResponse response ) throws ClassDefinitionException, InstantiationException, IllegalAccessException, InvocationTargetException, PropertyException, JavaScriptException, SAXException, NotAFunctionException { + public static void load( WebResponse response ) throws InstantiationException, IllegalAccessException, InvocationTargetException, JavaScriptException, SAXException { if (!(response.getScriptableObject().getScriptEngine() instanceof JavaScriptEngine)) run( response ); response.getScriptableObject().load(); } private static void initHTMLObjects( Scriptable scope ) throws IllegalAccessException, InstantiationException, - InvocationTargetException, ClassDefinitionException, PropertyException { + InvocationTargetException { ScriptableObject.defineClass( scope, Window.class ); ScriptableObject.defineClass( scope, Document.class ); ScriptableObject.defineClass( scope, Style.class ); @@ -207,7 +225,7 @@ void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) - throws SAXException, PropertyException, JavaScriptException, NotAFunctionException { + throws SAXException, JavaScriptException { _scriptable = scriptable; _scriptable.setScriptEngine( this ); _parent = parent; @@ -383,7 +401,7 @@ } - public Scriptable jsGet_frames() throws SAXException, PropertyException, JavaScriptException, NotAFunctionException { + public Scriptable jsGet_frames() throws SAXException, JavaScriptException { if (_frames == null) { WebResponse.Scriptable scriptables[] = getDelegate().getFrames(); Window[] frames = new Window[ scriptables.length ]; @@ -423,7 +441,7 @@ void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) - throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { + throws JavaScriptException, SAXException { super.initialize( parent, scriptable ); _location = (Location) Context.getCurrentContext().newObject( this, "Location" ); @@ -470,7 +488,7 @@ public Window jsFunction_open( Object url, String name, String features, boolean replace ) - throws PropertyException, JavaScriptException, NotAFunctionException, IOException, SAXException { + throws JavaScriptException, IOException, SAXException { WebResponse.Scriptable delegate = getDelegate().open( toStringIfNotUndefined( url ), name, features, replace ); return delegate == null ? null : (Window) toScriptable( delegate ); } @@ -753,7 +771,8 @@ static public class Navigator extends JavaScriptEngine { private ClientProperties _clientProperties; - + private ElementArray _plugins = new ElementArray(); + public String getClassName() { return "Navigator"; } @@ -789,8 +808,8 @@ } - public Object[] jsGet_plugins() { - return new Object[0]; + public Scriptable jsGet_plugins() { + return _plugins; } @@ -838,10 +857,6 @@ static ElementArray newElementArray( Scriptable parent ) { try { return (ElementArray) Context.getCurrentContext().newObject( parent, "ElementArray" ); - } catch (PropertyException e) { - throw new RhinoException( e ); - } catch (NotAFunctionException e) { - throw new RhinoException( e ); } catch (JavaScriptException e) { throw new RhinoException( e ); } @@ -917,7 +932,7 @@ void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) - throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { + throws JavaScriptException, SAXException { super.initialize( parent, scriptable ); _document = (Document) parent; _style = (Style) Context.getCurrentContext().newObject( this, "Style" ); @@ -966,7 +981,7 @@ } - public Scriptable jsGet_elements() throws PropertyException, NotAFunctionException, JavaScriptException { + public Scriptable jsGet_elements() throws JavaScriptException { if (_controls == null) { initializeControls(); } @@ -989,7 +1004,7 @@ } - private void initializeControls() throws PropertyException, NotAFunctionException, JavaScriptException { + private void initializeControls() throws JavaScriptException { ScriptableDelegate scriptables[] = getDelegate().getElementDelegates(); Control[] controls = new Control[ scriptables.length ]; for (int i = 0; i < controls.length; i++) { @@ -1036,7 +1051,7 @@ void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) - throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { + throws JavaScriptException, SAXException { super.initialize( parent, scriptable ); if (parent instanceof Form) _form = (Form) parent; }