com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 JavaScript  
字(3.8k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions()方法的一些代码示例,展示了JavaScriptEngine.processPostponedActions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JavaScriptEngine.processPostponedActions()方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
类名称:JavaScriptEngine
方法名:processPostponedActions

JavaScriptEngine.processPostponedActions介绍

[英]INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Process postponed actions, if any.
[中]

代码示例

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * Calls the given function taking care of synchronization issues.
 * @param htmlPage the HTML page that caused this script to executed
 * @param function the js function to execute
 * @param context the context in which execution should occur
 * @param scope the execution scope
 * @param thisObject the 'this' object
 * @param args the function's arguments
 * @return the function result
 */
public Object callFunction(final HtmlPage htmlPage, final Function function, final Context context,
    final Scriptable scope, final Scriptable thisObject, final Object[] args) {
  synchronized (htmlPage) { // 2 scripts can't be executed in parallel for one page
    final Object result = function.call(context, scope, thisObject, args);
    processPostponedActions();
    return result;
  }
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * Calls the given function taking care of synchronization issues.
 * @param htmlPage the HTML page that caused this script to executed
 * @param function the js function to execute
 * @param context the context in which execution should occur
 * @param scope the execution scope
 * @param thisObject the 'this' object
 * @param args the function's arguments
 * @return the function result
 */
public Object callFunction(final HtmlPage htmlPage, final Function function, final Context context,
    final Scriptable scope, final Scriptable thisObject, final Object[] args) {
  synchronized (htmlPage) { // 2 scripts can't be executed in parallel for one page
    final Object result = function.call(context, scope, thisObject, args);
    processPostponedActions();
    return result;
  }
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * Calls the given function taking care of synchronization issues.
 * @param htmlPage the HTML page that caused this script to executed
 * @param function the js function to execute
 * @param context the context in which execution should occur
 * @param scope the execution scope
 * @param thisObject the 'this' object
 * @param args the function's arguments
 * @return the function result
 */
public Object callFunction(final HtmlPage htmlPage, final Function function, final Context context,
    final Scriptable scope, final Scriptable thisObject, final Object[] args) {
  synchronized (htmlPage) { // 2 scripts can't be executed in parallel for one page
    final Object result = function.call(context, scope, thisObject, args);
    processPostponedActions();
    return result;
  }
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * Executes the specified JavaScript code in the context of a given HTML page.
 *
 * @param htmlPage the page that the code will execute within
 * @param script the script to execute
 * @return the result of executing the specified code
 */
public Object execute(final HtmlPage htmlPage, final Script script) {
  final Scriptable scope = getScope(htmlPage, null);
  final ContextAction action = new HtmlUnitContextAction(scope, htmlPage) {
    @Override
    public Object doRun(final Context cx) {
      return script.exec(cx, scope);
    }
    @Override
    protected String getSourceCode(final Context cx) {
      return null;
    }
  };
  Object r = getContextFactory().call(action);
  processPostponedActions();
  return r;
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * Executes the specified JavaScript code in the context of a given HTML page.
 *
 * @param htmlPage the page that the code will execute within
 * @param script the script to execute
 * @return the result of executing the specified code
 */
public Object execute(final HtmlPage htmlPage, final Script script) {
  final Scriptable scope = getScope(htmlPage, null);
  final ContextAction action = new HtmlUnitContextAction(scope, htmlPage) {
    @Override
    public Object doRun(final Context cx) {
      return script.exec(cx, scope);
    }
    @Override
    protected String getSourceCode(final Context cx) {
      return null;
    }
  };
  Object r = getContextFactory().call(action);
  processPostponedActions();
  return r;
}

相关文章