Printing is not working [JavaScript Error: "PrintUtils.getWebBrowserPrint is not a function"]

RESOLVED FIXED in 6.5

Status

Calendar
Printing
P1
normal
RESOLVED FIXED
4 years ago
3 days ago

People

(Reporter: ssitter, Assigned: MakeMyDay)

Tracking

(Blocks: 1 bug)

Lightning 6.2

Details

Attachments

(2 attachments, 2 obsolete attachments)

(Reporter)

Description

4 years ago
Lightning 3.8a1 (BuildID 20141117030205) with Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Thunderbird/36.0a1

When trying to print it currently works but the following error will be reported:

> Error: DEPRECATION WARNING: getWebBrowserPrint is now deprecated, and fully unsupported for multi-process browsers. 
> Please use a frame script to get access to nsIWebBrowserPrint from content.
> You may find more details about this deprecation at: https://developer.mozilla.org/en-US/docs/Printing_from_a_XUL_App
> 
> chrome://global/content/printUtils.js 276 PrintUtils.getWebBrowserPrint
> chrome://calendar/content/calendar-print-dialog.js 265 finish
> chrome://calendar/content/calendar-print-dialog.js 234 getSettingsResponse
> chrome://calendar/content/calendar-print-dialog.js 136 onOperationComplete
> file:///[...]/components/calCompositeCalendar.js 516 calCompositeGetListenerHelper.prototype.onOperationComplete
> resource://calendar/modules/calProviderUtils.jsm 655 cPB_notifyPureOperationComplete
> resource://calendar/modules/calProviderUtils.jsm 669 cPB_notifyOperationComplete
> file:///[...]/components/calStorageCalendar.js 924 cSC_getItems_
> file:///[...]/components/calStorageCalendar.js 660 cSC_getItems/<
> null 0 null
> 
> Source File: resource:///modules/Deprecated.jsm Line: 79

Comment 1

3 years ago
I've been doing the other ones for TB and SM, so I'll give this one a go too.
Assignee: nobody → iann_bugzilla
Status: NEW → ASSIGNED

Comment 2

2 years ago
Hi Stefan

have you found a solution for this problem ?

Comment 3

2 years ago
Created attachment 8832383 [details]
Print Preview.png

