Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8022] Android: WebView: load event is fired when an invalid url is loaded instead of an error event

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-09T21:42:11.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:46:54.000+0000
Updated2020-01-09T21:42:11.000+0000

Description

When an invalid url is loaded from a webview, a load event is fired instead of an error event. An error event is fired in iOS, with no load event. 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: Two load events fire.

Comments

  1. Shameer Jan 2013-02-28

    The problem can reproduce with release 3.0.2 and master release 3.1.0 Both 'load' alert and 'beforeload' alert are repeat twice. Titanium Studio, build: 2.1.2.201208301612 Titanium SDK version: 3.1.0 (28/02/2013) Titanium SDK version: 3.0.2 (28/02/2013) Device: Samsung galaxy s duos Android version: 4.0.4
  2. Lee Morris 2017-07-12

    I am able to reproduce this issue, both loads events fire and also the error event 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