[AC-1800] 'window' JS element not available to EvalJS on Android WebView, SDK 3.1.0
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2014-01-02T06:30:58.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android, sdk3, webview |
Reporter | Paul Eustice |
Assignee | Ritu Agrawal |
Created | 2013-04-30T15:56:18.000+0000 |
Updated | 2016-03-08T07:40:41.000+0000 |
Description
I am trying to run some JS inside of a webview on Android that fires events within my hybrid app. When using SDK 3.0.2 the evalJS runs fine, but switching to 3.1 (necessary for the persistent Android webview localStorage bugfix) stops it from working.
I believe it is caused by the 'window' JS object not being available.
Code extract from Titanium JS file:
API.fireEvent = function(name, data){
if (data) {
var js = 'window.fireCustomEvent("' + name + '", ' + JSON.stringify(data) + ');';
}else{
var js = 'window.fireCustomEvent("' + name + '");';
}
webView.evalJS(js);
log("Call EvalJS on Webview: " + js);
};
var locale = Ti.Locale.getCurrentLocale();
API.fireEvent('returnLocale', { locale: locale } );
Code extract from webview JS file:
window.fireCustomEvent = function(name, data){
alert("Fire custom event " + name);
}
Hello Paul, When submitting a bug report it is important that you provide a working test case that is able to be easily pasted into an app.js and when run, clearly shows the problem. This ensures a speedy review and thorough understanding of the problem on both sides. Would you mind editing the bug description to provide this test case? For future reference: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report. A simple app.js that replicates the issue will suffice. Also be sure to wrap your code in {.code.} tags to ensure persistent formatting. (remove the dots) Thank you for your cooperation, Carter
Hi Carter, Thanks for the reply, and sorry for poor issue-raising etiquette. I've investigated further and my initial suspicion about it being caused by a lack of the 'window' js object wasn't correct. Distilling my code down to something simple enough to demonstrate the bug (it's a large and complex hybrid app) doesn't bare fruit at the moment unfortunately. The bug definitely occurs only on 3.1.0 and not 3.0.2 but at the moment I can't reduce it down to be of help. If I find out anything more I'll update this issue.
We have not heard back from you since your last update in May. Not sure if this is still throwing error in your app. If so, please send us details so that we can take next necessary step to fix. If we don't hear back, we will assume the issue is no longer valid and close it.
We have not been able to reproduce this issue with Titanium 3.2.0 GA SDK. If you are still running into the reported error, please let us know your test case. We sure will try to help. If we don't hear back, we will assume the issue has been resolved for you and the ticket can be closed.
Test Environment:
MAC OS X 10.8.5 Ti SDK 3.2.0.GA IOS Simulator 7.0.3 Ti CLI 3.2.0 Android 2.3.3, 4.2.2Test Code
app.jstest.js
Thanks