Define Cc/Ci/etc whenever Components is defined for a chrome scope




6 years ago
7 months ago


(Reporter: Dolske, Unassigned)


(Blocks: 2 bugs)

Firefox Tracking Flags

(Not tracked)


MozReview Requests


Submitter Diff Changes Open Issues Last Updated
Error loading review requests:


(3 attachments)



6 years ago
General idea from bug 406371 comment 5...

We use Cc/Ci/Cu/Cr "shortcut" variables all over the place in chrome code because Components.classes, Components.interfaces, etc are too tedious to type. (My fingers are already le tired from just those 2).

Could we just have a little xpconnect magic to create these globals along with Components? That would make 406371 much easier to untangle, and ensure that these shortcuts work all the time.
Yes, we should! Tricky part would be compatability issues, of course. We'd want to isolate this to chrome-code-only, for sure, and then also figure out a way to have it not clobber on existing variables that may use these names.

Comment 2

6 years ago
An easy way to do the latter would be to define them as non-permanent, so later redefinitions would overwrite the original.


5 years ago
Blocks: 406371
Blocks: 1230369
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
I started looking at this a little, just for Ci. The code isn't too complicated, but it is a little gross. For compatibility, you don't really want the JSPROP_PERMANENT, but it helped me find places that were defining it. I also wrote a script to automatically remove definitions of Ci. That removes around 1300 instances of people defining Ci. The other patch fixes a few places I noticed that get hit during startup that the script misses. Ideally you'd probably need an eslint to detect that. Once addons are no longer supported, we could then add PERMANENT, I assume.
Created attachment 8859337 [details]
script to remove definitions of Ci

Here's the script I wrote to remove a few common ways people define Ci. You run it on a directory, with --fix if you want it to actually change the files. If you run this yourself, you'll want to edit the bit of code down near "Hacky way to not process files in the objdir." to match your objdirs.
You need to log in before you can comment on or make changes to this bug.