/** * {@inheritDoc} */ @Override public Scriptable getParentScope() { return wrapped_.getParentScope(); }
/** * {@inheritDoc} */ @Override public Scriptable getParentScope() { return wrapped_.getParentScope(); }
private static Global getInstance(Function function) { Scriptable scope = function.getParentScope(); if (!(scope instanceof Global)) throw reportRuntimeError("msg.bad.shell.function.scope", String.valueOf(scope)); return (Global)scope; }
private void callFunction(final Function function, final Object[] args) { if (function == null) { return; } final Scriptable scope = function.getParentScope(); final JavaScriptEngine engine = (JavaScriptEngine) containingPage_.getWebClient().getJavaScriptEngine(); engine.callFunction(containingPage_, function, scope, WebSocket.this, args); } }
private void callFunction(final Function function, final Object[] args) { if (function == null) { return; } final Scriptable scope = function.getParentScope(); final JavaScriptEngine engine = (JavaScriptEngine) containingPage_.getWebClient().getJavaScriptEngine(); engine.callFunction(containingPage_, function, scope, WebSocket.this, args); } }
/** * Sets the state as specified and invokes the state change handler if one has been set. * @param state the new state * @param context the context within which the state change handler is to be invoked; * if {@code null}, the current thread's context is used */ private void setState(final int state, Context context) { state_ = state; if (stateChangeHandler_ != null && !openedMultipleTimes_) { final Scriptable scope = stateChangeHandler_.getParentScope(); final JavaScriptEngine jsEngine = (JavaScriptEngine) containingPage_.getWebClient().getJavaScriptEngine(); if (LOG.isDebugEnabled()) { LOG.debug("Calling onreadystatechange handler for state " + state); } final Object[] params = ArrayUtils.EMPTY_OBJECT_ARRAY; jsEngine.callFunction(containingPage_, stateChangeHandler_, scope, this, params); if (LOG.isDebugEnabled()) { if (context == null) { context = Context.getCurrentContext(); } LOG.debug("onreadystatechange handler: " + context.decompileFunction(stateChangeHandler_, 4)); LOG.debug("Calling onreadystatechange handler for state " + state + ". Done."); } } }
/** * Invokes the onerror handler if one has been set. * @param context the context within which the onerror handler is to be invoked; * if {@code null}, the current thread's context is used. */ private void processError(Context context) { if (errorHandler_ != null) { final Scriptable scope = errorHandler_.getParentScope(); final JavaScriptEngine jsEngine = (JavaScriptEngine) containingPage_.getWebClient().getJavaScriptEngine(); final Object[] params = new Event[] {new ProgressEvent(this, Event.TYPE_ERROR)}; if (LOG.isDebugEnabled()) { LOG.debug("Calling onerror handler"); } jsEngine.callFunction(containingPage_, errorHandler_, this, scope, params); if (LOG.isDebugEnabled()) { if (context == null) { context = Context.getCurrentContext(); } LOG.debug("onerror handler: " + context.decompileFunction(errorHandler_, 4)); LOG.debug("Calling onerror handler done."); } } }
/** * Sets the state as specified and invokes the state change handler if one has been set. * @param state the new state * @param context the context within which the state change handler is to be invoked; * if {@code null}, the current thread's context is used */ private void setState(final int state, Context context) { state_ = state; if (stateChangeHandler_ != null && !openedMultipleTimes_) { final Scriptable scope = stateChangeHandler_.getParentScope(); final JavaScriptEngine jsEngine = (JavaScriptEngine) containingPage_.getWebClient().getJavaScriptEngine(); if (LOG.isDebugEnabled()) { LOG.debug("Calling onreadystatechange handler for state " + state); } final Object[] params = ArrayUtils.EMPTY_OBJECT_ARRAY; jsEngine.callFunction(containingPage_, stateChangeHandler_, scope, this, params); if (LOG.isDebugEnabled()) { if (context == null) { context = Context.getCurrentContext(); } LOG.debug("onreadystatechange handler: " + context.decompileFunction(stateChangeHandler_, 4)); LOG.debug("Calling onreadystatechange handler for state " + state + ". Done."); } } }
/** * Invokes the onerror handler if one has been set. * @param context the context within which the onerror handler is to be invoked; * if {@code null}, the current thread's context is used. */ private void processError(Context context) { if (errorHandler_ != null) { final Scriptable scope = errorHandler_.getParentScope(); final JavaScriptEngine jsEngine = (JavaScriptEngine) containingPage_.getWebClient().getJavaScriptEngine(); final Object[] params = new Event[] {new ProgressEvent(this, Event.TYPE_ERROR)}; if (LOG.isDebugEnabled()) { LOG.debug("Calling onerror handler"); } jsEngine.callFunction(containingPage_, errorHandler_, this, scope, params); if (LOG.isDebugEnabled()) { if (context == null) { context = Context.getCurrentContext(); } LOG.debug("onerror handler: " + context.decompileFunction(errorHandler_, 4)); LOG.debug("Calling onerror handler done."); } } }
/** * Invokes the onerror handler if one has been set. * @param context the context within which the onerror handler is to be invoked; * if <tt>null</tt>, the current thread's context is used. */ private void processError(Context context) { if (errorHandler_ != null && !getBrowserVersion().isIE()) { if (context == null) { context = Context.getCurrentContext(); } final Scriptable scope = errorHandler_.getParentScope(); final JavaScriptEngine jsEngine = containingPage_.getWebClient().getJavaScriptEngine(); LOG.debug("Calling onerror handler"); jsEngine.callFunction(containingPage_, errorHandler_, context, this, scope, ArrayUtils.EMPTY_OBJECT_ARRAY); LOG.debug("onerror handler: " + context.decompileFunction(errorHandler_, 4)); LOG.debug("Calling onerror handler done."); } }
/** * Invokes the onerror handler if one has been set. * @param context the context within which the onerror handler is to be invoked; * if <tt>null</tt>, the current thread's context is used. */ private void processError(Context context) { if (errorHandler_ != null && !getBrowserVersion().isIE()) { if (context == null) { context = Context.getCurrentContext(); } final Scriptable scope = errorHandler_.getParentScope(); final JavaScriptEngine jsEngine = containingPage_.getWebClient().getJavaScriptEngine(); LOG.debug("Calling onerror handler"); jsEngine.callFunction(containingPage_, errorHandler_, context, this, scope, ArrayUtils.EMPTY_OBJECT_ARRAY); LOG.debug("onerror handler: " + context.decompileFunction(errorHandler_, 4)); LOG.debug("Calling onerror handler done."); } }
/** * Invokes the onerror handler if one has been set. * @param context the context within which the onerror handler is to be invoked; * if <tt>null</tt>, the current thread's context is used. */ private void processError(Context context) { if (errorHandler_ != null && !getBrowserVersion().isIE()) { if (context == null) { context = Context.getCurrentContext(); } final Scriptable scope = errorHandler_.getParentScope(); final JavaScriptEngine jsEngine = containingPage_.getWebClient().getJavaScriptEngine(); LOG.debug("Calling onerror handler"); jsEngine.callFunction(containingPage_, errorHandler_, context, this, scope, ArrayUtils.EMPTY_OBJECT_ARRAY); LOG.debug("onerror handler: " + context.decompileFunction(errorHandler_, 4)); LOG.debug("Calling onerror handler done."); } }
if (converterObject instanceof Function) { Function f = (Function)converterObject; value = f.call(Context.getContext(), f.getParentScope(), this, ScriptRuntime.emptyArgs); } else {
Function funObj) Scriptable scope = funObj.getParentScope(); Runner runner; if (args.length != 0 && args[0] instanceof Function) {
/** * Performs the download and calls the callback method. */ @Override public void run() { final Scriptable scope = callback_.getParentScope(); final WebRequest request = new WebRequest(url_); try { final WebResponse webResponse = client_.loadWebResponse(request); final String content = webResponse.getContentAsString(); if (LOG.isDebugEnabled()) { LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512)); } final Object[] args = new Object[] {content}; final ContextFactory cf = ((JavaScriptEngine) client_.getJavaScriptEngine()).getContextFactory(); cf.call(cx -> { callback_.call(cx, scope, scope, args); return null; }); } catch (final IOException e) { if (LOG.isErrorEnabled()) { LOG.error("Behavior #default#download: Cannot download " + url_, e); } } } }
/** * Performs the download and calls the callback method. */ @Override public void run() { final Scriptable scope = callback_.getParentScope(); final WebRequest request = new WebRequest(url_); try { final WebResponse webResponse = client_.loadWebResponse(request); final String content = webResponse.getContentAsString(); if (LOG.isDebugEnabled()) { LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512)); } final Object[] args = new Object[] {content}; final ContextFactory cf = ((JavaScriptEngine) client_.getJavaScriptEngine()).getContextFactory(); cf.call(cx -> { callback_.call(cx, scope, scope, args); return null; }); } catch (final IOException e) { LOG.error("Behavior #default#download: Cannot download " + url_, e); } } }
final Scriptable scope = f.getParentScope(); if (argsToWrap == 0) { return Context.call(factory, f, scope, thisObj, args);
/** * Performs the download and calls the callback method. */ public void run() { final WebClient client = getWindow().getWebWindow().getWebClient(); final Scriptable scope = callback_.getParentScope(); final WebRequestSettings settings = new WebRequestSettings(url_); try { final WebResponse webResponse = client.loadWebResponse(settings); final String content = webResponse.getContentAsString(); LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512)); final Object[] args = new Object[] {content}; final ContextAction action = new ContextAction() { public Object run(final Context cx) { callback_.call(cx, scope, scope, args); return null; } }; final ContextFactory cf = client.getJavaScriptEngine().getContextFactory(); cf.call(action); } catch (final IOException e) { LOG.error("Behavior #default#download: Cannot download " + url_, e); } } }
/** * Performs the download and calls the callback method. */ public void run() { final WebClient client = getWindow().getWebWindow().getWebClient(); final Scriptable scope = callback_.getParentScope(); final WebRequestSettings settings = new WebRequestSettings(url_); try { final WebResponse webResponse = client.loadWebResponse(settings); final String content = webResponse.getContentAsString(); LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512)); final Object[] args = new Object[] {content}; final ContextAction action = new ContextAction() { public Object run(final Context cx) { callback_.call(cx, scope, scope, args); return null; } }; final ContextFactory cf = client.getJavaScriptEngine().getContextFactory(); cf.call(action); } catch (final IOException e) { LOG.error("Behavior #default#download: Cannot download " + url_, e); } } }
/** * Performs the download and calls the callback method. */ public void run() { final WebClient client = getWindow().getWebWindow().getWebClient(); final Scriptable scope = callback_.getParentScope(); final WebRequestSettings settings = new WebRequestSettings(url_); try { final WebResponse webResponse = client.loadWebResponse(settings); final String content = webResponse.getContentAsString(); LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512)); final Object[] args = new Object[] {content}; final ContextAction action = new ContextAction() { public Object run(final Context cx) { callback_.call(cx, scope, scope, args); return null; } }; final ContextFactory cf = client.getJavaScriptEngine().getContextFactory(); cf.call(action); } catch (final IOException e) { LOG.error("Behavior #default#download: Cannot download " + url_, e); } } }