Karma: Headless Chrome instances is reported as Safari 0.0.0

Created on 14 Mar 2017  路  9Comments  路  Source: karma-runner/karma

Most of this was copied from https://github.com/karma-runner/karma-chrome-launcher/issues/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.

bug-upstream

Most helpful comment

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

All 9 comments

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.

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

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?

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

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

@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.

@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

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

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)

Was this page helpful?
0 / 5 - 0 ratings