Closed Bug 814383 Opened 7 years ago Closed 7 years ago

javascript strict warnings in browser.js

Categories

(Firefox :: General, defect)

x86
macOS
defect
Not set

Tracking

()

RESOLVED FIXED
Firefox 20

People

(Reporter: jfkthame, Assigned: jfkthame)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch fix browser.js strict warnings (obsolete) — Splinter Review
There are an annoying number of Javascript strict warnings generated by browser.js during startup:

JavaScript strict warning: chrome://browser/content/browser.js, line 98: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 255: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 1114: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 1301: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 3099: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3101: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3103: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3105: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3107: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3109: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3111: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3113: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3116: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 10318: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11115: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11120: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11132: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11975: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 13096: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 14219: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 98: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 255: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 1114: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 1301: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 3099: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3101: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3103: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3105: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3107: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3109: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3111: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3113: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 3116: anonymous function does not always return a value
JavaScript strict warning: chrome://browser/content/browser.js, line 10318: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11115: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11120: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11132: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 11975: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 13096: in strict mode code, functions may be declared only at top level or immediately within another function
JavaScript strict warning: chrome://browser/content/browser.js, line 14219: anonymous function does not always return a value

The attached patch aims to fix these, by explicitly returning null where a return value is lacking, and moving local function declarations up to the top of their enclosing function.
Attachment #684383 - Flags: review?(gavin.sharp)
The "functions may be declared only at top level" warning really bothers me. Can we fix those by changing: function foo() {} -> var foo = function foo() {}, instead?
OK, that works too; here's a version of the patch using the var foo = ... approach.
Attachment #684383 - Attachment is obsolete: true
Attachment #684383 - Flags: review?(gavin.sharp)
https://hg.mozilla.org/integration/mozilla-inbound/rev/57e1c40c89c5
Assignee: nobody → jfkthame
Target Milestone: --- → Firefox 20
Thanks for fixing this!
https://hg.mozilla.org/mozilla-central/rev/57e1c40c89c5
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.