Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8021] Android: WebView: error event not fired when invalid url loaded

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-09T21:41:48.000+0000
Affected Version/sRelease 2.0.0, Release 1.8.2, Release 3.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsparity, reprod
ReporterDustin Hyde
AssigneeUnknown
Created2012-03-14T15:43:00.000+0000
Updated2020-01-09T21:41:48.000+0000

Description

When an invalid url is loaded from a webview, no error event is generated. An error event is generated in iOS. Steps to Reproduce: 1. Run code, click 'Open Invalid URL'.
var win = Ti.UI.createWindow({
	backgroundColor:'blue'
});

var buttonGoogle = Ti.UI.createButton({
	title:'Open Google',
	top:'20%',
	height:'30%',
	left:'10%',
	right:'10%'
});

buttonGoogle.addEventListener('click', function(){
	var webView = Ti.UI.createWebView({
			url:'http://www.google.com'
		});
	
	webView.addEventListener('load', function(){
		alert('load: ' + webView.url);
		});
	
	webView.addEventListener('beforeload', function(){
		alert('beforeload: ' + webView.url);
		});
		
	webView.addEventListener('error', function(){
		alert('error: ' + webView.url);
		});
		
	win.add(webView);
	
	var button = Ti.UI.createButton({
		title:'Close',
		right:0,
		bottom:0,
		height:'10%',
		width:'20%'
	});
	
	button.addEventListener('click', function(){
		win.remove(webView);
	});
	
	webView.add(button);
});

win.add(buttonGoogle);

var buttonInvalid = Ti.UI.createButton({
	title:'Open Invalid URL',
	bottom:'20%',
	height:'30%',
	left:'10%',
	right:'10%'
});

buttonInvalid.addEventListener('click', function(){
	var webView = Ti.UI.createWebView({
			url:'http://xxx'
		});
	
	webView.addEventListener('load', function(){
		alert('load: ' + webView.url);
		});
	
	webView.addEventListener('beforeload', function(){
		alert('beforeload: ' + webView.url);
		});
		
	webView.addEventListener('error', function(){
		alert('error: ' + webView.url);
		});
		
	win.add(webView);
	
	var button = Ti.UI.createButton({
		title:'Close',
		right:0,
		bottom:0,
		height:'10%',
		width:'20%'
	});
	
	button.addEventListener('click', function(){
		win.remove(webView);
	});
	
	webView.add(button);
});

win.add(buttonInvalid);

win.open();
Expected Result: One error event should fire. Actual Result: No error events fire.

Comments

  1. Shameer Jan 2013-03-12

    'Error' alert fired only once but 'beforeload' alert fired 2 or 3 times inconsistently. When click on 'inavalid URL', observed steps 1.load alert fired 2.load alert fired again 3. beforeload alert 4.error alert 5. beforeload alert beforeload alert repeatedly fired instead of once. The problem reproduce with release 3.0.2 and master release 3.1.0 tested on Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 Device: Samsung galaxy s duos Android version: 4.0.4 Android Emulator: Android SDK version: 2.2
  2. Lee Morris 2017-07-12

    These are the observations I have made; 1. beforeload fires 2. load fires 3. error fires 4. beforeload fires With the following environment; Pixel (7.1) Studio 4.9.0.201705302345 Ti SDK 6.1.1 GA Appc NPM 4.2.9 Appc CLI 6.2.2 Ti CLI 5.0.14 Alloy 1.9.11 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131
  3. Alan Hutton 2020-01-09

    It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source