Closed Bug 1394556 Opened 2 years ago Closed 2 years ago

Compile JSM/component scripts in strict mode by default

Categories

(Core :: XPConnect, enhancement)

enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: kmag, Assigned: kmag)

References

(Depends on 1 open bug)

Details

Attachments

(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.

https://reviewboard.mozilla.org/r/173402/#review178782

::: 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.

https://reviewboard.mozilla.org/r/173402/#review179246

::: testing/specialpowers/content/SpecialPowersObserver.jsm:258
(Diff revision 2)
>        }
>        let createdFiles = this._createdFiles;
>        try {
>          let promises = [];
>          aMessage.data.forEach(function(request) {
> -          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.

https://reviewboard.mozilla.org/r/173404/#review179252
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)
https://hg.mozilla.org/mozilla-central/rev/3a804c720f13
https://hg.mozilla.org/mozilla-central/rev/0ab0630eec0c
Status: NEW → RESOLVED
Closed: 2 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.