Closed Bug 1394556 Opened 6 years ago Closed 6 years ago

Compile JSM/component scripts in strict mode by default


(Core :: XPConnect, enhancement)

Not set



Tracking Status
firefox57 --- fixed


(Reporter: kmag, Assigned: kmag)


(Depends on 1 open bug)



(2 files)

Bug 1186409 is currently blocked on non-strict `this` boxing issues in some JSMs. At this point, we shouldn't be relying on non-strict-mode behavior, so it's probably time to just enforce strict mode on all JSM/component scripts.
See Also: → 807862
Comment on attachment 8901988 [details]
Bug 1394556: Part 1 - Fix strict mode errors in JSM scripts.

::: services/common/kinto-offline-client.js:21
(Diff revision 1)
>  /*
>   * This file is generated from kinto.js - do not modify directly.
>   */
> +const global = this;

This also needs to be fixed upstream. I'll file a separate PR for that.
Attachment #8901988 - Flags: review?(ehsan) → review?(dtownsend)
Attachment #8901989 - Flags: review?(ehsan) → review?(dtownsend)
Comment on attachment 8901988 [details]
Bug 1394556: Part 1 - Fix strict mode errors in JSM scripts.

::: testing/specialpowers/content/SpecialPowersObserver.jsm:258
(Diff revision 2)
>        }
>        let createdFiles = this._createdFiles;
>        try {
>          let promises = [];
> {
> -          const filePerms = 0666; // eslint-disable-line no-octal
> +          const filePerms = 0o666; // eslint-disable-line no-octal

I think you can get rid of the eslint disable here now.
Attachment #8901988 - Flags: review?(dtownsend) → review+
Comment on attachment 8901989 [details]
Bug 1394556: Part 2 - Compile all JSM/module scripts in strict mode.
Attachment #8901989 - Flags: review?(dtownsend) → review+
Jörg, there's a good chance this will affect Thunderbird. Look out for errors like "TypeError: this is null", "TypeError: setting a property that has only a getter", and "ReferenceError: assignment to undeclared variable"
Flags: needinfo?(jorgk)
Thanks for the heads-up, I love changes to JS (not) ;-(
Flags: needinfo?(jorgk)
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
(For further reference)
It is also possible to enforce strict-mode on the JSContext. We currently didn't do that. One way non-strict may sneak in is horrible stuff through Function(). The shared JSM global work still work in presence of non-strict code, but we should really avoid it to avoid potential problems.
Depends on: 1396303
Depends on: 1396967
You need to log in before you can comment on or make changes to this bug.