Closed Bug 1265174 Opened 4 years ago Closed 2 years ago

closing print preview window in TB produces "useless expression" warning

Categories

(Toolkit :: Printing, defect, minor)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: aceman, Assigned: aceman)

Details

Attachments

(1 file, 1 obsolete file)

Closing print preview window (of a message) in Thunderbird produces "useless expression" warning:

Warning: TypeError: useless expression
Source File: chrome://messenger/content/msgPrintEngine.xul
Line: 1
Source Code:
null

The line seems wrong, the error could possibly be in
mailnews/base/content/msgPrintEngine.js
Product: MailNews Core → Toolkit
Attached patch 1265174.patch (obsolete) — Splinter Review
arai has found that the error really occurs at printUtils.js line 709, which is: document.documentElement.setAttribute("onclose", this._closeHandlerPP);

The msgPrintEngine.xul file has no 'onclose' attribute on the 'window' element defined.
Therefore this._closeHandlerPP can be null (https://dxr.mozilla.org/comm-release/rev/ca38c18d63f9dd59c93179cf3c43ddee58793f1e/mozilla/toolkit/components/printing/content/printUtils.js#679) so setting onclose to null at exit seems useless.

The patch makes the code at line 709 being the inverse of 679, i.e. if there was no "onclose" attribute at the start, remove it now, do not set it to null or empty.

This fixes the warning for me. Thanks arai!
Attachment #8942434 - Flags: review?(bugs)
Attachment #8942434 - Flags: feedback?(arai.unmht)
Comment on attachment 8942434 [details] [diff] [review]
1265174.patch

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

looks good.
thanks!
Attachment #8942434 - Flags: feedback?(arai.unmht) → feedback+
Comment on attachment 8942434 [details] [diff] [review]
1265174.patch

Looks like the file isn't consistent with if's {} usage.
Per coding style there should be {} always with if and else, so please add those.
Attachment #8942434 - Flags: review?(bugs) → review+
Sure, thanks.
Assignee: nobody → acelists
Status: NEW → ASSIGNED
Attachment #8942455 - Flags: review+
Keywords: checkin-needed
OS: Linux → All
Hardware: x86 → All
Attachment #8942434 - Attachment is obsolete: true
Pushed by ncsoregi@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/78776e9bdba1
do not restore "onclose" attribute to null value in print preview window, when there was none at the start. r=smaug
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/78776e9bdba1
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.