[TIMOB-12324] iOS: improve RTE for addEventListener with one arg
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.0.0, Release 3.0.2 |
Fix Version/s | n/a |
Components | iOS |
Labels | ios, qe-sdk3.0.2 |
Reporter | Dustin Hyde |
Assignee | Unknown |
Created | 2013-01-17T15:47:50.000+0000 |
Updated | 2018-02-28T20:03:44.000+0000 |
Description
iOS: improve RTE for addEventListener with one arg.
If only one arg is passed to addEventListener, the iOS RTE does not indicate the nature of the problem:
[ERROR] : Script Error = *** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0] at app.js (line 100).
Test Code:
var win = Ti.UI.createWindow();
win.addEventListener(function(){
Ti.API.error('SESSION ID: ' + Ti.App.sessionId);
});
win.open();
The Android Error message is informative:
[ERROR][TiExceptionHandler( 310)] (main) [682,2923] ----- Titanium Javascript Runtime Error -----
[ERROR][TiExceptionHandler( 310)] (main) [0,2923] - In ti:/events.js:138,10
[ERROR][TiExceptionHandler( 310)] (main) [0,2923] - Message: Uncaught Error: addListener only takes instances of Function. The listener for event "function (){}" is "undefined"
[ERROR][TiExceptionHandler( 310)] (main) [1,2924] - Source: throw new Error('addListener only takes instances of Function. The listener
[ERROR][V8Exception( 310)] Exception occurred at ti:/events.js:138: Uncaught Error: addListener only takes instances of Function. The listener for event "function (){}" is "undefined"
The iOS Error message for an undefined callback is informative:
[ERROR] : Invalid type passed to function. expected: KrollCallback, was: (null) in -[TiProxy addEventListener:] (TiProxy.m:798)
[ERROR] : Script Error = Invalid type passed to function. expected: KrollCallback, was: (null) in -[TiProxy addEventListener:] (TiProxy.m:798) at app.js (line 115).
Undefined callback test code:
var win = Ti.UI.createWindow();
win.addEventListener();
win.open();
MobileWeb has no RTE: TIMOB-10412
Steps to Reproduce:
1. Run code:
var win = Ti.UI.createWindow();
win.addEventListener(function(){
Ti.API.error('SESSION ID: ' + Ti.App.sessionId);
});
win.open();
Actual Result:
Index out of bounds runtime error.
Expected Result:
RTE indicating wrong number of args, or unexpected arg type.
No comments