16 ms·
Headless mode in Firefox
- Vinnl 9y agoNote that this works in the latest release only on Linux - Windows and OS X support is coming in the next release in a few weeks.
- bobwaycott 9y ago> Headless Firefox works on Fx55+ on Linux, and 56+ on Windows/Mac. Edit: so people know what versions are pegged.
- fairpx 9y agoAs a UI designer, I dream of strikeheadlessstrike chromeless browsers, where the UI appears when you need it, intuitively, even when NOT in full screen. The top bar simply takes too much unnecessary space. If there's any dev that wants to collaborate on this, let me know :)
- caiob 9y agoFrom a security POV, the URL being displayed at all times is absolutely necessary in order to avoid phishing.
- fairpx 9y agoI think there are certain elements that can be displayed differently. So maybe semi-headless is the solution.
- mikewhy 9y agoSounds like any browser when full-screened on macOS.
- 2close4comfort 9y agoOr popups? Just imagine how realistic I could make a popup box seem know people will just think that it is from the operating system which I can also detect in another headless window along with another transparent window for bitcoin mining...I think you get the idea. UX yeah this is neat for appliances it will make for more seamless experiences, lets just hope you all are sanitizing inputs and building in secure methods of auth to make the experience worth the risk.
- nilved 9y agoNo 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.
- etplayer 9y agoIt would be cool if browsers could highlight URLs that contain the kind of characters which are commonly used to spoof, though I suppose it would lead people to a false sense of security.
- noisem4ker 9y agoJust set your browser to always show punycode. On Firefox, network.IDN_show_punycode = true URLs are no place for unicode characters to hide in. An xn-- prefix is all the warning you need.
- bzbarsky 9y agoYour claims are false for the majority of the world's population (which lives in non-English speaking countries and may well want to visit sites whose names make sense in their own language).
- eeZah7Ux 9y agoThat's why Firefox detects if the URL mixes together symbols from different languages: https://wiki.mozilla.org/IDN_Display_Algorithm https://wiki.mozilla.org/IDN_Display_Algorithm Much better than showing punycode all the time.
- kuschku 9y agoSo sites such as bücher.de (I originally had a link here to the site, but HN punycodes that: http://xn--bcher-kva.de/ http://xn--bcher-kva.de/ ) shouldn’t exist? That’s a very america-centric world, it’s like enforcing only US-ASCII on all websites. Most of the world doesn’t speak English, and browsers showing domains punycoded leads to mistrust, especially if it’s a legitimate retailer (the one mentioned above actually added a redirect to a romanized version of the URL due to that)
- dredmorbius 9y agoUseful. Neither ideal nor necessary, though. A full source reputation, authentication, and integrity capability strikes me as far more useful.
- radarsat1 9y agoF11?
- ZenoArrow 9y agoF11 is full screen, not headless. Headless means you can't see the browser or the website content, it's built for scripting purposes (automated web testing and web scraping). The only time you can see the content is if your script requests a screen capture.
- radarsat1 9y agoI know what headless means, but if fairpx is really referring to headless (he seems to have changed his post) then I have no idea what this means: > where the UI appears when you need it, intuitively, even when NOT in full screen or how it relates to a headless browser.
- radarsat1 9y agoReplying to myself.. ok the poster was confused between headless and chromeless (by which he really meant full screen), that explains it.. sorry.
- terminalcommand 9y agoI used to achieve this by using a tiling window manager (i3). In i3, if you run firefox normally it opens up in a pane, if you choose full screen (f11) inside firefox, it fills up the entire pane. In the other panes you can still keep your other windows, such as emacs, file browser, terminal etc.
- altotrees 9y agoSounds like a great idea. My skills aren't quite up to UI design collaboration standards but I guess I am curious as to how you would build and implement such a browser?
- maggit 9y agoA small nomenclature clarification seems to be in order: "Headless" means without output. It is often used to describe servers without any attached monitors (the monitor would be the head that it is missing), but can similarly be used to describe browsers that do not even create a window on your desktop. It simply runs as a service that can be scripted. What you are looking for, I would rather call "chromeless". The browser is there, but it has no visible UI-components outside of the webpage.
- privong 9y ago> What you are looking for, I would rather call "chromeless". The browser is there, but it has no visible UI-components outside of the webpage. Why "chromless" and not just "Full screen"? The latter is what that mode has been known by for decades? Or is it a subtle distinction that "Full screen" mode can show the location bar by moving the mouse to that edge of the screen (at least in Firefox 55), while "chromless" never lets you see the location bar?
- maggit 9y agoThose are two orthogonal concerns. A (theoretical) browser in full screen mode might or might not display UI elements/browser chrome. A windowed browser might or might not display browser chrome. A chromeless windowed browser would look something like QuickTime in macOS, if that helps you; the window consists entirely of the playing video until you mouse over it.
- vog 9y agoIf you want this, just press F11 on firefox. Or select from the menu: View / Full Screen. But this has nothing to do with a headless browser.
- skrebbel 9y agoThat's not headless, it's chromeless. Anyway, IE11 on Windows 8 (tablet mode) had that, and it was amazing (assuming you used the touch screen, that is - the UX wasn't so fantastic with a mouse). It's the only thing from Windows 8 I miss in Windows 10.
- lioeters 9y agoGranted, this is not the "headless" they're talking about, but rather "chrome-less" (chrome being the browser UI frame around the page itself).. JavaScript Fullscreen API: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_... Cross-browser polyfill: https://github.com/sindresorhus/screenfull.js https://github.com/sindresorhus/screenfull.js
- cageface 9y agoI really hate this trend in UI design. I have to scroll back half way up the page in iOS Safari to get the menu bar to display again, for example. I've watched a lot of non-technical users struggle to figure out what magic they have to perform to get an app's controls to even appear. Your job is to make things usable & functional, not pretty.
- dredmorbius 9y agoI'm working on some thoughts in a related, if not entirely similar, vein: https://www.reddit.com/r/dredmorbius/comments/6bgowu/what_if_the_web_was_filesystemaccessible/ https://www.reddit.com/r/dredmorbius/comments/6bgowu/what_if...
- bryanrasmussen 9y agosince you're setting the environment variable to be headless what happens if you're browsing with Firefox while running your automated process?
- watwut 9y agoSet the environment variable to tests only.
- traverseda 9y agoYou don't need to set all your environment variables in your bashrc, if that's not obvious. They're not global state. You can change them on a per-terminal basis, and that only effects the environment of that one terminal. Firefox does some weird stuff with multiprocessing, where if you run the firefox command twice you only get one process. I don't know how that would effect things, but I imagine just setting the env variable and running as a different firefox profile would do it. There's always firejail/firewarden, if you need a quick and easy sandbox for a program you already have installed, and that will solve that problem, if it is a problem.
- Vinnl 9y agoAdditionally, it's also possible to turn it on using the CLI flag `--headless`, if setting env vars is a concern.
- Vinnl 9y agoOh, and additionally: passing options with a double dash doesn't work on Windows, so use `-headless` to be sure.
- bryanrasmussen 9y agoD'oh of course.
- Derbasti 9y agoCan you tell Firefox to print in headless mode? I want to write reports using HTML and JS, but printing is always an issue.
- randlet 9y agoYou 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-chrome#create_a_pdf_dom https://developers.google.com/web/updates/2017/04/headless-c...
- bartread 9y agoWow - thanks for posting that: could come in handy on the project I'm currently working on!
- newhere420 9y agoWe'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.
- reagan83 9y agoCan you elaborate on some of the issues you're having in the Chrome Remote Interface?
- perryprog 9y agoIs this open source? It would be very interesting to take a look at!
- bartread 9y agoYeah, D3 is what we're working with as well; also need to be able to embed the charts in Powerpoint, but that'll be a different story. All fun and games.
- deleted 9y ago[deleted]
- wslh 9y agoWith Chrome and Firefox finally adding a headless mode, could I replace Lynx for Chrome or Firefox?
- jamespo 9y agoAre you expecting chrome/ff to render in text on the console?
- deleted 9y ago[deleted]
- majewsky 9y agoNo, that's two different concerns. Headless Chrome/Firefox render the website into a framebuffer in memory (instead of on the screen), but websites still look the same. You can extract an image file from this framebuffer and it will look as if the browser had been running in normal GUI mode. Lynx on the other hand renders onto a text terminal, which is a completely different output device compared to a pixel-based framebuffer.
- skrebbel 9y agoThis is very nice. What's the recommended way to run end-to-end tests in headless firefox _and_ headless chrome? Can't wait for a cross-platform headless Edge :-)
- thejosh 9y agoI'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.
- dsun180 9y agoI switched from selenium to testcafe a few weeks ago. It's such a great tool. I would never go back.
- hugs 9y agoWhat do you like better with testcafe?
- TheAceOfHearts 9y agoWriting 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 don't think there's any value to running all your tests on the browser. It's much faster and simpler to run the bulk of your tests on node, with a fake DOM environment. If you're interacting directly with the DOM, you might want to consider breaking that off as a separate lib. From the lib's repo you can have all of its tests run on a real browser.
- gedrap 9y agoTotally 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.
- royka118 9y agoFor all of you old fogies working on angular 1 apps and are running browser tests with karma you can run your tests in firefox with headless mode with a customer launcher. Add the snippet below to your karma conf ``` browsers: ['FirefoxHeadless'], customLaunchers: { FirefoxHeadless: { base: 'Firefox', flags: [ '-headless', ], }, }, ``` Note you need to be running the beta version of firefox, I needed to download it from here https://www.mozilla.org/en-US/firefox/channel/desktop/ https://www.mozilla.org/en-US/firefox/channel/desktop/
- MuffinFlavored 9y agoDoes this offer any real benefit over Xvfb?
- royka118 9y agoWell currently we run the karma tests on CI with chrome headless so this allows us to do the same with firefox
- pcx 9y agoWe 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.
- xexers 9y agoDoes anyone have any metrics on headless vs headed browser testing? Can you say headless is 25% faster and 20% more reliable? What is the sales pitch for headless browsers for UI automation?
- Sammi 9y agoDon't know about performance numbers, but one reason for headless browsers is so that you can run your tests on cheap small headless Linux servers.
- sacheendra 9y agoAdding to ^. You don't need to have the Xorg stuff running to run tests.
- Wilya 9y agoThat'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.
- Vinnl 9y agoDoesn't xvfb still just run an Xserver, simply without painting? Or do headless Chrome and Firefox still require an X server running too?
- Wilya 9y agoYou'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.
- jacobsenscott 9y agoI don't have numbers handy, but I didn't notice any significant performance difference between headless and headed chrome. I think the main benefit of headless is ease of test server setup. We use a CI service, so that's not a factor. We are sticking with phantomjs for now because it is significantly faster than chrome for our tests.
- justinph 9y agoAnyone know if you can run flash in headless mode?
- codewithcheese 9y agoDoes anyone know if there is a way to control the window size? If there is does it also modify screen.availHeight properties and other give aways that you have modified the window size.
- jopsen 9y agoLooks like it's controlled through webdriver.. I'm guessing you can lookup the webdriver spec to see what you can do...
- coolio222 9y agoCan you download files in headless Firefox or Chrome?
- deleted 9y ago[deleted]
- eptgrant 9y agoNot with Chrome at the moment. https://bugs.chromium.org/p/chromium/issues/detail?id=696481 https://bugs.chromium.org/p/chromium/issues/detail?id=696481 Soon. In the interim I've been using standard C# web requests and using the cookies from the ChromeDriver. Doesn't work for downloads where it is not a direct link unfortunately.
- heipei 9y agoNow if only Firefox also implemented the Chrome Remote Debugging Protocol... https://chromedevtools.github.io/debugger-protocol-viewer/tot/ https://chromedevtools.github.io/debugger-protocol-viewer/to...
- jxn 9y agoFirefox does have their own, documented and seemingly stable remote debugging protocol. I haven't used it recently, but there is the Valence project (https://github.com/mozilla/valence https://github.com/mozilla/valence) which provides adapters for their debugging tools for other protocols, namely Chrome's remote debugger. In the past, I have used this to debug Chrome with firefox's devtools. Maybe it works for your needs?
- auchenberg 9y agoMozilla DevTools is exploring implementing parts of the Chrome DevTools Protocol ("CDP") in Firefox. https://groups.google.com/forum/#!topic/mozilla.dev.platform/4-4A8W-nP5g https://groups.google.com/forum/#!topic/mozilla.dev.platform...
- minademian 9y agowelcome development. apparent that Firefox is paying attention what's happening in JS world...
- bligh____ 9y agoIt would be cool if mozilla and google would standatalize the headless API and command line flags as llvm and gcc has done, so you would perform headless cross browser testing.
- cat199 9y agoFWIW, the most common cc command line flags on unix share a common lineage back to AT&T PCC compiler. Which is not to say there is not common effort between the projects you mention now.
- XCSme 9y agoSo something like Webdriver.io ?
- jacalata 9y agoLike that, but with documentation.
- shados 9y agoand that actually works. Using headless chrome with the direct API is so much more reliable than the selenium API.
- Lightbody 9y agoThe onus of who actually automates the browser is moving from Selenium (the open source project) to the browser vendors. This will help with reliability and is also exactly what you're asking for: https://www.w3.org/TR/webdriver/ https://www.w3.org/TR/webdriver/
- shados 9y agoRight. That will be nice when it's done and stable (I'm looking at you, Safari), but for my tests today that doesn't really help me.
- beamatronic 9y agoCould you use this to write the best screen scraper? One you could run locally and trust to obtain sensitive data?
- vosper 9y agoI think so, and the same can probably be accomplished with headless Chrome.
- tree_of_item 9y agoPerhaps 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.
- Manishearth 9y agoNo, this has been in the works for a while https://bugzilla.mozilla.org/show_bug.cgi?id=1338004 https://bugzilla.mozilla.org/show_bug.cgi?id=1338004 So not in reaction to Chrome. In fact, the first attempt for this was almost a decade ago (https://bugzilla.mozilla.org/show_bug.cgi?id=446591 https://bugzilla.mozilla.org/show_bug.cgi?id=446591)
- tree_of_item 9y agoThanks for the info, that's good news.
- duck 9y agoOr you could look at as really bad news if it takes a decade to implement this.
- Manishearth 9y agoI mean, Selenium has worked for Firefox for years so it's not like this was a priority. It's a decade to decide this is worth doing, which is reasonable given that there's also a "good enough" solution out there; Selenium.
- hugs 9y agoGood enough to be the W3C standard. https://www.w3.org/TR/webdriver/ https://www.w3.org/TR/webdriver/
- mathgenius 9y agoHas anyone built a WaaS yet ? (Web-browser as a service.)
- pbhjpbhj 9y agoLike browsershots?
- cptaj 9y agoCame in to say exactly this. The funny thing is that someone HAS created browser as a service XD
- deleted 9y ago[deleted]
- lotyrin 9y agoSauce Labs and BrowserStack have been in that space for quite a while now.
- hugs 9y ago2008 for Sauce Labs, to be precise. Before that, BrowserCam (founded in 2002, acquired by Gomez in 2007) was part of my inspiration for Sauce Labs. BrowserCam was one of the first screenshots-as-a-service sites. The only thing it was missing was Selenium support for end-to-end test automation. :-)
- protomikron 9y agoI think if done right there would be a market (if this is actually the right direction and useful is another question). wbaas.io "web browser as a service" Support like say the 5 major browsers (Firefox, Chrome, Safari, ...), provide an API and charge like ~xx euro/month. The biggest challenge is probably to make it secure as one builds in essence a DOS proxy?
- hugs 9y agoThere totally is a market for it. Sauce Labs makes $25MM/year doing it. One way to secure the service is by using pristine virtual machines for each session and discarding them afterwards.
- deleted 9y ago[deleted]
- nkkollaw 9y agoCan someone do an ELI5 on why headless browsers are useful? I've use them before to make screenshots of webpages, and I have noticed that many NPM packages come (or came) with PhantomJS as a dependency, but I have no idea why one would need that.
- cbhl 9y agoAutomated integration/regression tests is a pretty big use case. You spin up a copy of your server, point the headless browser at it, run some JavaScript to simulate some user interactions, and verify the page contains the right strings / screenshot doesn't deviate too much from a golden image. I guess the ELI5 way of saying that would be: "Making sure your website still works." People also headless browsers for content generation inside larger systems. (I saw one team make videos by creating CSS animations, and then capturing screenshots from the headless browser at 30 fps.)
- nkkollaw 9y agoGot it. Thanks!
- tyingq 9y agoScraping for data is another big use case. Like a price comparison web site. Or the company LinkedIn is unhappy about because they are scraping profile data.
- nashashmi 9y agoSo an ELI5 of everything you said would be: Putting the website through user actions in a firefox browser and recording/capturing/documenting the results headlessly. Headless version allows you to go through hundreds of results in the background.
- cbhl 9y agoMaybe. I got stuck trying to imagine whether a five-year-old would understand what "headless" means in a software context (as opposed to, "headless dragon" or something).
- barbolo 9y agoWhich way to go: Chrome headless, Firefox headless or both?
- ZenoArrow 9y agoBoth. Ideally, you shouldn't run website tests on a single browser. We shouldn't want to return to the days where websites only worked well on a single browser.
- Vinnl 9y agoExactly. I already think it's a shame that I can only run Firefox and Chrome in Docker (i.e. CI), but I hope that their differences will compensate enough to cover most potential problems in Edge and Safari.
- jhasse 9y agoFirefox headless. Chrome is steering towards a monopoly, which most of the time doesn't end well.
- computerwizard 9y agoI wonder if this will work with the iMacros addon?
- camoby 9y agoWhile I think solutions like this are useful in some situations, I wonder how much non-human traffic and spam they might end up being responsible for.
- fake-name 9y agoDoes it require X to be installed? If so, it's not headless.
- mykmelez 9y agoIt does require X to be installed, although it doesn't actually use X, and the X implementation can just be Xvfb. Unfortunately, fixing that is hard. I think Chrome has the same limitation. For Firefox, the issue is tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=1372998 https://bugzilla.mozilla.org/show_bug.cgi?id=1372998.
- deleted 9y ago[deleted]
- kyledrake 9y agoIt would be really nice to see see GPU / WebGL support here!
- makecheck 9y agoTools like headless browsers might turn into the "perl" of this generation. :) Years ago I could always find a way to make Perl do whatever I wanted. It was usually "wrong" to fire up an entire interpreter compared to using faster, less flexible tools but it got the job done. Now I imagine people thinking, "the browser will do this", especially if they can grab screenshots or other local data files.
- nicklaf 9y agoThe article mentions screenshots. I am interested in running the browser as a rendering tool, but ouputing not just a bitmap, but something closer to PDF. The goal here would be to crawl a bunch of pages and spin up the CPU to run all the needed JavaScript to render things, but to obtain an identical version of the page that runs about as fast viewing a screenshot, but also includes text. An offline "web OCR", if you will. NeWS, Display PostScript, Quartz all come to mind. I know you can save webpages as PDF documents, but I am thinking of something that is like PDF but closer to HTML-just more closely coupled to what is being displayed, and not whatever arbitrary style or JavaScript abuse the developer decided on. Even just outputing some neat, canonical HTML based on the state of the page once everything is loaded would be helpful, so that the bitmap could later be combined in some kind of new document format.
- richdougherty 9y agoI'm pretty sure you could write some WebDriver + JavaScript that captures the DOM/text in the page. You might even be able to capture layout information for later reconstruction.
- nicklaf 9y agoThat's useful to know, thank you. Perhaps the solution isn't so complicated.
- kuschku 9y agoWhat you want is SVG. You want an SVG output of the actual, full, page. With text embedded in SVG properly, of course.
- nicklaf 9y agoThat is actually exactly what I want (why didn't I think of it...)! Thank you. In fact, wkhtmltoimage supports svg and does a great job of rendering, say, GitHub or techmeme. It falls over on formatting mathoverflow.net, but I think the same technique could be changed a bit to more closely resemble what actually gets layed out on the page in a running browser instance.
- fenesiistvan 9y agoWhat about the "app" mode? Chrome have introduced the --app command line switch long time ago and similar functionality would be very useful also in Firefox. I suppose that implementation would be also very easy, i don't understand why there is still no such functionality in Firefox.