public void clearErrorMessages() { ScriptingEngineImpl.clearErrorMessages(); }
/** * handle the event that has the given script attached * by compiling the eventScript as a function and executing it * @param eventScript - the script to use * @deprecated since 1.7 - use doEventScript instead */ public boolean doEvent( String eventScript ) { return doEventScript(eventScript); }
public String[] getErrorMessages() { return ScriptingEngineImpl.getErrorMessages(); }
/** * run the given script * @param language - the language of the script * @param script - the script to run */ public String runScript( String language, String script ) { if (!supportsScriptLanguage( language )) return ""; try { script = script.trim(); if (script.startsWith( "<!--" )) { script = withoutFirstLine( script ); if (script.endsWith( "-->" )) script = script.substring( 0, script.lastIndexOf( "-->" )); } Context context = Context.enter(); context.initStandardObjects( null ); context.evaluateString( this, script, "httpunit", 0, null ); return getDocumentWriteBuffer(); } catch (Exception e) { handleScriptException( e, "Script '" + script + "'" ); return ""; } finally { discardDocumentWriteBuffer(); Context.exit(); } }
/** * load * @param response */ public void load( WebResponse response ) { Function onLoadEvent=null; try { Context context = Context.enter(); context.initStandardObjects( null ); HTMLDocument htmlDocument = ((DomWindow) response.getScriptingHandler()).getDocument(); if (!(htmlDocument instanceof HTMLDocumentImpl)) return; HTMLBodyElementImpl body = (HTMLBodyElementImpl) htmlDocument.getBody(); if (body == null) return; onLoadEvent = body.getOnloadEvent(); if (onLoadEvent == null) return; onLoadEvent.call( context, body, body, new Object[0] ); } catch (JavaScriptException e) { ScriptingEngineImpl.handleScriptException(e, onLoadEvent.toString()); // HttpUnitUtils.handleException(e); } catch (EcmaError ee) { //throw ee; ScriptingEngineImpl.handleScriptException(ee, onLoadEvent.toString()); } finally { Context.exit(); } }
private String withoutFirstLine( String script ) { for (int i=0; i < script.length(); i++) { if (isLineTerminator( script.charAt(i) )) return script.substring( i ).trim(); } return ""; }
public Object get( String propertyName, Scriptable scriptable ) { Object result = super.get( propertyName, scriptable ); if (result != NOT_FOUND) return result; if (_scriptable == null) return NOT_FOUND; return convertIfNeeded( _scriptable.get( propertyName ) ); }
/** * run the given script * @param language - the language of the script * @param script - the script to run */ public String runScript( String language, String script ) { if (!supportsScriptLanguage( language )) return ""; try { script = script.trim(); if (script.startsWith( "<!--" )) { script = withoutFirstLine( script ); if (script.endsWith( "-->" )) script = script.substring( 0, script.lastIndexOf( "-->" )); } Context context = Context.enter(); context.initStandardObjects( null ); context.evaluateString( this, script, "httpunit", 0, null ); return getDocumentWriteBuffer(); } catch (Exception e) { handleScriptException( e, "Script '" + script + "'" ); return ""; } finally { discardDocumentWriteBuffer(); Context.exit(); } }
/** * load * @param response */ public void load( WebResponse response ) { Function onLoadEvent=null; try { Context context = Context.enter(); context.initStandardObjects( null ); HTMLDocument htmlDocument = ((DomWindow) response.getScriptingHandler()).getDocument(); if (!(htmlDocument instanceof HTMLDocumentImpl)) return; HTMLBodyElementImpl body = (HTMLBodyElementImpl) htmlDocument.getBody(); if (body == null) return; onLoadEvent = body.getOnloadEvent(); if (onLoadEvent == null) return; onLoadEvent.call( context, body, body, new Object[0] ); } catch (JavaScriptException e) { ScriptingEngineImpl.handleScriptException(e, onLoadEvent.toString()); // HttpUnitUtils.handleException(e); } catch (EcmaError ee) { //throw ee; ScriptingEngineImpl.handleScriptException(ee, onLoadEvent.toString()); } finally { Context.exit(); } }
private String withoutFirstLine( String script ) { for (int i=0; i < script.length(); i++) { if (isLineTerminator( script.charAt(i) )) return script.substring( i ).trim(); } return ""; }
public Object get( String propertyName, Scriptable scriptable ) { Object result = super.get( propertyName, scriptable ); if (result != NOT_FOUND) return result; return ScriptingSupport.getNamedProperty( this, getJavaPropertyName( propertyName ), scriptable ); }
/** * run the given script * @param language - the language of the script * @param script - the script to run */ public String runScript( String language, String script ) { if (!supportsScriptLanguage( language )) return ""; try { script = script.trim(); if (script.startsWith( "<!--" )) { script = withoutFirstLine( script ); if (script.endsWith( "-->" )) script = script.substring( 0, script.lastIndexOf( "-->" )); } Context context = Context.enter(); context.initStandardObjects( null ); context.evaluateString( this, script, "httpunit", 0, null ); return getDocumentWriteBuffer(); } catch (Exception e) { handleScriptException( e, "Script '" + script + "'" ); return ""; } finally { discardDocumentWriteBuffer(); Context.exit(); } }
/** * load * @param response */ public void load( WebResponse response ) { Function onLoadEvent=null; try { Context context = Context.enter(); context.initStandardObjects( null ); HTMLDocument htmlDocument = ((DomWindow) response.getScriptingHandler()).getDocument(); if (!(htmlDocument instanceof HTMLDocumentImpl)) return; HTMLBodyElementImpl body = (HTMLBodyElementImpl) htmlDocument.getBody(); if (body == null) return; onLoadEvent = body.getOnloadEvent(); if (onLoadEvent == null) return; onLoadEvent.call( context, body, body, new Object[0] ); } catch (JavaScriptException e) { ScriptingEngineImpl.handleScriptException(e, onLoadEvent.toString()); // HttpUnitUtils.handleException(e); } catch (EcmaError ee) { //throw ee; ScriptingEngineImpl.handleScriptException(ee, onLoadEvent.toString()); } finally { Context.exit(); } }
public void clearErrorMessages() { ScriptingEngineImpl.clearErrorMessages(); }
public String[] getErrorMessages() { return ScriptingEngineImpl.getErrorMessages(); }
/** * handle the event that has the given script attached * by compiling the eventScript as a function and executing it * @param eventScript - the script to use * @deprecated since 1.7 - use doEventScript instead */ public boolean doEvent( String eventScript ) { return doEventScript(eventScript); }
private String withoutFirstLine( String script ) { for (int i=0; i < script.length(); i++) { if (isLineTerminator( script.charAt(i) )) return script.substring( i ).trim(); } return ""; }
public Object get( int i, Scriptable scriptable ) { Object result = super.get( i, scriptable ); if (result != NOT_FOUND) return result; if (_scriptable == null) return NOT_FOUND; return convertIfNeeded( _scriptable.get( i ) ); }
/** * Evaluates the specified string as JavaScript. Will return null if the script has no return value. * @param expression - the expression to evaluate */ public Object evaluateExpression( String expression ) { try { Context context = Context.enter(); context.initStandardObjects( null ); Object result = context.evaluateString( this, expression, "httpunit", 0, null ); return (result == null || result instanceof Undefined) ? null : result; } catch (Exception e) { handleScriptException( e, "URL '" + expression + "'" ); return null; } finally { Context.exit(); } }
public void clearErrorMessages() { ScriptingEngineImpl.clearErrorMessages(); }