Closed Bug 628831 Opened 15 years ago Closed 14 years ago

Enable ES5 strict mode in Fennec JS files

Categories

(Firefox for Android Graveyard :: General, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: mbrubeck, Unassigned)

Details

Attachments

(1 file)

Attached patch patchSplinter Review
Enabling strict mode will help us to catch certain JavaScript mistakes sooner, give us some tools to protect against bad third-party JavaScript (e.g. from extensions) and in the future enable function inlining and other optimizations. For details, see: http://hacks.mozilla.org/2011/01/ecmascript-5-strict-mode-in-firefox-4/ This patch adds "use strict" to most of the core JS files in Fennec, and some of the larger components. It fixes a few things that don't work in strict mode (mostly arguments.callee and some duplicate 'let' bindings). It also has some unrelated comment cleanup.
Attachment #506934 - Flags: review?(mark.finkle)
Whiteboard: [has-patch]
Can't we do the same thing with "javascript.options.strict" = true ?
(In reply to comment #1) > Can't we do the same thing with "javascript.options.strict" = true ? It's much safer to do this per-file, especially since we use so many JS files outside of our control (from mozilla-central). Even if they are strict-mode compliant now, that might change in the future. If I'm not mistaken, javascript.options.strict also affects web content.
After researching this more, the "javascript.options.strict" pref is not the same as ES5 strict mode. This pref enables additional warnings that appear in the error console for both chrome and content JavaScript. ES5 strict mode ("use strict") changes the run-time behavior of the JS engine in ways that allow earlier error detection, better protection against malicious or buggy code, and (in the future) better optimization by the compiler.
Comment on attachment 506934 [details] [diff] [review] patch I don't see a reason to take this for Fennec 4. The code requires changes which means we could be breaking stuff. The patch fixes what you found, but there could be other stuff you didn't find. I'd be willing to take this after fennec 4.
Attachment #506934 - Flags: review?(mark.finkle) → review-
Whiteboard: [has-patch] → [has-patch][waiting for after 4.0]
I'm not feeling motivated to pick this up again. We can start by doing this for new files.
Assignee: mbrubeck → nobody
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
Whiteboard: [has-patch][waiting for after 4.0]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: