Closed Bug 258833 Opened 20 years ago Closed 17 years ago

[FIX]Bug 230816 fix changed scope chain for XBL constructors/destructors

Categories

(Core :: XBL, defect, P1)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha4

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(2 files)

"this" used to be in the scope chain (since the function used to be an event
handler).
Comment on attachment 158516 [details] [diff] [review]
This should fix the scope chain

This should fix that bug with the autocomplete dropdown you were seeing in
Firefox, Brian...
Attachment #158516 - Flags: superreview?(brendan)
Attachment #158516 - Flags: review?(bryner)
Priority: -- → P1
Summary: Bug 230816 fix changed scope chain for XBL constructors/destructors → [FIX]Bug 230816 fix changed scope chain for XBL constructors/destructors
Target Milestone: --- → mozilla1.8alpha4
Attachment #158516 - Flags: review?(bryner) → review+
Comment on attachment 158516 [details] [diff] [review]
This should fix the scope chain

shaver, could you sr?
Attachment #158516 - Flags: superreview?(brendan) → superreview?(shaver)
Comment on attachment 158516 [details] [diff] [review]
This should fix the scope chain

sr=jst
Attachment #158516 - Flags: superreview?(shaver) → superreview+
Is it actually a good idea for "this" to be in the scope chain?
Short-term, probably -- as it is, at least two toolkit bindings (autocomplete
and toolbar) are broken....  If we feel it's acceptable to break backwards
compat here, that's fine with me; we just need to fix the bindings then.
Comment on attachment 158516 [details] [diff] [review]
This should fix the scope chain

I was on IRC with bz last night when we realized what broke here -- sorry I
didn't see it when sr'ing bz's patch to make constructors and destructors
anonymous functions.  I too think deep scope chains were a mistake (mine, in
Navigator 2.0), made to enable greater brevity in onclick="..." handlers.

For "XBL 2"'s JS bindings, we can change things.  For now, I think we must keep
compatibility.

/be
Fixed.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
*** Bug 258890 has been marked as a duplicate of this bug. ***
Took me a while to find out that the bug I was seeing ("top is a string? what?") was caused by a magically appearing local variable, and then trace it back to this bug. This bug is three years old, can we maybe reconsider polluting the namespace? From what I can see, this "feature" is not documented anywhere.
Blocks: tomtom
If bindings no longer rely on this, we can do whatever.  I doubt that's the case, however.
Looking through the bindings, the only ones that are affected by this seem to be still autocomplete and toolbar. And that's obvious code bugs that should be fixed. I can try running the tests to see whether they turn up anything else.
I'm not talking about our in-tree bindings only.  I'm talking about bindings in general, in the wild.

I suspect that Brendan is right and that we shouldn't touch this in XBL1.  If we do, I think it needs to be early in an alpha cycle..
All tests did fine. As to bindings in the wild - that should be mostly extensions. Hard to tell how many extension have bugs similar to autocomplete, but I am pretty sure that those are much fewer than extensions assuming that bindings will stay attached after the node was removed from a document. So I will take the liberty and reopen this bug - I think this really needs to be addressed properly, causing subtle bugs with undocumented and very non-obvious behavior is very bad IMO.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attachment #289711 - Flags: review?(bzbarsky)
It's not just extensions.  Akamai uses XBL, for example.

If you want to back this patch out, please file a new bug for that.  One bug per problem.

Note that this behavior SHOULD be documented.  If it's not, we need to fix that. But it's been in place ever since we've been shipping XBL, so changing it is not something to take lightly...
Status: REOPENED → RESOLVED
Closed: 20 years ago17 years ago
Resolution: --- → FIXED
Comment on attachment 289711 [details] [diff] [review]
Proposed namespace pollution patch

I'm not going to review this patch, sorry.  Most of it I can't even review if I wanted to.
Attachment #289711 - Flags: review?(bzbarsky)
Oh, and as for tests... the number we have is tiny.  They don't have very good coverage, certainly not in this area.  Not breaking them is good as a minimum requirement, but doesn't produce any confidence in the patch, generally.
Comment on attachment 289711 [details] [diff] [review]
Proposed namespace pollution patch

>       <constructor><![CDATA[
>-        mController = Components.classes["@mozilla.org/autocomplete/controller;1"].
>+        this.mController = Components.classes["@mozilla.org/autocomplete/controller;1"].
>                         getService(Components.interfaces.nsIAutoCompleteController);
>       ]]></constructor>
I wonder why this was never made a field...

>           // Look to see if there is a toolbarset.
>           this.toolbarset = this.firstChild;
>           while (this.toolbarset && this.toolbarset.localName != "toolbarset")
>-            this.toolbarset = toolbarset.nextSibling;
>+            this.toolbarset = this.toolbarset.nextSibling;
>           
>           if (this.toolbarset) {
>             // Create each toolbar described by the toolbarset.
>             var index = 0;
>-            while (toolbarset.hasAttribute("toolbar"+(++index))) {
>-              var toolbarInfo = toolbarset.getAttribute("toolbar"+index);
>+            while (this.toolbarset.hasAttribute("toolbar"+(++index))) {
>+              var toolbarInfo = this.toolbarset.getAttribute("toolbar"+index);
>               var infoSplit = toolbarInfo.split(":");
>               this.appendCustomToolbar(infoSplit[0], infoSplit[1]);
>             }
>           }
Even without the C++ changes I think it might be worth getting someone like gavin to review this for code correctness reasons.
Yes.  But not in this bug, please.  Stop the bugmail!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: