window.chrome object not available in "headless" mode
See original GitHub issuePerhaps this is not the correct place for this (I’ve also filed this bug: https://bugs.chromium.org/p/chromium/issues/detail?id=806333 but I wasn’t sure where to dig in.
I’m finding that when I run my Nightwatch tests with Chrome in “headless” mode, that certain odd tests are failing consistently that pass when run “not in headless” mode. Upon digging in, it appears that the window.chrome
and/or chrome
objects are not available/present to webpages loaded in “headless” mode.
This is a problem for us because some of the things we test for are dependent on whether or not a User’s browser as window.chrome && window.chrome.webstore
, which should both be truthy in any version of Chrome, headless or not I would think.
Is this expected behavior? Anything that can be done?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (3 by maintainers)
Top GitHub Comments
@newhouse the absence of
window.chrome
is an implication of headless architecture.Chromium consists of layers:
A few things on this diagram are important:
content
layer is the API to build “browsers”. So if you’re building a browser, you’re embeddingcontent
.content
embedder. A lot of Chromium functionality, e.g. extensions andwindow.chrome
, lives in thechrome
layercontent
embedder. Since extensions are in thechrome
layer, they’re naturally missing in the headless browser.Hope this helps.
Look into how puppeteer does evaluateOnNewDocument: https://github.com/GoogleChrome/puppeteer/blob/master/lib/Page.js#L658