Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18336] iOS: JavaScript function overriding doesn't work

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionWon't Fix
Resolution Date2015-01-12T22:24:44.000+0000
Affected Version/sRelease 3.5.0
Fix Version/sn/a
ComponentsiOS
Labelsqe-3.5.0, regression
ReporterKajenthiran Velummaylum
AssigneeIngo Muschenetz
Created2015-01-07T07:06:16.000+0000
Updated2017-03-23T22:38:51.000+0000

Description

JavaScript function overriding doesn't work in 3.5.0

It's a regression since it works fine in 3.4.1 GA

Steps To Reproduce

1. Create a Classic App 2. Replace following code in app.js file
var win = Ti.UI.createWindow({backgroundColor:'white'});
var b = Ti.UI.createButton({
	title:"Alert",
	width:200,
	height:40,
	top:50
});
b.addEventListener('click', function() {
	alert("durp durp durp");
});
win.add(b);
var b2 = Ti.UI.createButton({
	title:"Change alert",
	width:200,
	height:40,
	bottom:50
});
b2.addEventListener('click', function() {
	alert = function(e) {
		Ti.API.info("durp durp durp");
	};
});
win.add(b2);
win.open();
3. Run on iOS device 4. Click on *Alert* button. It will alert a message "durp durp durp". It works! 5. Click on *Change alert* button. 6. Again click on *Alert* button

Expected Result

It should log a console message "durp durp durp". Not an alert anymore. It's the behariour in 3.4.1 GA

Actual Result

It produce alert message.

Comments

  1. Ingo Muschenetz 2015-01-07

    Can you please locate/paste the origin of this test case?
  2. Wilson Luu 2015-01-08

    Note, to workaround this issue, you can add something like this from Fokke (http://www.tidev.io/2014/03/17/snippet-for-a-better-alert/ ):
       function alert(message, title, ok) {
         Ti.UI.createAlertDialog({
           message: message,
           title: title || L('alert_title', 'Alert'),
           ok: ok || L('alert_ok', 'OK')
         }).show();
       }
       
  3. Kajenthiran Velummaylum 2015-01-08

    This test case is originated from the ticket TIMOB-6572.
  4. Pedro Enrique 2015-01-12

    Resolving issue as "won't fix". Looking at the source code I verified that we made "alert", and other global variables, not-deletable and read-only. The fact that in an earlier version of Titanium they could be overwritten is that it was a bug in our JavaScriptCore. This has now been fixed and this issue is no longer valid.
  5. Kajenthiran Velummaylum 2015-01-13

    Can't we generate any warning or error messages at this situation?
  6. Lee Morris 2017-03-23

    Closing ticket as Won't Fix with reference to the above comments.

JSON Source