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

fix(server): detection new MS Edge Chromium #3440

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/helper.js
Original file line number Diff line number Diff line change
@@ -3,13 +3,15 @@
const fs = require('graceful-fs')
const path = require('path')
const _ = require('lodash')
const useragent = require('useragent')
const useragent = require('ua-parser-js')
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 ua = useragent(fullName)
if (!ua.browser.name && !ua.browser.version && !ua.os.name && !ua.os.version) {
return fullName
}
return `${ua.browser.name} ${ua.browser.version || '0.0.0'} (${ua.os.name} ${ua.os.version || '0.0.0'})`
}

exports.isDefined = (value) => {
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
@@ -413,7 +413,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",
2 changes: 1 addition & 1 deletion test/e2e/basic.feature
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ Feature: Basic Testrunner
Then it passes with:
"""
..
HeadlessChrome
Chrome Headless
"""
@not-jenkins
Scenario: Execute a test in Chrome
6 changes: 3 additions & 3 deletions test/e2e/browser_console.feature
Original file line number Diff line number Diff line change
@@ -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
@@ -150,7 +150,7 @@ Feature: Browser Console Configuration
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: Execute logging program and disabling terminal
@@ -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:
2 changes: 1 addition & 1 deletion test/e2e/custom-context.feature
Original file line number Diff line number Diff line change
@@ -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
@@ -20,7 +20,7 @@ Feature: Including files
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: Execute a test excluding an explicitly included file
@@ -41,7 +41,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
@@ -66,7 +66,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
@@ -91,7 +91,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
@@ -116,7 +116,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
@@ -141,7 +141,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
@@ -167,7 +167,7 @@ Feature: Including files
Then it passes with like:
"""
.
HeadlessChrome
Chrome Headless
"""
And it passes with like:
"""
2 changes: 1 addition & 1 deletion test/e2e/headers.feature
Original file line number Diff line number Diff line change
@@ -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
@@ -21,7 +21,7 @@ Feature: Middleware
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

Scenario: Frameworks can add middleware
@@ -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
@@ -20,7 +20,7 @@ Feature: Proxying
Then it passes with:
"""
.
HeadlessChrome
Chrome Headless
"""

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

Scenario: URLRoot
@@ -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
@@ -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
@@ -21,7 +21,7 @@ Feature: runInParent option
Then it passes with:
"""
..
HeadlessChrome
Chrome Headless
"""
@not-jenkins
Scenario: Execute a test in Chrome
2 changes: 1 addition & 1 deletion test/e2e/upstream-proxy.feature
Original file line number Diff line number Diff line change
@@ -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
@@ -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)
})

@@ -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', () => {
38 changes: 23 additions & 15 deletions test/unit/helper.spec.js
Original file line number Diff line number Diff line change
@@ -14,100 +14,100 @@ describe('helper', () => {
'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 ' +
'(KHTML, like Gecko) Version/6.0 Mobile/10A403 Safari/8536.25'
)
.to.be.equal('Mobile Safari 6.0.0 (iOS 6.0.0)')
.to.be.equal('Mobile Safari 6.0 (iOS 6.0)')
})

it('should parse Linux', () => {
expecting(
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19) Gecko/20081216 ' +
'Ubuntu/8.04 (hardy) Firefox/2.0.0.19'
)
.to.be.equal('Firefox 2.0.0 (Ubuntu 8.04.0)')
.to.be.equal('Firefox 2.0.0.19 (Ubuntu 8.04)')
})

it('should degrade gracefully when OS not recognized', () => {
expecting(
'Mozilla/5.0 (X11; U; FreeBSD; i386; en-US; rv:1.7) Gecko/20081216 ' +
'Firefox/2.0.0.19'
).to.be.equal('Firefox 2.0.0 (FreeBSD 0.0.0)')
).to.be.equal('Firefox 2.0.0.19 (FreeBSD 0.0.0)')
})

it('should parse Chrome', () => {
expecting(
'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'
)
.to.be.equal('Chrome 16.0.912 (Mac OS X 10.6.8)')
.to.be.equal('Chrome 16.0.912.63 (Mac OS 10.6.8)')

expecting(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.15 ' +
'(KHTML, like Gecko) Chrome/18.0.985.0 Safari/535.15'
)
.to.be.equal('Chrome 18.0.985 (Mac OS X 10.6.8)')
.to.be.equal('Chrome 18.0.985.0 (Mac OS 10.6.8)')
})

it('should parse Firefox', () => {
expecting(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 ' +
'Firefox/7.0.1'
)
.to.be.equal('Firefox 7.0.1 (Mac OS X 10.6.0)')
.to.be.equal('Firefox 7.0.1 (Mac OS 10.6)')
})

it('should parse Opera', () => {
expecting(
'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.9.168 ' +
'Version/11.52'
)
.to.be.equal('Opera 11.52.0 (Mac OS X 10.6.8)')
.to.be.equal('Opera 11.52 (Mac OS 10.6.8)')
})

it('should parse Safari', () => {
expecting(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.52.7 ' +
'(KHTML, like Gecko) Version/5.1.2 Safari/534.52.7'
)
.to.be.equal('Safari 5.1.2 (Mac OS X 10.6.8)')
.to.be.equal('Safari 5.1.2 (Mac OS 10.6.8)')
})

it('should parse IE7', () => {
expecting(
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; ' +
'.NET CLR 2.0.50727; .NET4.0C; .NET4.0E)'
)
.to.be.equal('IE 7.0.0 (Windows Vista.0.0)')
.to.be.equal('IE 7.0 (Windows Vista)')
})

it('should parse IE8', () => {
expecting(
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; ' +
'SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3)"'
)
.to.be.equal('IE 8.0.0 (Windows 7.0.0)')
.to.be.equal('IE 8.0 (Windows 7)')
})

it('should parse IE9', () => {
expecting(
'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; ' +
'.NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'
)
.to.be.equal('IE 9.0.0 (Windows 7.0.0)')
.to.be.equal('IE 9.0 (Windows 7)')
})

it('should parse IE10', () => {
expecting(
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; ' +
'.NET4.0E; .NET4.0C)'
)
.to.be.equal('IE 10.0.0 (Windows 8.0.0)')
.to.be.equal('IE 10.0 (Windows 8)')
})

it('should parse PhantomJS', () => {
expecting(
'Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) ' +
'PhantomJS/1.6.0 Safari/534.34'
)
.to.be.equal('PhantomJS 1.6.0 (Mac OS X 0.0.0)')
.to.be.equal('PhantomJS 1.6.0 (Mac OS 0.0.0)')
})

// Fix for #318
@@ -116,15 +116,23 @@ describe('helper', () => {
'Mozilla/5.0 (Linux; U; Android 4.2; en-us; sdk Build/JB_MR1) ' +
'AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
)
.to.be.equal('Android 4.2.0 (Android 4.2.0)')
.to.be.equal('Android Browser 4.0 (Android 4.2)')
})

it('should parse Headless Chrome', () => {
expecting(
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) ' +
'HeadlessChrome/70.0.3538.77 Safari/537.36'
)
.to.be.equal('HeadlessChrome 70.0.3538 (Linux 0.0.0)')
.to.be.equal('Chrome Headless 70.0.3538.77 (Linux x86_64)')
})

it('should parse MS Edge Chromium', () => {
expecting(
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' +
'Chrome/80.0.3987.132 Safari/537.36 Edg/80.0.361.66'
)
.to.be.equal('Edge 80.0.361.66 (Windows 10)')
})
})