(In reply to Ian Neal from comment #1)
> I've been doing the other ones for TB and SM, so I'll give this one a go too.

Will Lightning Calendar/Tasks use the Print Preview as shown in the attachment?

Thank you
(Reporter)

Comment 4

2 years ago
Ian, do you still intend to work on this bug?
Flags: needinfo?(iann_bugzilla)

Comment 5

2 years ago
CardBook now implements (not perfectly: direct printing not enabled) the standard print preview : this might be a good starting point for solving this bug...
Ian, any update on this? I'd appreciate if you could at least let us know what needs to be done. Is it sufficient to silence the warning given we are not using e10s? Is something else needed?

Philippe, if you have an idea how to fix this I would also be very interested.
Flags: needinfo?(iann_bugzilla)
Flags: needinfo?(iann_bugzilla)
(Reporter)

Comment 7

3 months ago
Lightning 6.2b3: Printing is completely broken because the deprecated functionality was removed in Thunderbird 60 with https://hg.mozilla.org/mozilla-central/rev/58996b7409fc 

NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS: [JavaScript Error: "PrintUtils.getWebBrowserPrint is not a function" {file: "chrome://calendar/content/calendar-print-dialog.js" line: 274}]'[JavaScript Error: "PrintUtils.getWebBrowserPrint is not a function" {file: "chrome://calendar/content/calendar-print-dialog.js" line: 274}]' when calling method: [calIOperationListener::onOperationComplete]  calCompositeCalendar.js:501
Blocks: 1414612
Summary: Printing throws error: DEPRECATION WARNING: getWebBrowserPrint is now deprecated, and fully unsupported for multi-process browsers. Please use a frame script to get access to nsIWebBrowserPrint from content. → Printing is not working [JavaScript Error: "PrintUtils.getWebBrowserPrint is not a function"]
Version: Lightning 3.8 → Lightning 6.2
(Reporter)

Updated

3 months ago
Assignee: iann_bugzilla → nobody
Status: ASSIGNED → NEW
(Reporter)

Updated

3 months ago
Duplicate of this bug: 1459681
Priority: -- → P1
(Assignee)

Comment 9

6 days ago
Created attachment 8992301 [details] [diff] [review]
RestoreCalendarPrinting-V1.diff

This patch brings back printing capability for calendar. It basically makes use of mailsnews msgPrintEngine. I came across some issues when writing it and I don't have final solutions but workarounds if necessary that are good to go for now (imgo) since this bug is the only remaining regression for 6.2.

1. I tried to set an event listener to printWindow, but this makes msgPrintEngine to complain about a missing opener. It seems adding the listener somehow invalidates the reference, although I don't understand why atm. So for now, I'm going to use setInterval to close the calenfdar print window once printing is completed. Not quite nice, but it works.

2. The html templates for the week and month views are refencing calendar-printing.css which will not be loaded due to missing priviledges, since the print window is and must be a content only window. I haven't tried yet wether loading the file as content in chrome manifest would resolve the issue - if not, we should probably just inline the few css definitions in the file. If it turned out to be a non-issue in 6.2, this would be an issue of the overlay loader code. Is there an option to do an upfront try-push to beta 60 to verify this?

3. There is a weird issue with updating css nodes in a document with a hex color definition in it in calPrintUtils. The serialzed document looks properly and loads in FF, but when loading it into the ifranme, it dies and dev tools show that there is loaded only a fraction up to the place where the # character of the new color declaration was inserted. I added a hex2int converter to work araound this for now.

4. And finally, another issue I observed (but not limited to printing) is that the rendering of the print preview will fail if a calendar failed to load before e.g. because it's unavailable. This looks definitely like a problem with the overlay loader, but I haven't investigated further (although I have to admit that im not using really the latest version of Geoffs patches, so that might have been resolved already)
Assignee: nobody → makemyday
Status: NEW → ASSIGNED
Attachment #8992301 - Flags: review?(philipp)
Comment on attachment 8992301 [details] [diff] [review]
RestoreCalendarPrinting-V1.diff

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

Thanks for working on this, especially kudos for testing it with the new loader. A few comments follow, r+ with them fixed:

::: calendar/base/content/dialogs/calendar-print-dialog.js
@@ +236,5 @@
>              }
>          } catch (e) {
>              Components.utils.reportError("Calendar print dialog:refreshHtml: " + e);
>          }
> +        document.getElementById("content").src = "data:text/html," + printContent;

You could possibly use document.getElementById("content").setAttribute("srcdoc", printContent); (or maybe there is also an undocumented attribute) otherwise you will have to percent-encode printContent.

This will also fix the issues with the # character, avoiding the need for the conversion.

@@ +260,5 @@
> +        statusFeedback = statusFeedback.QueryInterface(Ci.nsIMsgStatusFeedback);
> +
> +        let printWindow = window.openDialog("chrome://messenger/content/msgPrintEngine.xul",
> +                                            "", "chrome,dialog=no,all", 1,
> +                                            ["data:text/html," + printContent],

Needs percent encoding here.

@@ +274,5 @@
> +        }
> +
> +        // We use this to close the window once printing is completed - adding an
> +        // onunload listener to printWindow seems to invalidate the opener reference
> +        // in msgPrintEngine.

Can you try adding the unload listener to printWindow.document instead of the window (and make sure you are using the right target, and/or use a capturing event listener).

Would it otherwise be possible to use window.opener.openDialog() so that the print window is opened from the main window, which is unlikely to be closed as quickly?

