chris
chris

Reputation: 3

SWT Browser when is executed JavaScript "successful"?

I was wondering - when calling the org.eclipse.swt.browser.Browser method execute,

Thanks in advance!

edit:
I just checked: the browser does not wait for callbacks to be called

Upvotes: 0

Views: 579

Answers (1)

Baz
Baz

Reputation: 36904

As far as I can tell from digging in the source code, the result will be decided by either of the following methods:

  • Firefox: 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.

So it sounds like, if there's no error, true will be returned.


As far as the async part of your question is concerned, the Browser will not wait for the execution of the async task. What you can do, however, is define a BrowserFunction (as shown in this example) and call that method from JavaScript when you're done with your async task.

Upvotes: 0

Related Questions