Project: titanium
Issue TIMOB-17613: Unable to execute javascript code using evalJS on Android with SDK 3.3.0.GA
After upgrading to the latest Titanium SDK (3.3.0.GA), we are not able to invoke Javascript functions using evalJS on Android. We are developing the application for about 2-3 years now, and we can confirm that the code worked prior upgrading to 3.3.0. Moreover, the iOS version of our app does not have this problem even after upgrading the SDK. Our application is quite complex, and one of the core features is the integration with web applications provided by our platform. In order this integration to work, we heavily rely on invoking Javascript functions in the webView context in order to retrieve some data, or identify what steps should be taken. Since we are not allowed to share any productive code, I have prepared a code snippet that presents the issue: {code:title=app.js|borderStyle=solid} (function() {	var win = Ti.UI.createWindow();	var webView = Ti.UI.createWebView({	url : 'test.html'	});	var evalJSFunc = "" +	"(function() {" +	"var result = '{';" +	"var d = document.getElementById('myDiv');" +	"if (d && d.children) {" +	"var childrenLength = d.children.length;" +	"var delimiter = '';" +	"for (var i = 0; i < childrenLength; i++) {" +	"var child = d.children[i];" +	"result = result + delimiter + child.name + ':' + child.value;" +	"delimiter = ',';" +	"}" +	"}" +	"result = result + '}';" +	"return result + '}';" +	"})();";	webView.addEventListener('load', function() {	var result = webView.evalJS(evalJSFunc);	alert(result);	});	win.add(webView);	win.open();	})(); {code} And this is the sample HTML file (note that the Javascript function is the same as the one we try to invoke using evalJS in app.js; it is left just for reference without invoking it): {code:title=test.html|borderStyle=solid}

{code} When executing the above we get the following error: {code} [INFO] : I/TiWebChromeClient.console: (main) [12259,12259] Uncaught SyntaxError: Unexpected token var (1:file:///android_asset/Resources/test.html) {code} After some time (if we wait enough) we get the attached screenshot in Genymotion simulator (no clue where this comes from). Until now, the workaround for us was to rollback to the previous Titanium SDK (3.2.3.GA). Now, given the fact that Apple will also release the new iOS8 soon, we expect that new Titanium SDK would be rolled out as well, one that we must upgrade to, since iOS8 is a must for us. However, this Android issue is also a blocker, putting us in deadlock situation. I have noticed that there are few other JIRA issues similar to ours. https://jira.appcelerator.org/browse/TIMOB-15896 https://jira.appcelerator.org/browse/TC-4427 However, I'm not sure if the cause is really the same (one of the issues says that this happens on 3.2.0 with API17 but we are experiencing it on 3.3.0 with API16). In either case, we would highly appreciate if this issue is treated with higher priority and resolved as quick as possible.
Story points: 3