Closed Bug 1260768 Opened 8 years ago Closed 8 years ago

showError() function is broken [Error: can't access lexical declaration 'window' before initialization]

Categories

(Calendar :: General, defect)

Lightning 4.7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ssitter, Assigned: ssitter)

Details

Attachments

(1 file)

Lightning 4.9a2 (Build ID 20160330004109)

I tried to import an ics file that resulted in an import error. But instead of the import error dialog I got nothing. Error console shows:

Error: ReferenceError: can't access lexical declaration 'window' before initialization
Source File: chrome://calendar/content/calUtils.js
Line: 1008
Assignee: nobody → ssitter
Status: NEW → ASSIGNED
Attachment #8736349 - Flags: review?(philipp)
Reported with Lightning 4.7b2 (Build ID 20160218191916) and Thunderbird 45.0 too.
OS: Unspecified → All
Hardware: Unspecified → All
Version: Lightning 4.9 → Lightning 4.7
There is one more place in the calendar code where window is used as a variable name. Does that need to be renamed, too?

https://mxr.mozilla.org/comm-central/source/calendar/base/modules/calProviderUtils.jsm#432
(In reply to MakeMyDay from comment #3)
I think it should be fine. In cal_promptOverwrite it just declares a local variable window.

Philipp, In my opinion we should consider porting back the fix, because as of now errors are not reported to the user but hidden in console due to this problem.
Comment on attachment 8736349 [details] [diff] [review]
use different variable name to avoid conflict with outer window object

Review of attachment 8736349 [details] [diff] [review]:
-----------------------------------------------------------------

How far did you want this backported? ESR45?

::: calendar/base/src/calUtils.js
@@ +1004,5 @@
>   *
>   * @param aMsg The message to be shown
>   */
>  function showError(aMsg) {
> +    let wnd = window || null;

I know it has been this way before, but it could actually show a `ReferenceError: window is not defined`, at least when I test it in xpcshell. You could use `let wnd = typeof "window" === undefined ? null : window`.
Attachment #8736349 - Flags: review?(philipp)
Attachment #8736349 - Flags: review+
Attachment #8736349 - Flags: approval-calendar-release+
Attachment #8736349 - Flags: approval-calendar-beta+
Attachment #8736349 - Flags: approval-calendar-aurora+
Keywords: checkin-needed
https://hg.mozilla.org/comm-central/rev/cbdfc91f5d59f351e818d534eb075ce1d262e2b9
Bug 1260768 - showError() function is broken [Error: can't access lexical declaration 'window' before initialization]. r=Fallen
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 5.1
Keywords: checkin-needed
Whiteboard: [checkin-needed comm-aurora, comm-beta]
https://hg.mozilla.org/releases/comm-aurora/rev/06c3aadde9bf312e681fd0e12bb253075b204b5a
https://hg.mozilla.org/releases/comm-beta/rev/b00046532da51845a963f918c8cec1e410b2e21f
Whiteboard: [checkin-needed comm-aurora, comm-beta] → [checkin-needed comm-esr45 after 45.1.1 was released]
Target Milestone: 5.1 → 4.9
https://hg.mozilla.org/releases/comm-esr45/rev/dfab8f086c880252c8c0cee5ed59b9a25e3b286a
Keywords: checkin-needed
Whiteboard: [checkin-needed comm-esr45 after 45.1.1 was released]
Target Milestone: 4.9 → 4.7.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: