Skip to content
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

Headless Chrome instances is reported as Safari 0.0.0 #2603

Closed
remcohaszing opened this issue Mar 14, 2017 · 9 comments
Closed

Headless Chrome instances is reported as Safari 0.0.0 #2603

remcohaszing opened this issue Mar 14, 2017 · 9 comments

Comments

@remcohaszing
Copy link

Most of this was copied from karma-runner/karma-chrome-launcher#107

Expected behaviour

Google Chrome headless should be reported as Google Chrome.

Actual behaviour

When Google Chrome is configured to run in headless mode, Karma reports it as Safari 0.0.0.

Environment Details

  • Karma version (output of karma --version): Karma version: 1.5.0
  • Google Chrome version (output of google-chrome --version): Google Chrome 57.0.2987.98
  • Relevant part of your karma.config.js file
browsers: ['ChromeNoSandboxHeadless'],

customLaunchers: {
  ChromeNoSandboxHeadless: {
    base: 'Chrome',
    flags: [
      '--no-sandbox',
      // See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
      '--headless',
      '--disable-gpu',
      // Without a remote debugging port, Google Chrome exits immediately.
      ' --remote-debugging-port=9222',
    ],
  },
},

Steps to reproduce the behaviour

Just run Karma and view any output where the browser name and version are visible.

@madCoder24
Copy link

I am seeing the same thing, but I get additional output. That says "executed 0 out of 0 disconnected". I am not sure if this is because I am running Chrome headless or something other issue due to my Karma configuration.

@remcohaszing
Copy link
Author

@madCoder24 I think that's related to another part of your config. The above config works just fine for me.

@rogeriopvl
Copy link
Contributor

rogeriopvl commented Mar 14, 2017

Is chrome headless user agent different from normal chrome?

That could be the issue. Karma uses the useragent package, which in turn uses the uap-core package to identify UAs. Maybe that package needs to be updated to include the chrome headless UA string?

@remcohaszing
Copy link
Author

Yep, the user agent differs.

Regular Chrome:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36

Headless Chrome:

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36

rogeriopvl added a commit to rogeriopvl/uap-core that referenced this issue Mar 15, 2017
Although Headless Chrome is just a `--headless` flag for Chrome, the
user-agent is different, so we can treat it as a special browser.

This flag is only available on Linux for now, and the UA has no version
included.

Related with: karma-runner/karma#2603
@rogeriopvl
Copy link
Contributor

Thanks for checking the UA @remcohaszing. Pull request opened upstream to fix this: ua-parser/uap-core#228

@rogeriopvl
Copy link
Contributor

@remcohaszing the useragent package has now updated the regexps from uap-core (see here) in version 2.1.13, so we can close this, since a simple npm update should fix this issue.

@maksimr maksimr closed this as completed Mar 26, 2017
jsantiago pushed a commit to jsantiago/docker-karma that referenced this issue May 23, 2017
* correct call to build docker image

* Change nodejs server to current LTS release
replace PhantomJS with Chrome because PhantomJS is no longer maintained
https://groups.google.com/forum/\#!msg/phantomjs/9aI5d-LDuNE/MpCM_wACAQAJ

* switch to Chrome-Headless in karma config
inspired by: karma-runner/karma#2603

* add package.json ton install dependencies

* add package.json ton install dependencies

* Revert "add package.json ton install dependencies"

This reverts commit 4fdd89f.

* add missing package.json

* change PhantomJS to Chromium in README.md
@Licen-it
Copy link

@rogeriopvl This issue is back in version 3.0.0 of karma, but now it's detecting HeadlessChrome 0.0.0 instead of the real chrome version which should be 68

@rogeriopvl
Copy link
Contributor

@Licen-it thanks for reporting. Will have a look ASAP.

@Licen-it
Copy link

Oh FYI i also noticed it's not detecting Linux version (i was detecting my mac version, but running the tests with jenkins on linux it wasn't) HeadlessChrome 0.0.0 (Linux 0.0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants