[TIMOB-24196] iOS: Debugging app with Safari throws error when adding event-listeners
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-12-05T19:05:52.000+0000 |
| Affected Version/s | Release 6.0.0 |
| Fix Version/s | Release 6.1.0 |
| Components | iOS |
| Labels | debugger, ios, jscore, safari |
| Reporter | Hans Knöchel |
| Assignee | Christopher Williams |
| Created | 2016-12-05T18:34:16.000+0000 |
| Updated | 2016-12-05T23:02:43.000+0000 |
Description
In TIMOB-23871, we introduced the ability to debug apps with Safari - this is great! While testing around it, I found out that adding event listeners throws an error in the Inspector (no visible error on the app).
The errors are caused by [this](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/KrollObject.m#L1343) and [this](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/KrollObject.m#L1359) line. They can be resolved by checking the value of
jsEventHash beforehand (thanks [~cwilliams]!).
Attachments
| File | Date | Size |
|---|---|---|
| debugger-safari.m4v | 2016-12-05T19:05:09.000+0000 | 6108271 |
https://github.com/appcelerator/titanium_mobile/pull/8659
*To test this ticket*: 1. Create a new app with
appc new -p ios1a. Ensure you have the<use-jscore-framework>true</use-jscore-framework>property in your<ios>section of the tiapp.xml 2. Paste the following code in your app:3. Run the app in the iOS Simulator 4. Open Safari and select the app by navigating tovar win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var btn1 = Ti.UI.createButton({ title: 'Toggle event-listener #1', top: 40 }); btn1.addEventListener('click', function() { alert('#1 works!'); }); var btn2 = Ti.UI.createButton({ title: 'Toggle event-listener #2', top: 120 }); btn2.addEventListener('click', myHandler); win.add(btn1); win.add(btn2); win.open(); function myHandler() { alert('#2 works!'); }Develop > Simulator > JSContext. If the menu is not there, enable it inSettings > Advanced > "Enable Develop menu in menu bar". 5. Set a breakpoint to both event listeners 6. Click both event listeners *Expected behavior*: The breakpoints are hit, the app doesn't crash and the Safari console does not throw any error. Please also see the attached videodebugger-safari.m4vto see how I tested the PR.Verified fixed, the Debugger on Safari no longer shows an error on event listeners and breakpoints are able to be hit (tested with the code provided above). *Environement*
Just realized didn't update the SDK Version build in the environement. ^