Closed Bug 638709 Opened 13 years ago Closed 13 years ago

DOM change while print dialog shows never allows changes/refreshes anymore

Categories

(Core :: Printing: Setup, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: nicolas, Assigned: smaug)

References

Details

(Keywords: regression)

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b12) Gecko/20100101 Firefox/4.0b12
Build Identifier: 4.0b12

While creating a function to print part of a page I ran into the problem that if an iframe is removed while the print dialog is open, the browser never accepts any change in page anymore with the message:

Alert: The document cannot change while Printing or in Print Preview

Pressing the reload button or a link also does not work. The tab has to be closed.

Reproducible: Always

Steps to Reproduce:
Run this. Happens every time.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Print Test</title>
<script>
function init() {
  var html = 'Test <b>frame</b> contents';
  var frameHtml = '<html><body onload="print();">'+html+'</body></html>';
  var iframe = document.getElementById('printFrame');

  var doc = iframe.contentDocument;
  doc.open();
  doc.write( frameHtml );
  doc.close();

  setTimeout( function() { iframe.parentNode.removeChild(iframe); }, 1000 );
}
</script>
</head>
<body onload="init();">
	<h2>Print Generated HTML test</h2>
	<iframe id="printFrame"></iframe>
</body>
</html>

Actual Results:  
After running this script, the page won't change or reload anymore.

Expected Results:  
Page should be able to refresh.

My solution is to make the timeout larger to remove the iframe (haven't found a way to generate an event that printing is done) that was dynamically added to print.

Tested in Chrome as well and runs fine there.

This may be related to any or more of the following other tickets:

Bug 601722 - Page redirect while printing causes unacknowledgable modal alert, deadlock situation [Mac] 
Bug 476541 - Hang if page puts up an alert sheet while a modal dialog is open [Mac] 
Bug 615931 - Putting up tab-modal alert while print dialog is up causes 100% CPU hang 

Note that I tested this on Windows 7 so this is certainly not MAC specific.

While this may be a border-case, it shows a flaw in the event handling that may help find the cause of the related tickets.
Assignee: nobody → Olli.Pettay
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
This is a regression from Bug 487667 which landed 2009 :/
Attached patch patchSplinter Review
Keep a pointer to the top level content docshell while printing so that we can
mark it non-printing.

This is for now. I'll file a followup to remove the whole mark-non-printing-document-being-printed-flag. That may require some more changes, but shouldn't
be too difficult.

Still thinking about automatic tests for this.
Attachment #516851 - Flags: review?(roc)
Component: Event Handling → Printing: Setup
QA Contact: events → printing.setup
Depends on: 638736
In theory, if we'll have RC2 or 3 we could the take the fix, IMO.
But most probably this needs to wait few months to FF5.
Keywords: regression
Blocks: 638736
No longer depends on: 638736
Comment on attachment 516851 [details] [diff] [review]
patch

With document cloning we shouldn't have to do any of this SetIsPrintingInDocShellTree should we?
Attachment #516851 - Flags: review?(roc) → review+
This is sort of left-over from the clone-doc patch.
The patch in this bug is the safest approach to fix this, I think.
Even for FF4.x if needed.
http://hg.mozilla.org/mozilla-central/rev/fb507e8752fe
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: