Closed Bug 1151739 Opened 10 years ago Closed 10 years ago

Have workers inherit the JS version of their calling context so "let" can work in workers too without requiring the "dom.workers.latestJSVersion" pref to be set to true

Categories

(Core :: DOM: Workers, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox40 --- affected

People

(Reporter: asuth, Unassigned)

References

Details

Bug 487070 made it possible for content code to use JSVERSION_LATEST iff the "dom.workers.latestJSVersion" pref is set to true. (Chrome-privileged code gets JSVERSION_LATEST by default.) If this preference is not set, I believe DOM workers are unable to use "let". Since we currently allow content in the wild to opt-in to use of "let" through use of the "version" parameter on a <script> tag's type of 1.7/1.8/friends, it would be nice to similarly enable things to work on workers. From my investigation in bug 1127377 I know that we can slurp the CompileOptions out of our calling context and then presumably use that as the basis as the CompileOptions for the worker. It's not great but it's something that has a chance of doing what the content code wants and is something content code can control. (And code that opts into 1.7 in the main page context is less likely to get broken by the worker magically operating in 1.7-ish mode. Especially if this is propagated strictly so that a non-1.7 JS file creating a worker in the same page context will produce a non-1.7 worker.)
I don't think we should do this. JS versions in general is at this point an abandoned idea. Instead ES6 allows the use of 'let' without having to use a backwards incompatible JS version. I.e. without having to have an opt-in that the JS-loading level. Implementing this in Gecko is covered by bug 855665. So I think we should ask the JS to prioritize that.
I agree that just supporting "let" in general (bug 855665) or when opted-in via "use strict" (bug 932513) are way better than doing what I propose in comment 0. The argument in favor of a hacky fix like this is that it's not clear how many Gecko releases will be required before either of those happen and being entirely unable to use "let" in Workers during that time is a frustrating asymmetry. But that's just me having tried to resist using babel to transpile stuff. I realize there are serious webcompat/migration headaches/complications and I trust your judgement on this.
Based on discussion on dev-platform (https://groups.google.com/forum/#!topic/mozilla.dev.platform/UGYxEgzEkZo), it appears that the "let" implementation is much further from being safe to use than I thought, so it would arguably be unwise to enable such footgunning at this time and we should indeed just wait for "let" to be turned on for JSVERSION_DEFAULT. Any code that can't wait for "let" to be ready is recommended to use a transpiler. Marking this request as invalid, accordingly, but if someone with ownership over this module thinks wontfix is more appropriate, I won't take offence :)
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.