let and const compliancy breaks some add-ons. ex sticky

Discussion about official Mozilla Firefox builds
Post Reply
User avatar
streetwolf
Posts: 2700
Joined: August 21st, 2011, 8:07 am
Location: NJ (USA)

let and const compliancy breaks some add-ons. ex sticky

Post by streetwolf »

A patch on Nightly to enforce let and const compliancy has broken some add-ons. So if your favorite add-on isn't working this may be the cause.
Last edited by LoudNoise on November 21st, 2015, 3:17 pm, edited 3 times in total.
Reason: Made into a sixty day sticky
Intel i9-13900K | ASUS ROG MAXIMUS Z790 HERO DDR5 | 64GB CORSAIR VENGEANCE DDR5 @ 6400 Mhz.
H100i ELITE CAPELLIX XT Liquid CPU Cooler | PNY 12GB GeForce RTX 3080 Ti | 2 CORSAIR 2TB MP600 PRO XT GEN 4
HX1200 PLATINUM PSU | XENEON 32" IPS UHD 144Hz | BenQ 32" UHD | MS Windows 11 Pro
User avatar
streetwolf
Posts: 2700
Joined: August 21st, 2011, 8:07 am
Location: NJ (USA)

Re: let and const compliancy breaks some add-ons.

Post by streetwolf »

Intel i9-13900K | ASUS ROG MAXIMUS Z790 HERO DDR5 | 64GB CORSAIR VENGEANCE DDR5 @ 6400 Mhz.
H100i ELITE CAPELLIX XT Liquid CPU Cooler | PNY 12GB GeForce RTX 3080 Ti | 2 CORSAIR 2TB MP600 PRO XT GEN 4
HX1200 PLATINUM PSU | XENEON 32" IPS UHD 144Hz | BenQ 32" UHD | MS Windows 11 Pro
Ver Greeneyes
Posts: 1030
Joined: June 28th, 2008, 4:57 am

Re: let and const compliancy breaks some add-ons.

Post by Ver Greeneyes »

IIUC, let and const bindings in global scope used to behave exactly the same as var bindings - so for the most part, if things break you can just change all your global lets to vars. However, the change may cause some problems when loading things from other JSMs (which are specific to Gecko, and fulfill a similar purpose to the ES6 'modules' that are in the process of being implemented), as some things that used to be shared automatically in weird ways now no longer are. I'm not sure exactly what the difference is from the old system, as several solutions were considered and I'm not sure what they settled on (the devil is in the details for this one).

The announcement on the mozilla.dev.platform newsgroup contains more technical details.
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: let and const compliancy breaks some add-ons.

Post by lithopsian »

One area of concern might be the very common "const Ci = Components.interfaces" type declarations. Redeclarations of the const would cause a syntax error, but replacing const with var would magically make it go away. Now that would be a problem. Just guessing since I haven't seen any actual problems yet.
bomfog
Posts: 455
Joined: November 7th, 2002, 3:22 pm
Location: the palouse, SE. WA, USA

Re: let and const compliancy breaks some add-ons.

Post by bomfog »

streetwolf wrote:Don't know if this made it to Nightly yet but a patch to enforce let and const compliancy has broken some add-ons.


Some bug links:

Bug 1212707 - NoScript has stopped being able to unblock sites on the latest Firefox trunk (soon to be Nightly)
Edit: NoScript seems fixed as of 2.6.9.38rc1

Bug 1212968 - JPM based add-ons are completely broken by bug 1202902

Bug 1202902 - Give loader scripts and XUL frame scripts a lexical scope that doesn't break everything?

Bug 1212848 - Add-on options are missing since 2015-10-08 -> Comment 7:
Bug 1212968 has updated JPM to fix the issue so updating JPM to 1.0.2 and rebuilding your add-on would solve your problem.
Last edited by bomfog on October 9th, 2015, 8:20 am, edited 1 time in total.
User avatar
streetwolf
Posts: 2700
Joined: August 21st, 2011, 8:07 am
Location: NJ (USA)

Re: let and const compliancy breaks some add-ons.

Post by streetwolf »

You have to let the add-on developers know. I contacted a few and they provided me with the proper fix.
Intel i9-13900K | ASUS ROG MAXIMUS Z790 HERO DDR5 | 64GB CORSAIR VENGEANCE DDR5 @ 6400 Mhz.
H100i ELITE CAPELLIX XT Liquid CPU Cooler | PNY 12GB GeForce RTX 3080 Ti | 2 CORSAIR 2TB MP600 PRO XT GEN 4
HX1200 PLATINUM PSU | XENEON 32" IPS UHD 144Hz | BenQ 32" UHD | MS Windows 11 Pro
marty60
Posts: 475
Joined: March 21st, 2012, 7:09 am

Re: let and const compliancy breaks some add-ons.

Post by marty60 »

This change has crippled Custom Buttons and nuked NoScript and downthemall.

