public boolean isJavascriptEnabled() { return webClient.isJavaScriptEnabled(); }
private HtmlElement getFirstChildElement(final DomNode parent) { if (parent instanceof HtmlNoScript && getPage().getEnclosingWindow().getWebClient().isJavaScriptEnabled()) { return null; } DomNode node = parent.getFirstChild(); while (node != null && node instanceof HtmlElement == false) { node = node.getNextSibling(); } return (HtmlElement) node; }
private HtmlElement getFirstChildElement(final DomNode parent) { if (parent instanceof HtmlNoScript && getPage().getEnclosingWindow().getWebClient().isJavaScriptEnabled()) { return null; } DomNode node = parent.getFirstChild(); while (node != null && node instanceof HtmlElement == false) { node = node.getNextSibling(); } return (HtmlElement) node; }
private HtmlElement getFirstChildElement(final DomNode parent) { if (parent instanceof HtmlNoScript && getPage().getEnclosingWindow().getWebClient().isJavaScriptEnabled()) { return null; } DomNode node = parent.getFirstChild(); while (node != null && node instanceof HtmlElement == false) { node = node.getNextSibling(); } return (HtmlElement) node; }
/** * Fires the event on the element. Nothing is done if JavaScript is disabled. * @param event the event to fire * @return the execution result, or <tt>null</tt> if nothing is executed */ public ScriptResult fireEvent(final Event event) { final WebClient client = getPage().getWebClient(); if (!client.isJavaScriptEnabled()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Firing " + event); } final HTMLElement jsElt = (HTMLElement) getScriptObject(); final ContextAction action = new ContextAction() { public Object run(final Context cx) { return jsElt.fireEvent(event); } }; final ContextFactory cf = client.getJavaScriptEngine().getContextFactory(); final ScriptResult result = (ScriptResult) cf.call(action); if (event.isAborted(result)) { preventDefault(); } return result; }
/** * Fires the event on the element. Nothing is done if JavaScript is disabled. * @param event the event to fire * @return the execution result, or <tt>null</tt> if nothing is executed */ public ScriptResult fireEvent(final Event event) { final WebClient client = getPage().getWebClient(); if (!client.isJavaScriptEnabled()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Firing " + event); } final HTMLElement jsElt = (HTMLElement) getScriptObject(); final ContextAction action = new ContextAction() { public Object run(final Context cx) { return jsElt.fireEvent(event); } }; final ContextFactory cf = client.getJavaScriptEngine().getContextFactory(); final ScriptResult result = (ScriptResult) cf.call(action); if (event.isAborted(result)) { preventDefault(); } return result; }
/** * Returns an auto-refresh string if specified. This will look in both the meta * tags (taking care of <noscript> if any) and inside the HTTP response headers. * @return the auto-refresh string */ private String getRefreshStringOrNull() { final boolean javaScriptEnabled = getWebClient().isJavaScriptEnabled(); for (final HtmlMeta meta : getMetaTags("refresh")) { if ((!javaScriptEnabled || getFirstParent(meta, HtmlNoScript.TAG_NAME) == null)) { return meta.getContentAttribute(); } } return getWebResponse().getResponseHeaderValue("Refresh"); }
/** * Returns an auto-refresh string if specified. This will look in both the meta * tags (taking care of <noscript> if any) and inside the HTTP response headers. * @return the auto-refresh string */ private String getRefreshStringOrNull() { final boolean javaScriptEnabled = getWebClient().isJavaScriptEnabled(); for (final HtmlMeta meta : getMetaTags("refresh")) { if ((!javaScriptEnabled || getFirstParent(meta, HtmlNoScript.TAG_NAME) == null)) { return meta.getContentAttribute(); } } return getWebResponse().getResponseHeaderValue("Refresh"); }
/** * Returns an auto-refresh string if specified. This will look in both the meta * tags (taking care of <noscript> if any) and inside the HTTP response headers. * @return the auto-refresh string */ private String getRefreshStringOrNull() { final boolean javaScriptEnabled = getWebClient().isJavaScriptEnabled(); for (final HtmlMeta meta : getMetaTags("refresh")) { if ((!javaScriptEnabled || getFirstParent(meta, HtmlNoScript.TAG_NAME) == null)) { return meta.getContentAttribute(); } } return getWebResponse().getResponseHeaderValue("Refresh"); }
/** * Fires the event on the element. Nothing is done if JavaScript is disabled. * @param event the event to fire * @return the execution result, or <tt>null</tt> if nothing is executed */ public ScriptResult fireEvent(final Event event) { final WebClient client = getPage().getWebClient(); if (!client.isJavaScriptEnabled()) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Firing " + event); } final HTMLElement jsElt = (HTMLElement) getScriptObject(); final ContextAction action = new ContextAction() { public Object run(final Context cx) { return jsElt.fireEvent(event); } }; final ContextFactory cf = client.getJavaScriptEngine().getContextFactory(); final ScriptResult result = (ScriptResult) cf.call(action); if (event.isAborted(result)) { preventDefault(); } return result; }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * @param node the node that has just been added to the document */ void notifyNodeAdded(final DomNode node) { if (node instanceof HtmlElement) { boolean insideNoScript = false; if (getWebClient().isJavaScriptEnabled()) { for (DomNode parent = node.getParentNode(); parent != null; parent = parent.getParentNode()) { if (parent instanceof HtmlNoScript) { insideNoScript = true; break; } } } if (!insideNoScript) { addMappedElement((HtmlElement) node, true); } if (node.getNodeName().equals("base")) { calculateBase(); } } node.onAddedToPage(); }
/** * Sets the ready state on any deferred scripts, if necessary. */ private void setReadyStateOnDeferredScriptsIfNeeded() { if (getWebClient().isJavaScriptEnabled() && getWebClient().getBrowserVersion().isIE()) { final List<HtmlElement> elements = getDocumentElement().getHtmlElementsByTagName("script"); for (final HtmlElement e : elements) { if (e instanceof HtmlScript) { final HtmlScript script = (HtmlScript) e; if (script.isDeferred()) { script.setAndExecuteReadyState(READY_STATE_COMPLETE); } } } } }
/** * Sets the ready state on any deferred scripts, if necessary. */ private void setReadyStateOnDeferredScriptsIfNeeded() { if (getWebClient().isJavaScriptEnabled() && getWebClient().getBrowserVersion().isIE()) { final List<HtmlElement> elements = getDocumentElement().getHtmlElementsByTagName("script"); for (final HtmlElement e : elements) { if (e instanceof HtmlScript) { final HtmlScript script = (HtmlScript) e; if (script.isDeferred()) { script.setAndExecuteReadyState(READY_STATE_COMPLETE); } } } } }
/** * Sets the ready state on any deferred scripts, if necessary. */ private void setReadyStateOnDeferredScriptsIfNeeded() { if (getWebClient().isJavaScriptEnabled() && getWebClient().getBrowserVersion().isIE()) { final List<HtmlElement> elements = getDocumentElement().getHtmlElementsByTagName("script"); for (final HtmlElement e : elements) { if (e instanceof HtmlScript) { final HtmlScript script = (HtmlScript) e; if (script.isDeferred()) { script.setAndExecuteReadyState(READY_STATE_COMPLETE); } } } } }
/** * Executes any deferred scripts, if necessary. */ private void executeDeferredScriptsIfNeeded() { if (!getWebClient().isJavaScriptEnabled()) { return; } if (!getWebClient().getBrowserVersion().isIE()) { return; } final HtmlElement doc = getDocumentElement(); final List<HtmlElement> elements = doc.getHtmlElementsByTagName("script"); for (final HtmlElement e : elements) { if (e instanceof HtmlScript) { final HtmlScript script = (HtmlScript) e; if (script.isDeferred()) { script.executeScriptIfNeeded(true); } } } }
/** * Executes any deferred scripts, if necessary. */ private void executeDeferredScriptsIfNeeded() { if (!getWebClient().isJavaScriptEnabled()) { return; } if (!getWebClient().getBrowserVersion().isIE()) { return; } final HtmlElement doc = getDocumentElement(); final List<HtmlElement> elements = doc.getHtmlElementsByTagName("script"); for (final HtmlElement e : elements) { if (e instanceof HtmlScript) { final HtmlScript script = (HtmlScript) e; if (script.isDeferred()) { script.executeScriptIfNeeded(true); } } } }
/** * Executes any deferred scripts, if necessary. */ private void executeDeferredScriptsIfNeeded() { if (!getWebClient().isJavaScriptEnabled()) { return; } if (!getWebClient().getBrowserVersion().isIE()) { return; } final HtmlElement doc = getDocumentElement(); final List<HtmlElement> elements = doc.getHtmlElementsByTagName("script"); for (final HtmlElement e : elements) { if (e instanceof HtmlScript) { final HtmlScript script = (HtmlScript) e; if (script.isDeferred()) { script.executeScriptIfNeeded(true); } } } }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * Execute a Function in the given context. * * @param function the JavaScript Function to call * @param thisObject the "this" object to be used during invocation * @param args the arguments to pass into the call * @param htmlElementScope the HTML element for which this script is being executed * This element will be the context during the JavaScript execution. If null, * the context will default to the page. * @return a ScriptResult which will contain both the current page (which may be different than * the previous page and a JavaScript result object. */ public ScriptResult executeJavaScriptFunctionIfPossible(final Function function, final Scriptable thisObject, final Object[] args, final DomNode htmlElementScope) { if (!getWebClient().isJavaScriptEnabled()) { return new ScriptResult(null, this); } final JavaScriptEngine engine = getWebClient().getJavaScriptEngine(); final Object result = engine.callFunction(this, function, thisObject, args, htmlElementScope); return new ScriptResult(result, getWebClient().getCurrentWindow().getEnclosedPage()); }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * Execute a Function in the given context. * * @param function the JavaScript Function to call * @param thisObject the "this" object to be used during invocation * @param args the arguments to pass into the call * @param htmlElementScope the HTML element for which this script is being executed * This element will be the context during the JavaScript execution. If null, * the context will default to the page. * @return a ScriptResult which will contain both the current page (which may be different than * the previous page and a JavaScript result object. */ public ScriptResult executeJavaScriptFunctionIfPossible(final Function function, final Scriptable thisObject, final Object[] args, final DomNode htmlElementScope) { if (!getWebClient().isJavaScriptEnabled()) { return new ScriptResult(null, this); } final JavaScriptEngine engine = getWebClient().getJavaScriptEngine(); final Object result = engine.callFunction(this, function, thisObject, args, htmlElementScope); return new ScriptResult(result, getWebClient().getCurrentWindow().getEnclosedPage()); }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> * * Execute a Function in the given context. * * @param function the JavaScript Function to call * @param thisObject the "this" object to be used during invocation * @param args the arguments to pass into the call * @param htmlElementScope the HTML element for which this script is being executed * This element will be the context during the JavaScript execution. If null, * the context will default to the page. * @return a ScriptResult which will contain both the current page (which may be different than * the previous page and a JavaScript result object. */ public ScriptResult executeJavaScriptFunctionIfPossible(final Function function, final Scriptable thisObject, final Object[] args, final DomNode htmlElementScope) { if (!getWebClient().isJavaScriptEnabled()) { return new ScriptResult(null, this); } final JavaScriptEngine engine = getWebClient().getJavaScriptEngine(); final Object result = engine.callFunction(this, function, thisObject, args, htmlElementScope); return new ScriptResult(result, getWebClient().getCurrentWindow().getEnclosedPage()); }