[TIMOB-7808] Android: Webview reloads when removed and re-added. Regression from 1.7.5
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-05-03T17:33:12.000+0000 |
Affected Version/s | Release 1.8.0 |
Fix Version/s | Sprint 2012-05, Release 2.0.0 |
Components | Android |
Labels | module_webview, qe-testadded |
Reporter | Varun Joshi |
Assignee | Ping Wang |
Created | 2012-02-24T14:11:47.000+0000 |
Updated | 2014-06-04T21:42:53.000+0000 |
Description
This is a regression. When you try to move a webview from one view to another on Android using Titanium SDK 1.8.x and further, the webview reloads. It doesn't do this on iOS using any Titanium SDK. And it doesn't do it on Android when using Ti SDK 1.7.x.
The test case below shows that even removing the webview from a window and putting it back again makes it reload.
var win = Ti.UI.createWindow();
// It doesn't matter if the webview is created using html
orurl
// When loaded, the webview shows the current timestamp.
var webview = Ti.UI.createWebView({
html: '<html><head></head><body><script>var now = Date.now(); document.body.innerHTML = now;</script></body></html>'
});
var onload = function(){
// Actually, we could see that the load event would fires twice on Android,
// but I want to really prove that the content actually reloads
webview.removeEventListener('load', onload);
var before = webview.evalJS('now');
// Just removing the webview and adding it back again makes it reload on Android when using Ti SDK 1.8.x
win.remove(webview);
win.add(webview);
// Give Android time to breathe
setTimeout(function(){
var after = webview.evalJS('now');
alert('The webview ' + (before == after ? "HASN'T" : "HAS") + ' reloaded!');
}, 500);
};
webview.addEventListener('load', onload);
win.add(webview);
win.open();
The issue was raised by one of the Appcelerator Titans.
Another test case:
Testing steps: 1. run the above code 2. click "remove and add webview". should not see any alert dialog. 3. click "remove and release and add webview". should see the alert dialog.
Closing as Fixed. Used Ping's Code. Behaved as Expected: 1. app start: load event 2. 'Remove and add webview': no reload event. 3. 'remove and release and add webview': reload event SDK: 2.0.0.v20120316130302 Android: V8, Rhino Studio: 2.0.0.201203152033 OS: Snow Leopard Devices Tested: Nexus One 2.2.2
Open to update label