Re:Headless mode in Firefox
by zimpenfish on Friday September 01, 2017 @04:57AM
(#15147072)
Amusingly, I had this same problem back in ~1999 when trying to automatically screen capture webpages with Netscape on X.
Except then it was just a case of "wait 30 seconds and pray" because there was none of this fanciness.
(bloody kids, get off my lawn, banging two rocks together, etc.)
I don't think this feature is "utterly unusable". You can run your JS, wait for whatever events you want, and then pipe the resulting HTML to a --print-to-pdf command.
Re:Headless mode in Firefox
by developer2 on Monday September 04, 2017 @10:41AM
(#15168507)
The primary reason to print a pdf would be to do so to any random 3rd party page. Sadly, you have no control over how 3rd party sites render/load their content. And --print-to-pdf likely captures the render of the page at some predetermined point, my guess being the "onload" event. Which, again, is not going to result in a fully rendered page for many sites that load in their primary content using AJAX.
Capturing the PDF at even the onload event (let alone the useless DOMContentLoaded event) is going to capture an incomplete picture in a huge number of situations. Frankly, a PDF capture at onload event is going to be utterly unusable. Is there a way to set a delay before capturing, ie: 10 seconds?
In an ideal world, a true "finished loading" event would trigger only after all DOMContentLoaded and onload handlers are executed, only once any AJAX requests launched by such handlers are completed (including requests fired off in their handlers, recursively). Of course, websockets and long polling ajax would still interfere with detecting a true "finished" event, but it'd be better than setting an artificially large delay of 10+ seconds.