Prevent mozPrintCallback being invoked with the wrong <canvas> element
Categories
(Core :: Printing: Setup, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox69 | --- | fixed |
People
(Reporter: jwatt, Assigned: jwatt)
Details
Attachments
(1 file)
| Assignee | ||
Comment 1•6 years ago
|
||
Since the Firefox print preview code creates a static clone from the existing print preview static clone for any print preview settings changes, for enabling of simplified mode, and for a print from a print preview document, HTMLCanvasElement::CopyInnerTo may be invoked on an existing static clone. In that case, the mozPrintCallback's printState.context.canvas would previously have ended up using the canvas in the previous print preview static clone, which is wrong.
This is actually not as straightforward to trigger as you might think, since for settings changes the previous static clone is discarded, so any mozPrintCallback mutations to it are not seen. It is visible however if you print while in print preview, since the original print preview document is kept and keeps displaying after the print static clone is created and printed. It's also visible when switching to/from simplified mode since that uses two tabs (one for normal print preview, another for the simplified print preview).
For example, open about:blank and use the web console to invoke the following:
let p = document.createElement("p");
p.id = "myp"
p.textContent = "original"
document.body.append(p)
let c = document.createElement("canvas");
c.mozPrintCallback=(printState)=>{printState.context.canvas.ownerDocument.querySelector("#myp").textContent+=" mutated"}
document.body.append(c)
Now print preview it, and print from the print preview window. On finishing the actual print, the print preview window will now be displaying "original mutated" instead of just "original".
| Assignee | ||
Comment 2•6 years ago
|
||
Since the Firefox print preview code creates a static clone from the existing
print preview static clone for any print preview settings changes, for enabling
of simplified mode, and for a print from a print preview document,
HTMLCanvasElement::CopyInnerTo may be invoked on an existing static clone.
In that case, the mozPrintCallback's printState.context.canvas would previously
have ended up using the canvas in the previous print preview static clone,
which is wrong, and allow the callback to modify the static clone document.
Comment 4•6 years ago
|
||
| bugherder | ||
Description
•