iframe added during onafterprint is never loaded
Categories
(Core :: DOM: Navigation, defect)
Tracking
()
People
(Reporter: shlomo, Unassigned)
References
(Depends on 1 open bug)
Details
(Keywords: parity-chrome)
Attachments
(1 file)
|
719 bytes,
text/html
|
Details |
Steps to reproduce:
The following document has an iframe with the contents "A" which is printed on load.
After closing the Print dialog, a second iframe with the contents "B" should be added to the document.
<!doctype html>
<iframe id="a" srcdoc="A"></iframe>
<script>
function addIFrame() {
const b = document.createElement("iframe");
b.onload = () => { console.log("b onload"); }
b.srcdoc = "B";
document.body.appendChild(b);
}
const a = document.getElementById("a");
a.onload = () => {
a.contentWindow.onafterprint = addIFrame;
// WORKAROUND:
// a.contentWindow.onafterprint = setTimeout(() => { addIFrame(); });
a.contentWindow.print();
}
</script>
Actual results:
The second iframe is empty (and its onload event never runs).
Expected results:
The second iframe has the contents "B" (and its onload event runs).
This works on Chromium.
On Firefox, I need to call setTimeout as a workaround (see commented-out line above).
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Indeed, it works on Chrome, but not on Firefox.
Updated•1 year ago
|
Sean, do you have any ideas?
Comment 4•1 year ago
|
||
We don't allow navigation when the top BC is in printing mode https://searchfox.org/mozilla-central/rev/80ae03d93e3fd5769b16f37719b610e359f8fc62/docshell/base/nsDocShell.cpp#3047
Emilio, thoughts...?
(I think afterprint should be dispatched to notify web apps of ending the printing mode, so, any printing mode limitation shouldn't be applied at least. Ideally, the pending navigation should start before or after that.)
Comment 6•1 year ago
|
||
Bug 1663290 is on file to consider changing when we dispatch afterprint. Probably that fixes this use-case.
Description
•