GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-02-06T18:19:02.000+0000 |
Affected Version/s | Release 1.7.0 |
Fix Version/s | Sprint 2012-01, Release 2.0.0, Release 1.8.1, 2014 Sprint 02, 2014 Sprint 02 API, Release 3.2.1, Release 3.3.0 |
Components | Android |
Labels | android, defect, module_webview, parity, qe-3.2.1, qe-testadded, regression |
Reporter | Bill Dawson |
Assignee | Hieu Pham |
Created | 2011-04-15T02:40:35.000+0000 |
Updated | 2014-02-06T18:19:50.000+0000 |
Problem
The html property of a web view returns undefined for remote URLs.
Sample Code
The following will test if the html property is convincingly set for a reliable remote URL (the server always returns the text "GET"). If it is, a green border will show up. If it fails, a red border will show up.
/**
* This tests sees if the Ti.UI.WebView will properly return the HTML of a remote website.
* (And it gets ornery if it fails to grab the HTML.)
*/
var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var web = Ti.UI.createWebView({
url: 'http://appc.me/test/Echo',
width: '90%', height: '90%', top: '5%', left: '5%'
});
win.add(web);
win.open();
web.addEventListener('load', function() {
// The server returns just 'GET', but iOS forces the web view to be well formed...
Ti.API.info(web.html);
// So we'll accept either a well formed HTML or the literal response from the server.
if (web.html == '<html><head></head><body>GET</body></html>' || web.html == 'GET') {
win.backgroundColor = '#0f0';
alert('PASS: I love you forever!');
}
// Otherwise... FAIL!
else {
win.backgroundColor = '#f00';
alert('FAIL: web.html != expected html');
}
});
Associated Helpdesk Ticket
None, but there is a Staff Augmentation project that needs this for their Android app to work.
Workaround
You can get around this issue in Android by grabbing the HTML yourself with some JavaScript. So, the above sample code becomes...Closing bug. Verified fix on: SDK build: 1.9.0.v20120111103135 Runtime: V8, Rhino Titanium Studio, build: 1.0.8.201201101928 Device: Droid 3 (2.3.4)
Updating tags
Updating tags
Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5020
I am able to reproduce this issue. This is regression, works fine on SDK: 3.1.3.GA Using Environment: Device : Google Nexus 7, Android Version: 4.2.1 SDK: 3.2.0.v20131127194046 CLI version : 3.2.0-beta OS : MAC OSX 10.9 Alloy: 1.3.0 ACS: 1.0.9 Appcelerator Studio, build: 3.2.0.201311272052 titanium-code-processor: 1.1.0-beta XCode : 5.0.2
I've tested and confirmed that this is not a regression. It looks like a regression but CLI 3.2.0 is actually exposing this issue. This is because the latest CLI always target the latest SDK by default, whereas the 3.1.3 CLI targets API 10 by default. This issue is happening on API 17+ (4.2+). Starting from API 17, Android introduced @JavascriptInterface annotation that needs to be added to every function that exposes to Javascript. https://github.com/appcelerator/titanium_mobile/pull/3932 fixed most of these, but setValue() was left out.
master PR: https://github.com/appcelerator/titanium_mobile/pull/5287
PR merged
Backport to 3_2_X https://github.com/appcelerator/titanium_mobile/pull/5294
Verified fixed on: Mac OSX 10.9.2 Appcelerator Studio, build: 3.2.1.201402041206 Titanium SDK, build: 3.2.1.v20140203174850 CLI: 3.2.1-beta3 Alloy: 1.3.1-cr2 Android Emulator: 2.3.3, 4.2.2 and 4.4.2 Android Device: 4.4.2 Both code in description and comment passes successfully. Closing