Open Bug 1396455 Opened 7 years ago Updated 2 years ago

Print Preview: changing cppBrowser's contentDocument.title in onEnter() function updates DOM (and printed title header), but not the title header displayed in preview

Categories

(Toolkit :: Printing, defect, P3)

defect

Tracking

()

People

(Reporter: thomas8, Unassigned)

References

Details

+++ This bug was initially created as a clone of Bug #759039 +++

Toolkit's Print Preview comes with an onEnter event and associated listener function which according to documentation allows to "put content into print preview".
This works correctly for changing actual content of the PPBrowser's contentDocument (e.g. the documents background color), where the preview will show those changes (i.e. both DOM and preview display are updated immediately without further interventions).
However, changing the contentDocument.title of the PPBrowser will only update the DOM, but not display the change in the title header of the actual print preview (upper left corner). Confusingly, it will correctly *print* the *updated* title, which per this bug is different from the displayed title.

This might be bug in the TB implementation, but unless shown otherwise, I'll assume it's in the underlying toolkit code.

https://dxr.mozilla.org/comm-central/source/mozilla/toolkit/components/printing/content/printUtils.js#38-42
> *   Printing:Preview:Enter
> *     This message is sent to put content into print preview mode. We pass
> *     the content window of the browser we're showing the preview of, and
> *     the target of the message is the browser that we'll be showing the
> *     preview in.


STR

1) In PrintPreviewListener, have a custom function for onEnter event (onEnter function), where you change the title of the generated print preview document:

e.g. https://dxr.mozilla.org/comm-central/source/suite/mailnews/compose/MsgComposeCommands.js#857
> var PrintPreviewListener = {
> ...
>   onEnter()
>   {
>     let cppDoc = document.getElementById("cppBrowser").contentDocument;
>     cppDoc.title = "new preview title";
>     // Now, the new title is set in DOM, but not seen in preview header.
>     // But when printing, new title will surprisingly appear.
>     cppDoc.bgcolor = "yellow";
>     // By contrast, the new bgcolor is immediately seen in preview.
>
>     // Workaround to force title update in print preview header
>     // alert ("check header title: about to force preview update via PrintUtils.printPreview()");
>     // PrintUtils.printPreview();
>     // After forcing preview update, new title also seen in preview.
>   },
> ...
> ]\


2) check header title in upper left corner of print preview
3) check header title in upper left corner of printout

Actual Result

(cf. comment in code above)
2) if preview update is not forced via calling PrintUtils.printPreview again, new title is set in DOM, but not reflecting in the displayed title header of  print preview (unless forced via recursively calling PrintUtils.printPreview()).
3) When printing, new title header will surprisingly appear.

Expected Result

2) As per documentation, and just like any other changes to the preview content document (e.g. bgcolor), changing the title in onEnter() function should immediately reflect in the title header of preview display, without the need to force update via calling PrintUtils.printPreview() from within itself.
Summary: Print Preview: changing contentDocument.title in onEnter() function updates DOM (and printed title header), but not the title header displayed in preview → Print Preview: changing cppBrowser's contentDocument.title in onEnter() function updates DOM (and printed title header), but not the title header displayed in preview
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.