::: calendar/base/modules/utils/calViewUtils.jsm
@@ +230,5 @@
> +     *
> +     * @param  {String} aColor  color defined as hex string like "#RRGGBB"
> +     * @return {String}         the rgb() equivalent if any - otherwise aColor
> +     */
> +    convertHexColor2Rgb: function(aColor) {

This method would not be needed with the percent encoding trick, if you do still need it I may have some comments.
Attachment #8992301 - Flags: review?(philipp) → review+
(Assignee)

Comment 11

4 days ago
Created attachment 8992718 [details] [diff] [review]
RestreCalendarPrinting-V2.diff

Thanks. The attached patch considers the above comments, fixes a problem in the html exporter and additionally inlines the applicable definitions from the css file that could not be loaded. I tried to no avail to move it to calendar/content. At this point it's not worth the effort to investigate it further (at least I won't do atm).

The srcdoc thing didn't work, but urlencoding did the trick, so I could remove the addional conversion.

Also closing the window with the listenmer now works, it was a little tricky since the window seems to be reloaded several times by the printing code what made listener to be removed too early - I added a respective comment.

Since I added some stuff, I'm asking for review again. Please also grant the approvals for beta and esr.
Attachment #8992301 - Attachment is obsolete: true
Attachment #8992718 - Flags: review?(philipp)
Attachment #8992718 - Flags: approval-calendar-esr?(philipp)
Attachment #8992718 - Flags: approval-calendar-beta?(philipp)
Comment on attachment 8992718 [details] [diff] [review]
RestreCalendarPrinting-V2.diff

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

One comment I missed from last time, if this doesn't work out for some reason fine with me as well. r=philipp

::: calendar/base/content/dialogs/calendar-print-dialog.js
@@ +6,5 @@
>  
>  ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
>  ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
>  
> +var printContent = "";

Can you have printContent be a local variable to the refreshHtml function and pass the results to finishFunc instead? This way we save a global variable.
Attachment #8992718 - Flags: review?(philipp)
Attachment #8992718 - Flags: review+
Attachment #8992718 - Flags: approval-calendar-esr?(philipp)
Attachment #8992718 - Flags: approval-calendar-esr+
Attachment #8992718 - Flags: approval-calendar-beta?(philipp)
Attachment #8992718 - Flags: approval-calendar-beta+
(Assignee)

Comment 13

4 days ago
(In reply to Philipp Kewisch [:Fallen] [:📆] from comment #12)
> Comment on attachment 8992718 [details] [diff] [review]
> RestreCalendarPrinting-V2.diff
> 
> Review of attachment 8992718 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> One comment I missed from last time, if this doesn't work out for some
> reason fine with me as well. r=philipp
> 
> ::: calendar/base/content/dialogs/calendar-print-dialog.js
> @@ +6,5 @@
> >  
> >  ChromeUtils.import("resource://calendar/modules/calUtils.jsm");
> >  ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
> >  
> > +var printContent = "";
> 
> Can you have printContent be a local variable to the refreshHtml function
> and pass the results to finishFunc instead? This way we save a global
> variable.


This would cause an issue with rending the title, so let's keep it as is, since we need to get this into 62 and printing deserves an overhauling anyway, so we could take care of it if/when doing so.
Keywords: checkin-needed
(Assignee)

Updated

4 days ago
Flags: needinfo?(iann_bugzilla)
(Assignee)

Comment 14

4 days ago
Created attachment 8992935 [details] [diff] [review]
RestoreCalendarPrinting-V3.diff

Updated patch since the linter was complaining about a missing ;
Attachment #8992718 - Attachment is obsolete: true
Attachment #8992935 - Flags: review+
Attachment #8992935 - Flags: approval-calendar-esr+
Attachment #8992935 - Flags: approval-calendar-beta+

Comment 15

3 days ago
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/0711b428d7ee
Restore Calendar printing. r=philipp DONTBUILD
Status: ASSIGNED → RESOLVED
Last Resolved: 3 days ago
Keywords: checkin-needed
Resolution: --- → FIXED

Updated

3 days ago
Target Milestone: --- → 6.5
You need to log in before you can comment on or make changes to this bug.