Bug 136335

Summary: window.print() is blocked until XMLHttpRequest completes
Product: WebKit Reporter: Andrew Paprotsky <andrew>
Component: PrintingAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ap, hello, simon.fraser, steipete, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Macintosh   
OS: OS X 10.9   
Attachments:
Description Flags
reproducible test case none

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>