Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9361] Android: WebView has no error event

GitHub Issuen/a
TypeBug
PriorityMedium
StatusReopened
ResolutionUnresolved
Affected Version/sRelease 2.1.0, Release 8.0.2, Release 8.1.0
Fix Version/sSprint 2012-14 Core, Release 3.0.0
ComponentsAndroid
Labelscore, engSchedule, module_webview, qe-review, qe-testadded
Reporterkosso
AssigneeBill Dawson
Created2012-05-30T04:39:42.000+0000
Updated2019-10-29T15:38:28.000+0000

Description

WRT Github pull request : https://github.com/appcelerator/titanium_mobile/pull/910 When an Android webView attempts to load a non-existent url (for example), no error is fired (as documented!)
// example: app.js

var win = Ti.UI.createWindow({

backgroundColor:'#fff'

});

var web = Ti.UI.createWebView({

// a clearly incorrect url

url:'http://google.cooom'

});

web.addEventListener('error',function(e){

	Ti.API.info('ERROR: '+JSON.stringify(e));
	alert('ERROR: type:'+e.type+'\nurl:'+e.url);

});

win.add(web);
win.open();

Comments

  1. Bill Dawson 2012-07-03

    Testing Notes

    * Run below app.js on *both iOS and Android*.
       var win = Ti.UI.createWindow({
       	backgroundColor:'#fff'
       });
        
       var web = Ti.UI.createWebView({
       	url:'http://google.cooom' // BAD URL
       });
        
       web.addEventListener('error',function(e){
       	var message = e.message;
       	var code = e.errorCode;
       	if (code == Ti.UI.URL_ERROR_HOST_LOOKUP) {
       		message = "Titanium.UI.URL_ERROR_HOST_LOOKUP - " + message;
       	}
       	var url = e.url;
       	alert("Error url: " + url + "; Error code: " + code + "; Error message: " + message);
        
       });
        
       win.add(web);
       win.open();
       
    * You should see an alert showing you an error code, the erroring url and the error message. The message and the numeric code value are platform specific, however the code should match the constant Titanium.UI.URL_ERROR_HOST_LOOKUP. If it does match that, the message will begin with a prepended "Titanium.UI.URL_ERROR_HOST_LOOKUP". <-- you should see that at the front of the message. * No sense testing in MobileWeb, that event never fires and anyway a code is not available there. * Run python validate.py -e -s simple -f Titanium/UI/WebView.yml and python docgen.py to make sure there are no errors *related to the WebView documentation*.
  2. Bill Dawson 2012-07-05

    PR ready https://github.com/appcelerator/titanium_mobile/pull/2509
  3. Tamila Smolich 2012-08-15

    Closing as fixed. Tested and verified on: Titanium Studio, build: 2.1.1.201208091713 Titanium SDK, build: 2.2.0.v20120813184911 Devices: Nexus 7 tab (4.1.1) The expected alert is shown.
  4. Anshu Mittal 2012-09-07

    reopening to update labels
  5. Samir Mohammed 2019-07-18

    Re-opening as on iOS the error code and error message show undefined. Or should I create a new ticket? [~vijaysingh]
  6. Alan Hutton 2019-10-28

    Still showing as undefined.

JSON Source