GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-07-26T10:32:11.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | Release 3.1.0, 2013 Sprint 02 API, 2013 Sprint 02, 2013 Sprint 05 API, 2013 Sprint 05 |
Components | Android |
Labels | api, module_webview, qe-and060112, qe-testadded, regression |
Reporter | Satyam Sekhri |
Assignee | Vishal Duggal |
Created | 2012-06-17T01:48:06.000+0000 |
Updated | 2014-03-27T10:54:59.000+0000 |
A webview with HTML property (containing the HTML content of the webview) loads successfully but does not reload.
The behavior occurs since 2.0.1. This worked fine on 1.8.2
Steps to reproduce:
1. Create an application with code below
2. Launch app on android device
3. Click on "Remove and release and add webview" button
Actual: After step 2, the webview launches successfully
After step 3, the webview does not reload
Expected: The webview with HTML content should reload.
var _window = Ti.UI.createWindow({
backgroundColor:'#000'
})
var webview=Ti.UI.createWebView({
//url:'http://www.google.com',
html:'<html><body>test</body></html>',
top : 0,
height : 200
});
webview.addEventListener('load', function() {
alert('The webview is loaded!');
});
var b2 = Ti.UI.createButton({
title : "remove and release and add webview",
top : 280
});
b2.addEventListener("click", function() {
_window.remove(webview);
webview.reload();
_window.add(webview);
});
_window.add(webview);
_window.add(b2);
_window.open();
The issue still occurs. Tested on 3.0.0.GA. The issue is same as TIMOB-3501 which was reported for both url and html property of webview. However the url property works fine now and the issue exists only for html property.
Pull pending https://github.com/appcelerator/titanium_mobile/pull/3782
Another test case: Put flower.jpg in /Resources/ .
Bad test case. If this code is in base Resources/ folder it might work. What if this code is in a file that is in a subfolder of Resources?
Backport PR https://github.com/appcelerator/titanium_mobile/pull/3805
Webview is reloading successfully now. Titanium SDK: 3.1.0.v20130128172329 Titanium SDK: 3.0.2.v20130128174806 Titanium Studio:3.0.2.201301251115 Device: Samung GALAXY Tab 620 Android 3.2, Samsung GALAXY Note Android 2.3.6
The fix for this resulted in a slight change with regards to needing a base URL: Formerly:
Now, the behavior is like so (note the addition of baseURL):
I think Ping Wang's test case with flower.jpg is a valid test case because the documentation for WebView at http://docs.appcelerator.com/titanium/3.0/#!/guide/The_WebView_Component-section-29004918_TheWebViewComponent-UsingLocalWebContentwithWebView declares that "
all local web content is available relative to your project's Resources directory
" as below: bq.Let's say you not only want to show a local HTML file, but you also want that HTML file to have access to local CSS and Javascript files. All you need to do is remember that all local web content is available relative to your project's Resources directory. You can think of Resources almost as a local web server root path. To illustrate this point, let's take the prior example and expand it to use local CSS and Javascript files. So many developers are going to expect the the URLs for any local resource files will be relative to the Resources directory by default. Having to add a special{baseURL:'file:///android_asset/Resources/'}
for Android breaks that supposed rule. Having to use abaseURL
option is fine but it should be clarified in the documentation or some other appropriate location because this will break existing code that used the assumption from the documentation that all local resources are relative to your Resources directory of your project. For example my project worked great until 3.0.2, at which point none of my local Android resource files were being loaded correctly until I came across this workaround.What is the supposed value for baseURL above for iOS? this breaking change cause my app to stop working until I found this bug report. Also, even with baseURL specified, I couldn't fireEvent to and from webview and js module.
@Azwan this bug is only for Android, so you only need to set the
baseURL
for Android. In my app, for iOS, I simply don't specify anybaseURL
and the files load correctly, as expected. I cannot verify your problems with firing events to and from the webview and the local js; for me it all works fine in both Android and iOS once I've set thebaseURL
for Android. I fire an event from the local JS loaded by the webview component, and I can receive that event in my application code. I have not yet tried firing an event from my Titanium code and receiving it in the local webview component.Reopening to fix the reload method and fix the baseURL problems
Resources for test case
PR https://github.com/appcelerator/titanium_mobile/pull/3909
Environment used for verification - Titanium SDK: 3.1.0.v20130311192922 Titanium Studio:3.0.2.201302151605 Device: Samsung GALAXY Note (2.3.6) and Samung GALAXY Tab 620 Android 3.2
Reopening to update label.
updated label. Closing as Fixed. Verified with environment: Studio: 3.1.1.201306131423 SDK: 3.1.2.v20130725180746 acs:1.0.3 alloy:1.1.3 npm:1.2.14 titanium:3.1.1 titanium-code-processor:1.0.1 OS: OSX 10.8 Device: HTC Desire(v4.0.3),iphone simulator(v6.0) Webview with HTML property having HTML content getting reload now.