SWT浏览器什么时候执行JavaScript"successful"?
SWT Browser when is executed JavaScript "successful"?
我想知道 - 在调用 org.eclipse.swt.browser.Browser
方法执行时,
return boolean
是如何确定的?
- 什么时候考虑执行
javaScript
"successful"?
- 特别是,当我启动一些异步函数并等待响应时会发生什么?
- 浏览器会等待回调吗?
- 是否成功基于空调用堆栈且没有错误?
提前致谢!
编辑:
我刚刚检查:浏览器不等待回调被调用
据我挖掘源代码可以看出,结果将由以下两种方法之一决定:
- 火狐:
JS_EvaluateScriptForPrincipals
If the script compiles and executes successfully, *rval receives the value from the last-executed expression statement processed in the script, and JS_EvaluateScriptForPrincipals or JS_EvaluateUCScriptForPrincipals returns JS_TRUE. Otherwise it returns JS_FALSE, and the value left in *rval is undefined.
- WebKit:
JSEvaluateScript
The value that results from evaluating script, or NULL if an exception is thrown.
听起来,如果没有错误,将返回 true
。
就您问题的异步部分而言,Browser
不会等待异步任务的执行。但是,您可以做的是定义一个 BrowserFunction
(如 this example 所示)并在完成异步任务后从 JavaScript 调用该方法。
我想知道 - 在调用 org.eclipse.swt.browser.Browser
方法执行时,
return boolean
是如何确定的?- 什么时候考虑执行
javaScript
"successful"? - 特别是,当我启动一些异步函数并等待响应时会发生什么?
- 浏览器会等待回调吗?
- 是否成功基于空调用堆栈且没有错误?
提前致谢!
编辑:
我刚刚检查:浏览器不等待回调被调用
据我挖掘源代码可以看出,结果将由以下两种方法之一决定:
- 火狐:
JS_EvaluateScriptForPrincipals
If the script compiles and executes successfully, *rval receives the value from the last-executed expression statement processed in the script, and JS_EvaluateScriptForPrincipals or JS_EvaluateUCScriptForPrincipals returns JS_TRUE. Otherwise it returns JS_FALSE, and the value left in *rval is undefined.
- WebKit:
JSEvaluateScript
The value that results from evaluating script, or NULL if an exception is thrown.
听起来,如果没有错误,将返回 true
。
就您问题的异步部分而言,Browser
不会等待异步任务的执行。但是,您可以做的是定义一个 BrowserFunction
(如 this example 所示)并在完成异步任务后从 JavaScript 调用该方法。