Steps to Reproduce:
- Build and run attached WebViewInteropTest.js on Android.
- Observe the Android log.
An Timeout waiting to evaluate JS warning message appears in the log.
The evalJS() calls should succeed. A countdown message "Reload in: X" should appear in the web page, starting from 5. When it counts down to zero, the page should reload.
The WebView.evalJS() call will not work until the "load" event has been received from the WebView. This is because Titanium injects a "polling" script into the web page in the WebViewClient.onPageFinished() call...
This polling script is responsible for fetching/evaluating the script added to the stack by the evalJS() call...
Since evalJS() is getting called before the web page has finished loading, the evalJS() call will always fail with a timeout warning when the Titanium runtime runs on the main UI thread.
Queue all Ti.App.fireEvent() calls made within the HTML and do not fire them until the page has finished loading.
Use the new async version of WebView.evalJS() that was introduced into 7.5.0. It does not have this issue.