NS will probably get fixed in time but the other two not sure.
User avatar
LoudNoise
New Member
Posts: 39900
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Re: let and const compliancy breaks some add-ons.

Post by LoudNoise »

Your choice folks, but would it make sense to move this to Extension Dev?
Post wrangler
"Choose between the Food Select Feature or other Functions. If no food or function is chosen, Toast is the default."
User avatar
patrickjdempsey
Posts: 23686
Joined: October 23rd, 2008, 11:43 am
Location: Asheville NC
Contact:

Re: let and const compliancy breaks some add-ons.

Post by patrickjdempsey »

streetwolf wrote:Here's a read on what's happening: ES6 In Depth: let and const ★ Mozilla Hacks – the Web developer blog


Ver Greeneyes wrote:The announcement on the mozilla.dev.platform newsgroup contains more technical details.


So Mozilla got all excited about let and used it everywhere for everything and now they've got to back up and only use it when it's called for, and revert back to var for globals. Now that is funny. Presumably extensions written by low-level morons like me that don't use let or const aren't bothered by this enforcement?
Tip of the day: If it has "toolbar" in the name, it's crap.
What my avatar is about: https://addons.mozilla.org/en-US/seamonkey/addon/sea-fox/
Ver Greeneyes
Posts: 1030
Joined: June 28th, 2008, 4:57 am

Re: let and const compliancy breaks some add-ons.

Post by Ver Greeneyes »

patrickjdempsey wrote:Presumably extensions written by low-level morons like me that don't use let or const aren't bothered by this enforcement?
Yes, behavior of good old var is unchanged. The behavior of let and const in function and block scopes is also unchanged - the last change to that behavior was the addition of the 'temporal dead zone', which makes things like

Code: Select all

x = 5;
let x;
an error (lets are not hoisted like vars). There are still some changes to come for let and const I believe - their behavior in for loops should be slightly different IIRC - but it's mostly minor stuff.
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: let and const compliancy breaks some add-ons.

Post by lithopsian »

Not just the addition of the temporal dead zone, but the changing from window-global scope to its own global scope. I think people are both more aware and more understanding of the temporal dead zone, perhaps not by name but at least infrequently trying to use a let variable before it is declared. The change in scope is going to bite a lot of people, and not necessarily for doing dumb stuff. It is easy to say that the behaviour of var has not changed, but the interaction of var with let and const *has* changed, so it is entirely possible for a var statement to now produce an error where it didn't before. Redeclaring a global let or const using var used to work, but won't now.

The behaviour of let in simple for loops was changed in FF39, so that each loop iteration receives its own binding of the let variable, affecting closures. for...in and for...of loops are not yet changed but it should land soon. I suspect a few people are going to be affected by this and it will be a bear to track down.

Still, I have little sympathy for people who get bitten by these changes. I've been shouting in the dark for years that let (and const) are not standards compliant and their behaviour would sooner or later change, so please avoid them unless you know exactly what you're letting yourself in for. The MDN pages even warned more or less the same thing. let might be the new var now (or soon), but the people who've been treating it that way for the last five years or so are going to be busy bees.

A move to extensions dev would be useful. If not, I'll start a new thread there since people are going to need information about this.
Ver Greeneyes
Posts: 1030
Joined: June 28th, 2008, 4:57 am

Re: let and const compliancy breaks some add-ons.

Post by Ver Greeneyes »

lithopsian wrote:The behaviour of let in simple for loops was changed in FF39, so that each loop iteration receives its own binding of the let variable, affecting closures. for...in and for...of loops are not yet changed but it should land soon. I suspect a few people are going to be affected by this and it will be a bear to track down.
Ah, it seems I'm more out of the loop than I thought. Thanks for the clarifications, too :)

By the way, I believe Shu is preparing a blog post about the changes to explain them in more detail. I don't think it's been posted yet.
User avatar
joeg
Posts: 2616
Joined: October 10th, 2003, 12:37 pm
Location: How can you be in two places at once, when you're not anywhere at all?

Re: let and const compliancy breaks some add-ons.

Post by joeg »

If you happen to use the Status-4-Evar extension and have been affected by this change, the author has provided a fix.
https://addons.mozilla.org/de/firefox/a ... /versions/
Although every day is Judgment Day, I nonetheless feel like a room without a roof.
marty60
Posts: 475
Joined: March 21st, 2012, 7:09 am

Re: let and const compliancy breaks some add-ons.

Post by marty60 »

For Custom Buttons users Odyseus has uploaded a temporary fix:

http://custombuttons.sourceforge.net/fo ... d3326c5aee
Ver Greeneyes
Posts: 1030
Joined: June 28th, 2008, 4:57 am

Re: let and const compliancy breaks some add-ons.

Post by Ver Greeneyes »

Ver Greeneyes wrote:By the way, I believe Shu is preparing a blog post about the changes to explain them in more detail.

Said blog post: Breaking changes in let and const in Firefox Nightly 44
Post Reply