Closed Bug 404748 Opened 17 years ago Closed 17 years ago

__defineSetter__ regression in FF3: no longer works with event properties when used on prototype

Categories

(Core :: DOM: Events, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.9beta2

People

(Reporter: fick_el, Assigned: jst)

References

Details

Attachments

(2 files, 2 obsolete files)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9b1) Gecko/2007110904 Firefox/3.0b1 Build Identifier: The following code works well in FF2 and earlier: HTMLDivElement.prototype.__defineSetter__("onclick",function () { alert("setter called"); }); divRef.onclick=function () {}; In FF3b the setter is never called. It is called fine for non-event properties, but all event properties stopped working. This regression is critical for us and will require going through many changes in order to workaround. Can this be fixed for FF3? Reproducible: Always
Could you attach a minimal testcase using "Add an attachment"? And finding the regression range would be great http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/
Added requested testcase.
Regression somewhere between 2006-09-01 - 2006-11-15
2006-10-06-04-trunk works, 2006-10-07-04-trunk doesn't.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Or some JS engine change? Not sure.
No longer blocks: 349465
Ah, didn't notice bug 159849.
Indeed, regression from bug 159849. Tested backing out locally.
Blocks: 159849
I don't see a way to make both |with| (which requires that the property resolve somewhere on the prototype chain of the object) and the defineSetter thing here work short of always making sure to define the property on an ancestor of the prototype defineSetter was called on. Of course people can call it at arbitrary places in the prototype chain (Object.prototype, anyone)? And we don't really want to be putting on* properties on Object.prototype. Put another way, we could perhaps with a lot of pain put the properties on HTMLDivElement.prototype, but then someone calling HTMLElement.prototype.defineSetter will run into this exact same bug. Unless I'm seriusly missing something about how the JS engine works, I think our only reasonable options are that we ship either this bug or bug 159849.
Flags: blocking1.9?
Boris, I understand the point you make about the impossibility of supporting people trying to call it at arbitrary places in the chain. However, I believe that the main issue here is to keep supporting code that was already working, and not necessarily try to accommodate any conceivable new situation. HTMLSomeElement.prototype.__defineSetter__ on event properties worked up to and including FF2. The patch to bug 159849, which broke it, was never included in any official release, as far as I'm aware. So basically the choice is between keeping backward compatibility, and introducing new functionality. I may not be entirely objective, but I'd argue that the new functionality offered by the 159849 patch is coming to support a feature that is both generally discouraged for performance and ambiguity reasons (FF 1.5 even had a strict warning about usage of 'with') and is not helping support more websites, as the syntax choice is very rare. I'd definitely go with keeping backward compatibility here.
> the main issue here is to keep supporting code that was already working Yes, but the question is what this set of code should be. > So basically the choice is between keeping backward compatibility, and > introducing new functionality. It's a choice between keeping compatibility and making some sites that used to not work work... > as the syntax choice is very rare. Sadly, it's not. There's a lot of "with" usage out there, esp. in some of the JS libraries floating around (Dreamweaver stuff comes to mind). I do agree that it's not clear which way the tradeoff should go here; we need data... Plus I'd like to hear what Brendan has to say, if anything.
Attached patch Possible fix. (obsolete) — Splinter Review
Attached patch Possible fix (diff -w) (obsolete) — Splinter Review
This reverts us to work as we used to in the case described here. bz, what do you think about this approach?
Attachment #289715 - Flags: superreview?(bzbarsky)
Attachment #289715 - Flags: review?(bzbarsky)
I guess that works. It makes the behavior ordering-dependent (so if you assign on an object once before the defineSetter call, the setter will never get called for future sets of that property on that object), but if we assume the defineSetter happens early enough it would work. I'm a little confused by two parts of the patch: 1) When doing an assignment, why are we now doing a RegisterCompileHandler if there is a setter up the proto chain? 2) How can we hit the !ok case in the innermost |if| there? The previous condition was "!proto || (ok && hasProp)", right?
(In reply to comment #14) > I guess that works. It makes the behavior ordering-dependent (so if you assign > on an object once before the defineSetter call, the setter will never get > called for future sets of that property on that object), but if we assume the > defineSetter happens early enough it would work. Yeah, not sure we can do much about that... > I'm a little confused by two parts of the patch: > > 1) When doing an assignment, why are we now doing a RegisterCompileHandler if > there is a setter up the proto chain? > 2) How can we hit the !ok case in the innermost |if| there? The previous > condition was "!proto || (ok && hasProp)", right? Both of those are screwups when I refactored some of that code from an earlier version... New patch coming up.
Attached patch Updated fix.Splinter Review
Attachment #289714 - Attachment is obsolete: true
Attachment #289715 - Attachment is obsolete: true
Attachment #289735 - Flags: superreview?(bzbarsky)
Attachment #289735 - Flags: review?(bzbarsky)
Attachment #289715 - Flags: superreview?(bzbarsky)
Attachment #289715 - Flags: review?(bzbarsky)
Comment on attachment 289735 [details] [diff] [review] Updated fix. This, I buy. Please check in some tests to go with the fix?
Attachment #289735 - Flags: superreview?(bzbarsky)
Attachment #289735 - Flags: superreview+
Attachment #289735 - Flags: review?(bzbarsky)
Attachment #289735 - Flags: review+
Assignee: nobody → jst
I'd love to see someone step up and help write testcases for this, and to get this landed. This isn't a high priority blocker, if a blocker at all, so I'd love to not spend more time on this now unless I have to.
Attachment #289735 - Flags: approval1.9?
Flags: in-testsuite?
Keywords: qawanted
Comment on attachment 289735 [details] [diff] [review] Updated fix. would be great to get some tests with this...
Attachment #289735 - Flags: approval1.9? → approval1.9+
Checking in dom/src/base/nsDOMClassInfo.cpp; /cvsroot/mozilla/dom/src/base/nsDOMClassInfo.cpp,v <-- nsDOMClassInfo.cpp new revision: 1.492; previous revision: 1.491 done
Status: NEW → RESOLVED
Closed: 17 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9 M10
Checked in a mochitest for this.
Flags: in-testsuite? → in-testsuite+
(In reply to comment #14) > I guess that works. It makes the behavior ordering-dependent (so if you assign > on an object once before the defineSetter call, the setter will never get > called for future sets of that property on that object), but if we assume the > defineSetter happens early enough it would work. That's life on the prototype chain, though. Sorry I didn't reply to my summons earlier -- was traveling last week -- glad to see you guys sorted it out. /be
Issue is Resolved - removing QA-Wanted Keywords - QA-Wanted query clean-up task
Keywords: qawanted
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: