-
Notifications
You must be signed in to change notification settings - Fork 240
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
window.chrome object not available in "headless" mode #83
Comments
Let's use your crbug as the canonical issue for this. Headless is a slightly different embedder of Chromium content than Chrome/Chromium, and one difference is the window.chrome object. |
Thanks, @paulirish . Still "triaging" the issue over there. We'll see what happens. I'll update this issue with whatever happens over there. |
FWIW I don't expect it to be fixed anytime soon. Why do you rely on (cross-linking the related pptr issue: puppeteer/puppeteer#1026 ) |
Automated browser tests we are running check to see if an element reminding the User of our site’s chrome extension is being displayed or not. Our app displays that reminder element based on whether, among other things, the I would consider this use case legitimate and this behavior a “bug”. Currently I have to have our front end code mock it out when running headless chrome. Which is lame. |
There are no extensions in headless, so having a chrome.webstore property feels wrong. There are lots of ways for Blink to appear in the wild without Chrome. Mocking window.chrome might be lame, but it’s the same as what we would be doing to fix it on the browser side. |
i suppose the ultimate bug here is that chrome headless doesn't support extensions. people are requesting that, but it'll be some time before that happens (if it ever does). agree with joel that it doesn't make sense for i assume it's possible to use nightwatch with a headful chrome? if so, then do that for your extension-dependent tests. |
Thank you both for your responses. That comment was definitely not directed at this (or any other related project), but was certainly poorly phrased. Apologies if it came across as a dig. The fact that it took me basically 1 line of code to go from running headful to headless and have only 1 test fail is a pretty amazing testament to this project, Chromium, and others, for sure. I was surprised to find this question only asked a handful of times and, IMO, not thoroughly answered, so I started asking around. I'm even on the issue that was linked to this one by Paul. I think there are starting to be others like me that are discovering the ease of running headless Chrome with their testing frameworks, and eventually some of them will also encounter this issue. The fact that you guys are dropping knowledge about which lines of code in the Chromium build creates the As @paulirish explained earlier and stated more directly just above here, it seems to stem from how Chrome runs headless, and we'll have to wait and see what develops there. @paulirish Yes, I can definitely work around this in a manner like you suggested and I may just do that. Thanks! @JoelEinbinder Without it being added to DevTools explicitly (I agree that that feels wrong given what I now know), are there any hooks/configs/options where mocking Thanks again to you both |
Look into how puppeteer does evaluateOnNewDocument: https://github.com/GoogleChrome/puppeteer/blob/master/lib/Page.js#L658 |
Latest comment from Chromium team:
Given my naiveté on the underlying subject matter (why no extensions allowed in headless, etc) I'm afraid to touch this issue any more and seems like a "case closed" for me. If anyone here more suited would like to tack on any questions/comments to that issue, please be my guest! |
@newhouse the absence of Chromium consists of layers: A few things on this diagram are important:
Hope this helps. |
@aslushnikov very helpful, indeed. Thank you for providing that insight! |
Perhaps 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/orchrome
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?
The text was updated successfully, but these errors were encountered: