Closed Bug 1793627 Opened 3 years ago Closed 3 years ago

afterprint event is triggered when the print dialog is opened

Categories

(Toolkit :: Printing, defect, P2)

Firefox 105
defect

Tracking

()

RESOLVED INVALID
Tracking Status
firefox-esr102 --- wontfix
firefox105 --- wontfix
firefox106 --- wontfix
firefox107 --- wontfix
firefox108 --- wontfix

People

(Reporter: Radoslav.Yankov, Unassigned)

References

(Regression)

Details

(Keywords: regression)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0

Steps to reproduce:

window.onbeforeprint = function () {
console.log('before') // this should appear when the dialog appears
};
window.onafterprint = function () {
console.log('after') // this should appear when the dialog disappears, but actually appears immediately
};
window.print(); or Ctrl + P

Actual results:

afterprint event is triggered when the print dialog is opened.

Expected results:

afterprint event should be triggered afer closing the print dialog.
For comparison, Chrome fires afterprint after the dialog is closed in either case (printing dispatched or dialog cancelled).

The Bugbug bot thinks this bug should belong to the 'Toolkit::Printing' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Printing
Product: Firefox → Toolkit
Severity: -- → S2
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mstriemer)
Priority: -- → P2
QA Whiteboard: [qa-regression-triage]

Hello,

QA would want to help pull a regression range for this issue.

Is anything that we can do here? If yes, could you please give us a more in-depth STR?

STR:

  1. Navigate to data:text/html,<script>window.onbeforeprint = ()=>console.log('before');window.onafterprint = ()=>console.log('after');</script>
  2. Open the console (Ctrl+Shift+K)
  3. Print (Ctrl+P)

Expected results:

  • Console shows:
    • before

Actual results:

  • Console shows:
    • before
    • after

Thank you, Mark!
Attaching the regression range made on Windows 10x64:
Last good revision: 52ae1bffec15aeea1deb8213af9948e57ad5d0cc (2020-07-10)
First bad revision: 517957ca7a3c2892a4ae3c7491fb538a5d84aa12 (2020-07-11)
Pushlog:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=52ae1bffec15aeea1deb8213af9948e57ad5d0cc&tochange=517957ca7a3c2892a4ae3c7491fb538a5d84aa12
I have also searched for a recent regression including the new print modal but I didn't find one.

Unfortunately, mozregression cannot bisect further because the builds are old and I don't know which one is the culprit here. At first glance bug 1557983 and bug 1651532 looks printing related. Hope it helps. If more information is needed please let us know.

Has STR: --- → yes

Seems quite likely bug 1557983 regressed this then, Jonathan do you mind taking a look?

Flags: needinfo?(mstriemer) → needinfo?(jwatt)
Regressed by: 1557983

Set release status flags based on info from the regressing bug 1557983

Set release status flags based on info from the regressing bug 1557983

This behavior is intentional.

The beforeprint/afterprint events are intended to allow script to make changes to a document to make it more suitable for printing, then to revert those changes once they are no longer needed so that the on-screen document doesn't continue to show the for-print changes.

Shortly after the beforeprint event fires, Mozilla's printing implementation clones the document that is to be printed, which allows the afterprint event to be fired immediately after the clone is complete. That means that there is no need to wait until the print dialog closes to fire afterprint.

Status: NEW → RESOLVED
Closed: 3 years ago
Flags: needinfo?(jwatt)
Resolution: --- → INVALID
See Also: → 1815734
You need to log in before you can comment on or make changes to this bug.