Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10734] iOS: Parity with Android Webview event handling

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2012-12-04T00:51:02.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2012 Sprint 24, 2012 Sprint 24 API
ComponentsiOS
Labelsapi
ReporterKarl Rowley
AssigneeIngo Muschenetz
Created2012-08-31T11:44:40.000+0000
Updated2013-03-27T22:32:09.000+0000

Description

Event handling for a webview does not match Android. Test Case Number 1:
var window = Titanium.UI.createWindow();
 
window.addEventListener('click', function(e) {
        alert('window click');
})

 
var webView = Titanium.UI.createWebView();
var html = '<html>' + 
   '<body>' +
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<a onclick="javascript:alert(123456)">Click me!</a>' +
   '</body>' + 
   '</html>';
webView.html = html;
//webView.addEventListener('click', function(e) {
 //       alert('webview click');
//})
window.add(webView);
window.open();
Expected result: Click on "Click me" brings up 123456 alert. Click on background brings up "window click" alert. Actual result: Click on "Click me" works as expected. Click on background has no effect. Test Case Number 2:
var window = Titanium.UI.createWindow();
 
window.addEventListener('click', function(e) {
        alert('window click');
})

 
var webView = Titanium.UI.createWebView();
var html = '<html>' + 
   '<body>' +
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<a onclick="javascript:alert(123456)">Click me!</a>' +
   '</body>' + 
   '</html>';
webView.html = html;
webView.addEventListener('click', function(e) {
        alert('webview click');
})
window.add(webView);
window.open();
Expected result: Clicking on "click me" brings up 3 alerts, one for the link, one for the webview, and one for the window. Clicking on the background brings up 2 alerts -- one for the webview and one for the window. Actual result: Clicking anywhere brings up two alerts -- one for the webview and one for the window. Clicking on the "Click me" link has the same effect, and the "123456" alert is never displayed. Test Case Number 3:
var window = Titanium.UI.createWindow();
 
//window.addEventListener('click', function(e) {
 //       alert('window click');
//})

 
var webView = Titanium.UI.createWebView();
var html = '<html>' + 
   '<body>' +
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<br />' + 
        '<a onclick="javascript:alert(123456)">Click me!</a>' +
   '</body>' + 
   '</html>';
webView.html = html;
webView.addEventListener('click', function(e) {
        alert('webview click');
})
window.add(webView);
window.open();
Expected result: Clicking on "Click me" brings up "123456" alert and also "webview clicked" alert. Clicking on background brings up "webview clicked" alert. Actual result: Clicking anywhere brings up "webview clicked" alert only. Clicking on "click me" link does not bring up "123456" dialog.

Comments

  1. Karl Rowley 2012-08-31

JSON Source