Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Printing steps" should not run in parallel #4686

Closed
domenic opened this issue Jun 10, 2019 · 2 comments · Fixed by #4690
Closed

"Printing steps" should not run in parallel #4686

domenic opened this issue Jun 10, 2019 · 2 comments · Fixed by #4690

Comments

@domenic
Copy link
Member

domenic commented Jun 10, 2019

https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#printing

When the print() method is invoked, if the Document is ready for post-load tasks, then the user agent must run the printing steps in parallel. Otherwise, the user agent must only set the print when loaded flag on the Document.

As pointed out by @TimothyGu in #4682, it seems like there are several steps inside the printing steps that should be run from a the main thread, not from in-parallel. E.g. steps 3 and 4 fire an event; and step 4 may pause (and pause seems to explicitly pause a task).

One thing to test here is whether beforeprint fires synchronously when calling print(). If that is true, then the solution is:

If that is not true, then the solution is a bit more complicated.

@TimothyGu
Copy link
Member

Seems like we are in the lucky case. On Firefox and Chrome (not sure about Safari), everything seems to be synchronous. In particular, the following

onbeforeprint = () => { console.log('beforeprint'); };
onafterprint  = () => { console.log('afterprint');  };
console.log('before calling print()');
window.print();
console.log('after print() returns');

prints

before calling print()
beforeprint
afterprint
after print() returns

in both Chrome and Firefox. I'll go ahead and create a PR.

TimothyGu added a commit to TimothyGu/html that referenced this issue Jun 12, 2019
This was a slip-up in the larger clean-up commit in 61da493, where
"synchronous" was changed to "in parallel". All browsers implement the
synchronous behavior.

Fixes whatwg#4686.
@zcorpan
Copy link
Member

zcorpan commented Jun 13, 2019

WebKit seems to not support the events. https://bugs.webkit.org/show_bug.cgi?id=19937

cc @cdumez

domenic pushed a commit that referenced this issue Jun 24, 2019
This was a slip-up in the larger clean-up commit in 61da493, where
"synchronous" was changed to "in parallel". All browsers implement the
synchronous behavior.

Fixes #4686.

Tests: web-platform-tests/wpt#17439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants