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

RESOLVED FIXED in 4.7.2

Status

defect
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: ssitter, Assigned: ssitter)

Tracking

Lightning 4.7
4.7.2

Details

Attachments

(1 attachment)

Assignee

Description

3 years ago
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

Comment 1

3 years ago
Assignee: nobody → ssitter
Status: NEW → ASSIGNED
Attachment #8736349 - Flags: review?(philipp)
Assignee

Comment 2

3 years ago
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

Comment 3

3 years ago
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
Assignee

Comment 4

3 years ago
(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+
Assignee

Updated

3 years ago
Keywords: checkin-needed

Comment 6

3 years ago
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

Updated

3 years ago
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 5.1
Assignee

Updated

3 years ago
Keywords: checkin-needed
Whiteboard: [checkin-needed comm-aurora, comm-beta]

Comment 7

3 years ago
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

Comment 8

3 years ago
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.