本文整理了Java中com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.getWebClient()
方法的一些代码示例,展示了JavaScriptEngine.getWebClient()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JavaScriptEngine.getWebClient()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
类名称:JavaScriptEngine
方法名:getWebClient
[英]Returns the web client that this engine is associated with.
[中]返回与此引擎关联的web客户端。
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
private void doProcessPostponedActions() {
holdPostponedActions_ = false;
final WebClient webClient = getWebClient();
if (webClient == null) {
postponedActions_.set(null);
代码示例来源:origin: HtmlUnit/htmlunit
private void doProcessPostponedActions() {
holdPostponedActions_ = false;
final WebClient webClient = getWebClient();
if (webClient == null) {
postponedActions_.set(null);
代码示例来源:origin: net.disy.htmlunit/htmlunit
public final Object run(final Context cx) {
final Boolean javaScriptAlreadyRunning = javaScriptRunning_.get();
javaScriptRunning_.set(Boolean.TRUE);
try {
cx.putThreadLocal(KEY_STARTING_SCOPE, scope_);
cx.putThreadLocal(KEY_STARTING_PAGE, htmlPage_);
synchronized (htmlPage_) { // 2 scripts can't be executed in parallel for one page
final Object response = doRun(cx);
processPostponedActions();
return response;
}
}
catch (final Exception e) {
handleJavaScriptException(new ScriptException(htmlPage_, e, getSourceCode(cx)));
return null;
}
catch (final TimeoutError e) {
if (getWebClient().isThrowExceptionOnScriptError()) {
throw new RuntimeException(e);
}
LOG.info("Caught script timeout error", e);
return null;
}
finally {
javaScriptRunning_.set(javaScriptAlreadyRunning);
}
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
public final Object run(final Context cx) {
final Boolean javaScriptAlreadyRunning = javaScriptRunning_.get();
javaScriptRunning_.set(Boolean.TRUE);
try {
cx.putThreadLocal(KEY_STARTING_SCOPE, scope_);
cx.putThreadLocal(KEY_STARTING_PAGE, htmlPage_);
synchronized (htmlPage_) { // 2 scripts can't be executed in parallel for one page
final Object response = doRun(cx);
processPostponedActions();
return response;
}
}
catch (final Exception e) {
handleJavaScriptException(new ScriptException(htmlPage_, e, getSourceCode(cx)));
return null;
}
catch (final TimeoutError e) {
if (getWebClient().isThrowExceptionOnScriptError()) {
throw new RuntimeException(e);
}
LOG.info("Caught script timeout error", e);
return null;
}
finally {
javaScriptRunning_.set(javaScriptAlreadyRunning);
}
}
代码示例来源:origin: org.jenkins-ci/htmlunit
public final Object run(final Context cx) {
final Boolean javaScriptAlreadyRunning = javaScriptRunning_.get();
javaScriptRunning_.set(Boolean.TRUE);
try {
cx.putThreadLocal(KEY_STARTING_SCOPE, scope_);
cx.putThreadLocal(KEY_STARTING_PAGE, htmlPage_);
synchronized (htmlPage_) { // 2 scripts can't be executed in parallel for one page
final Object response = doRun(cx);
processPostponedActions();
return response;
}
}
catch (final Exception e) {
handleJavaScriptException(new ScriptException(htmlPage_, e, getSourceCode(cx)));
return null;
}
catch (final TimeoutError e) {
if (getWebClient().isThrowExceptionOnScriptError()) {
throw new RuntimeException(e);
}
LOG.info("Caught script timeout error", e);
return null;
}
finally {
javaScriptRunning_.set(javaScriptAlreadyRunning);
}
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Handles an exception that occurred during execution of JavaScript code.
* @param scriptException the exception
*/
protected void handleJavaScriptException(final ScriptException scriptException) {
// Trigger window.onerror, if it has been set.
final HtmlPage page = scriptException.getPage();
if (page != null) {
final WebWindow window = page.getEnclosingWindow();
if (window != null) {
final Window w = (Window) window.getScriptObject();
if (w != null) {
w.triggerOnError(scriptException);
}
}
}
// Throw a Java exception if the user wants us to.
if (getWebClient().isThrowExceptionOnScriptError()) {
throw scriptException;
}
// Log the error; ScriptException instances provide good debug info.
LOG.info("Caught script exception", scriptException);
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Handles an exception that occurred during execution of JavaScript code.
* @param scriptException the exception
*/
protected void handleJavaScriptException(final ScriptException scriptException) {
// Trigger window.onerror, if it has been set.
final HtmlPage page = scriptException.getPage();
if (page != null) {
final WebWindow window = page.getEnclosingWindow();
if (window != null) {
final Window w = (Window) window.getScriptObject();
if (w != null) {
w.triggerOnError(scriptException);
}
}
}
// Throw a Java exception if the user wants us to.
if (getWebClient().isThrowExceptionOnScriptError()) {
throw scriptException;
}
// Log the error; ScriptException instances provide good debug info.
LOG.info("Caught script exception", scriptException);
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Handles an exception that occurred during execution of JavaScript code.
* @param scriptException the exception
*/
protected void handleJavaScriptException(final ScriptException scriptException) {
// Trigger window.onerror, if it has been set.
final HtmlPage page = scriptException.getPage();
if (page != null) {
final WebWindow window = page.getEnclosingWindow();
if (window != null) {
final Window w = (Window) window.getScriptObject();
if (w != null) {
w.triggerOnError(scriptException);
}
}
}
// Throw a Java exception if the user wants us to.
if (getWebClient().isThrowExceptionOnScriptError()) {
throw scriptException;
}
// Log the error; ScriptException instances provide good debug info.
LOG.info("Caught script exception", scriptException);
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
getWebClient().getJavaScriptErrorListener().timeoutError(page_, e.getAllowedTime(), e.getExecutionTime());
if (getWebClient().getOptions().isThrowExceptionOnScriptError()) {
throw new RuntimeException(e);
代码示例来源:origin: HtmlUnit/htmlunit
getWebClient().getJavaScriptErrorListener().timeoutError(page_, e.getAllowedTime(), e.getExecutionTime());
if (getWebClient().getOptions().isThrowExceptionOnScriptError()) {
throw new RuntimeException(e);
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Handles an exception that occurred during execution of JavaScript code.
* @param scriptException the exception
* @param triggerOnError if true, this triggers the onerror handler
*/
protected void handleJavaScriptException(final ScriptException scriptException, final boolean triggerOnError) {
// Trigger window.onerror, if it has been set.
final HtmlPage page = scriptException.getPage();
if (triggerOnError && page != null) {
final WebWindow window = page.getEnclosingWindow();
if (window != null) {
final Window w = window.getScriptableObject();
if (w != null) {
try {
w.triggerOnError(scriptException);
}
catch (final Exception e) {
handleJavaScriptException(new ScriptException(page, e, null), false);
}
}
}
}
getWebClient().getJavaScriptErrorListener().scriptException(page, scriptException);
// Throw a Java exception if the user wants us to.
if (getWebClient().getOptions().isThrowExceptionOnScriptError()) {
throw scriptException;
}
// Log the error; ScriptException instances provide good debug info.
LOG.info("Caught script exception", scriptException);
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Handles an exception that occurred during execution of JavaScript code.
* @param scriptException the exception
* @param triggerOnError if true, this triggers the onerror handler
*/
protected void handleJavaScriptException(final ScriptException scriptException, final boolean triggerOnError) {
// Trigger window.onerror, if it has been set.
final HtmlPage page = scriptException.getPage();
if (triggerOnError && page != null) {
final WebWindow window = page.getEnclosingWindow();
if (window != null) {
final Window w = window.getScriptableObject();
if (w != null) {
try {
w.triggerOnError(scriptException);
}
catch (final Exception e) {
handleJavaScriptException(new ScriptException(page, e, null), false);
}
}
}
}
getWebClient().getJavaScriptErrorListener().scriptException(page, scriptException);
// Throw a Java exception if the user wants us to.
if (getWebClient().getOptions().isThrowExceptionOnScriptError()) {
throw scriptException;
}
// Log the error; ScriptException instances provide good debug info.
LOG.info("Caught script exception", scriptException);
}
代码示例来源:origin: org.jenkins-ci/htmlunit
if (config.isJsObject()) {
if (!getWebClient().getBrowserVersion().isIE()) {
final SimpleScriptable obj = config.getLinkedClass().newInstance();
prototype.defineProperty("__proto__", prototype, ScriptableObject.DONTENUM);
代码示例来源:origin: net.disy.htmlunit/htmlunit
if (config.isJsObject()) {
if (!getWebClient().getBrowserVersion().isIE()) {
final SimpleScriptable obj = config.getLinkedClass().newInstance();
prototype.defineProperty("__proto__", prototype, ScriptableObject.DONTENUM);
代码示例来源:origin: org.jvnet.hudson/htmlunit
if (config.isJsObject()) {
if (!getWebClient().getBrowserVersion().isIE()) {
final SimpleScriptable obj = config.getLinkedClass().newInstance();
prototype.defineProperty("__proto__", prototype, ScriptableObject.DONTENUM);
内容来源于网络,如有侵权,请联系作者删除!