Open Bug 413154 Opened 17 years ago Updated 2 years ago

"The document cannot change while Printing or in Print Preview." is a stupid error message

Categories

(Core :: Layout, defect)

defect

Tracking

()

People

(Reporter: ted, Unassigned)

References

()

Details

(Keywords: polish)

Attachments

(1 file)

I got this error message while print previewing something.  I guess the page loaded something using JavaScript while I had it open in Print Preview.  The error message didn't do anything useful for me, I just clicked "OK" and continued printing.  Why do we even have this error message?  The code should just handle it gracefully, or deal with it in some way that doesn't involve the user.
I got ~5 copies of this same error after leaving the Firefox Tinderbox page open in print-preview for a few minutes.
Probably the iframes refreshing?
Yeah, i think so.
I do printing in my application by having some javascript at the end of the page like:
	<script language:JavaScript>
	<!--
		if( window.print ) {
			resizeWin('.$width.');
			window.print();
			restoreWinSize();
			if( ret ) {
				setTimeout(\'window.location=ret;\', 2000);
			} else {
				setTimeout(\'window.history.back();\', 2000);
			}
		} else {
			alert(\'Your browser does not support the window.print() function.  Use your browser\\\'s Print button instead.\');
		}
	-->
	</script>

This is intended to give the browser 2 seconds to launch the print, then it should go to the specified page.  Under 2.0.0.xx it all worked fine.  Under 3.0 it now generates the error message and apparently disabled the "window.location" directive.  It is possible that many of these type of pages are chained together and this problem breaks the chain at the first one.

Very bad problem from an application perspective.  I cannot allow my clients to upgrade to 3.0 until this issue is addressed.  In fact, I have to keep them at 2.0.0.14 because in 2.0.0.15 and extra blank page is now printed!
Tony: Those issues you mention (especially the second one) merit new bugs, separate from this one.

Could you file one for each issue? (one on the script-not-working issue, and one on the extra-blank-page issue?)  If possible, please attach a testcase to each bug that demonstrates the issue.

Please mention the bug numbers here in a comment, as well.  Thanks!
You can reproduce the message with this testcase, which contains a meta refresh. Just load the testcase, and then print preview it. After a few seconds you should get an alert box with the error.

It seems to me that we should just disable meta refresh in print preview and avoid this altogether.
I'm seeing this on 3.5b4 when I print just about everything from commercial websites.  The printing works as long as I dismiss the dialog.  I did once see what I think is a race condition where the dialog stole focus, wouldn't dismiss, and I had to kill Firefox to get control back.

Principle: don't bother the user with non-critical errors they can't prevent and can't correct.

What would happen if we just removed the call to display this dialog?  Removing user annoyance would be in the 'pros' column.
Keywords: polish

There is no error message shown now in current versions of Firefox. It only refreshes the page and you have to go into the print menu again. Is this as intendet and we should close this bug or is this still an issue?

Flags: needinfo?(dholbert)

This error message still exists in the code, but it looks like it's not possible to trigger.

The string is here:

isprinting=The document cannot change while Printing or in Print Preview.

https://searchfox.org/mozilla-central/rev/5dd1f5147d3ffffb0dbd1c8cc9262887bec58014/browser/locales/en-US/chrome/overrides/appstrings.properties#21
https://searchfox.org/mozilla-central/rev/5dd1f5147d3ffffb0dbd1c8cc9262887bec58014/dom/locales/en-US/chrome/appstrings.properties#20

And it looks like we're set up to display that error string from nsDocShell::DisplayLoadError if we encounter a particular error code:

case NS_ERROR_DOCUMENT_IS_PRINTMODE:
  // Doc navigation attempted while Printing or Print Preview
  error = "isprinting";
  break;

https://searchfox.org/mozilla-central/rev/5dd1f5147d3ffffb0dbd1c8cc9262887bec58014/docshell/base/nsDocShell.cpp#3796-3799

But it looks like we never actually use that error code elsewhere in the codebase, so this is probably all dead code.

Oh, sorry, I did a bogus search. We do use that error code in one spot:
https://searchfox.org/mozilla-central/rev/5dd1f5147d3ffffb0dbd1c8cc9262887bec58014/docshell/base/nsDocShell.cpp#3310-3315

bool nsDocShell::NavigationBlockedByPrinting(bool aDisplayErrorDialog) {
  if (!mBrowsingContext->Top()->GetIsPrinting()) {
    return false;
  }
  if (aDisplayErrorDialog) {
    DisplayLoadError(NS_ERROR_DOCUMENT_IS_PRINTMODE, nullptr, nullptr, nullptr);

That seems reachable in theory. So, we might be at-a-loss for exact STR here, but in theory this is still an issue (in that the error message still exists in the codebase and it's still theoretically possible to trigger it).

Not a huge priority, but also not quite good to close.

Flags: needinfo?(dholbert)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: