Bug 136335 - window.print() is blocked until XMLHttpRequest completes
Summary: window.print() is blocked until XMLHttpRequest completes
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Printing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.9
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-08-28 03:09 PDT by Andrew Paprotsky
Modified: 2017-10-17 12:25 PDT (History)
5 users (show)

See Also:


Attachments
reproducible test case (807 bytes, application/zip)
2014-08-28 03:11 PDT, Andrew Paprotsky
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Paprotsky 2014-08-28 03:09:48 PDT
If there's an active XMLHttpRequest window.print() is blocked; print dialog appears only when the request is completed. This is a problem for cases when XMLHttpRequest is used for long-polling.

Steps to reproduce:
1. Extract the attached archive to a PHP enabled web server
2. Visit the index.php.
3. Click the button to see the result.
Comment 1 Andrew Paprotsky 2014-08-28 03:11:03 PDT
Created attachment 237302 [details]
reproducible test case
Comment 2 Alexey Proskuryakov 2014-08-28 13:19:15 PDT
Thank you for the bug report.

I think that this is unintentional (and a consequence of delaying a print() that's called from an inline script), yet this still looks like a correct behavior.

If XHR progress events were displayed under a modal print dialog, that would cause many undesirable effects (e.g. what if event handler tried to do a window.close() while the window was being printed). And if we stopped progress events, that would cause correctness issues on websites that expect them to be handled in a timely manner.
Comment 3 Andrew Paprotsky 2014-08-28 23:04:20 PDT
Thanks for the quick reply.

The problem is that if I want to print something using window.print() then I have to wait until active XHR is completed. So if I have a long-polling request with 10 minutes timeout then in worst case I'd have to wait 10 minutes until the print dialog appears.
Comment 4 Philipp Spiess 2017-10-16 09:51:02 PDT
This is still an issue. Chrome seems to have fixed this [1], are there any plans for Safari to do the same as well?

This makes it impossible to use the print API for websites that rely on long-polling to get real time updates.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=173140
Comment 5 Radar WebKit Bug Importer 2017-10-17 12:25:46 PDT
<rdar://problem/35035119>