Skip to content

Commit

Permalink
fix(server): detection new MS Edge Chromium
Browse files Browse the repository at this point in the history
BREAKING CHANGES - Browser and OS name generation are changed
swich on new lib ua-parser-js to have a good detection of MS Edge Chromium
  • Loading branch information
anthony-redFox committed Mar 5, 2020
1 parent a673aa8 commit 24c1218
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 73 deletions.
10 changes: 6 additions & 4 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
const fs = require('graceful-fs')
const path = require('path')
const _ = require('lodash')
const useragent = require('useragent')
const useragent = require('ua-parser-js')
const Promise = require('bluebird')
const mm = require('minimatch')

exports.browserFullNameToShort = (fullName) => {
const agent = useragent.parse(fullName)
const isUnknown = agent.family === 'Other' || agent.os.family === 'Other'
return isUnknown ? fullName : `${agent.toAgent()} (${agent.os})`
const au = useragent(fullName)
if (!au.browser.name && !au.browser.version && !au.os.name && !au.os.version) {
return 'NonexistentBot/1.2.3'
}
return `${au.browser.name} ${au.browser.version || '0.0.0'} (${au.os.name} ${au.os.version || '0.0.0'})`
}

exports.isDefined = (value) => {
Expand Down
35 changes: 5 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
"socket.io": "2.1.1",
"source-map": "^0.6.1",
"tmp": "0.0.33",
"useragent": "2.3.0"
"ua-parser-js": "0.7.21"
},
"devDependencies": {
"browserify": "^16.2.3",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Basic Testrunner
Then it passes with:
"""
..
HeadlessChrome
Chrome Headless
"""
@not-jenkins
Scenario: Execute a test in Chrome
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/browser_console.feature
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Feature: Browser Console Configuration
When I start Karma
Then the file at test/e2e/console.log contains:
"""
HeadlessChrome
Chrome Headless
"""

Scenario: Execute logging program and disabling terminal
Expand All @@ -150,7 +150,7 @@ Feature: Browser Console Configuration
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: Execute logging program and disabling terminal
Expand All @@ -170,7 +170,7 @@ Feature: Browser Console Configuration
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""
Scenario: Execute logging program with singleRun
Given a configuration with:
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/custom-context.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Feature: Custom Context File
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""
14 changes: 7 additions & 7 deletions test/e2e/files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Including files
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: Execute a test excluding an explicitly included file
Expand All @@ -41,7 +41,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
Expand All @@ -66,7 +66,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
Expand All @@ -91,7 +91,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
Expand All @@ -116,7 +116,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
Expand All @@ -141,7 +141,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
Expand All @@ -167,7 +167,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/headers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Feature: Custom Headers
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""
4 changes: 2 additions & 2 deletions test/e2e/middleware.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Middleware
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: Frameworks can add middleware
Expand All @@ -40,5 +40,5 @@ Feature: Middleware
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""
6 changes: 3 additions & 3 deletions test/e2e/proxy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Proxying
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: Added by a framework
Expand All @@ -39,7 +39,7 @@ Feature: Proxying
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: URLRoot
Expand All @@ -60,5 +60,5 @@ Feature: Proxying
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""
2 changes: 1 addition & 1 deletion test/e2e/reconnecting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Feature: Passing Options
Then it passes with:
"""
.....
HeadlessChrome
Chrome Headless
"""
2 changes: 1 addition & 1 deletion test/e2e/runInParent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: runInParent option
Then it passes with:
"""
..
HeadlessChrome
Chrome Headless
"""
@not-jenkins
Scenario: Execute a test in Chrome
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/upstream-proxy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Feature: UpstreamProxy
When I start Karma behind a proxy on port 9875 that prepends '/__proxy__/' to the base path
Then it passes with regexp:
"""
HeadlessChrome.*Executed.*SUCCESS
Chrome Headless.*Executed.*SUCCESS
"""
4 changes: 2 additions & 2 deletions test/unit/browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Browser', () => {
it('should set fullName and name', () => {
const fullName = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 ' + '(KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7'
browser = new Browser('id', fullName, collection, emitter, socket)
expect(browser.name).to.equal('Chrome 16.0.912 (Mac OS X 10.6.8)')
expect(browser.name).to.equal('Chrome 16.0.912.63 (Mac OS 10.6.8)')
expect(browser.fullName).to.equal(fullName)
})

Expand Down Expand Up @@ -66,7 +66,7 @@ describe('Browser', () => {
it('should return browser name', () => {
const fullName = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 ' + '(KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7'
browser = new Browser('id', fullName, collection, emitter, socket)
expect(browser.toString()).to.equal('Chrome 16.0.912 (Mac OS X 10.6.8)')
expect(browser.toString()).to.equal('Chrome 16.0.912.63 (Mac OS 10.6.8)')
})

it('should return verbatim user agent string for unrecognized browser', () => {
Expand Down
Loading

0 comments on commit 24c1218

Please sign in to comment.