ClickAider

Unexpected Fragility of Mozilla Toolbar development

XUL is a cool and rapid way to develop toolbars in Firefox, and a vast improvement over Internet Explorer’s model.

I was surprised, however, to discover that there a surprisingly low degree of namespace and object isolation between toolbars. I discovered this when I included prototype.js in my project, and found that I had broken the Facebook toolbar. 

Why?  Prototype.js adds additional methods to the array prototype, and this breaks the Facebook toolbar, which uses the "for (x in a)" idiom to iterate through the elements of the array, which now include the newly added functions.  The Facebook toolbar doesn’t expect these and blows up.

I hacked around this for the moment by modifying prototype.js to only add the special array extensions when I ask it to via the $A function. 

(Sadly, the prototype folks in the forums don’t think this more conservative behavior will ever be incorporated as an option in the main code line;  their philosophy is that no one should use the bad idiom or have to coexist with anyone who uses it.)

Even this is a total fix since there is a chance that some random toolbar author will reuse one of the same global variable names that prototype or I do. 

I mention this primarily so that other’s don’t fall into the same gotcha; hopefully future versions of Firefox will have a better toolbar isolation model for reliability and security reasons.

No Comments so far
Leave a comment


Leave a comment

(required)

(required)