Live data from Hacker News

Headless mode in Firefox

developer.mozilla.org

71–80 of 191 posts

Re: Headless mode in Firefox

#71
post #65
post #23

Earlier quoted context omitted.

No it isn't, the URL is unreliable source of truth with Unicode spoofing attacks and things like that. Safari only shows the domain at this point; the URL is an unimportant implementation detail.

How would you differentiate say: " http://googlemail.buyviagra.com" From: " https://mail.google.com" If they looked the same.

[deleted]

Re: Headless mode in Firefox

#72
post #45

Earlier quoted context omitted.

Does this offer any real benefit over Xvfb?

We were using Xvfb with PhantomJS. Moving to a headless browser gave us the advantage of making sure everything is rendering just as we see in the GUI mode of that browser. This had a lot to do with moving away from PhantomJS. But it also removed the unkowns, Xvfb and other dependencies that came with it, from our stack. The lesser the unkowns the better I guess.

Wait, why did you need to use XVFB with PhantomJS? Isn't Phantom headless as is?

Re: Headless mode in Firefox

#73
post #17
post #6

Can you tell Firefox to print in headless mode? I want to write reports using HTML and JS, but printing is always an issue.

You can generate pdfs with headless Chromium/Chrome pretty easily[1]. chromium-browser --headless --disable-gpu --print-to-pdf=output_file_name.pdf file:///path/to/your/html [1] https://developers.google.com/web/updates/2017/04/headless-c...

I built a simple REST API that wraps this call for my other projects and it's been working great the past few months. If this would be useful to you my contact info is in my profile.

Re: Headless mode in Firefox

#74
post #45

Earlier quoted context omitted.

We were using Xvfb with PhantomJS. Moving to a headless browser gave us the advantage of making sure everything is rendering just as we see in the GUI mode of that browser. This had a lot to do with moving away from PhantomJS. But it also removed the unkowns, Xvfb and other dependencies that came with it, from our stack. The lesser the unkowns the better I guess.

Wait, why did you need to use XVFB with PhantomJS? Isn't Phantom headless as is?

Still requires a X server, which docker containers won't necessarily have.

Re: Headless mode in Firefox

#75
post #6

Can you tell Firefox to print in headless mode? I want to write reports using HTML and JS, but printing is always an issue.

One word -- wkhtmltopdf

I've used wkhtmltopdf for years and it's really great. However, having a browser (headless Chrome and now Firefox) render the page closes the gap between what we build in HTML and what we want to output in a PDF, without having to deal with nuances of the wkhtmltopdf rendering engine.

Re: Headless mode in Firefox

#76

Earlier quoted context omitted.

Wow - thanks for posting that: could come in handy on the project I'm currently working on!

We're using Chrome Headless inside Docker to produce thousands of PDF reports from an Angular/D3 web app. It works very well, but there are some gotchas with regard to the Chrome Remoting Interface.

Can you elaborate on some of the issues you're having in the Chrome Remote Interface?

Re: Headless mode in Firefox

#77
Perhaps I'm spoiled, but I'm wondering why this wasn't a thing many years ago. Am I wrong in saying this was brought about in reaction to Chrome adding the same feature, or has this been there for a while? Clearly people wanted this for ages, hence the work on things like PhantomJS. But it seems like it was only added once they realized they needed to play catch-up with Chrome.

Re: Headless mode in Firefox

#78
post #29

Earlier quoted context omitted.

I'm currently evaluating testcafe which is pretty nice, and headless chrome was easy to setup. I'm interested to see what people recommend for browser testing, I'm also using preact.

Writing end-to-end tests is always a sucky and flaky experience, and it always ends up slowing down CI. With that said, I've used testcafe without any big complaints. My general rule of thumb is to try having as few end-to-end tests as possible. It's fine for an e2e test to cover multiple aspects of your application. Trying to write e2e tests as if they were unit tests just leads to sadness and infinite CI builds. I…

Totally agree. I am a fan of Test Pyramid model, where at the top you have a very small number of long running, complex tests (usually e2e), and at the very bottom you have a lot of small, isolated and very fast unit tests.

Testing everything in a browser/e2e provides a rather poor cost/benefit ratio, especially as the project grows and more features and tests are added, so it should be reserved for cases where it is really important.

I like having e2e tests that cover the very core functionality and involve multiple parts of the stack. For example, if you have your rather typical app with a login modal, it's probably good to have a test that clicks on the button, makes sure that the modal is visible, and the user is redirected to the expected page after logging in. But testing if error message is displayed if email address is invalid? That's too much.

Re: Headless mode in Firefox

#79
post #55
post #44

Earlier quoted context omitted.

That's what Xvfb is for. "xvfb-run firefox" and "firefox -headless" should be functionally equivalent. But I would still be interested in performance comparison with numbers.

Doesn't xvfb still just run an Xserver, simply without painting? Or do headless Chrome and Firefox still require an X server running too?

You're right, there is a difference.

I meant equivalent from the point of view of the user who wants to run tests, not on the way they work internally.

Re: Headless mode in Firefox

#80
post #53
post #17

Earlier quoted context omitted.

You can generate pdfs with headless Chromium/Chrome pretty easily[1]. chromium-browser --headless --disable-gpu --print-to-pdf=output_file_name.pdf file:///path/to/your/html [1] https://developers.google.com/web/updates/2017/04/headless-c...

If only browsers supported creation of page headers and footers.

@page { @top-center { content: element(pageHeader); } } #pageHeader{ position: running(pageHeader); }

http://www.w3.org/TR/css3-gcpm/#running-elements

Post reply on HN