Skip to content

Commit

Permalink
Add Chrome Headless browser. (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
aomarks authored Jan 2, 2018
1 parent c09c3c4 commit b6321b9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change Log

## [Unreleased]
- Add Chrome Headless browser.

## [0.2.1] - 2017-10-18
- Remove Firefox from set of browsers with push capability due to https://bugzilla.mozilla.org/show_bug.cgi?id=1409570.
Expand Down
2 changes: 1 addition & 1 deletion 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 @@ -29,6 +29,6 @@
},
"dependencies": {
"@types/ua-parser-js": "^0.7.31",
"ua-parser-js": "^0.7.14"
"ua-parser-js": "^0.7.15"
}
}
22 changes: 10 additions & 12 deletions src/browser-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ export type BrowserCapability =
// class can't be referenced as a type. Fix the typings.
export type UserAgentPredicate = (ua: any) => boolean;

const chrome = {
es2015: since(49),
push: since(41),
serviceworker: since(45),
modules: since(61),
};

const browserPredicates: {
[browser: string]: {[key in BrowserCapability]: UserAgentPredicate}
} = {
'Chrome': {
es2015: since(49),
push: since(41),
serviceworker: since(45),
modules: since(61),
},
'Chromium': {
es2015: since(49),
push: since(41),
serviceworker: since(45),
modules: since(61),
},
'Chrome': chrome,
'Chromium': chrome,
'Chrome Headless': chrome,
'OPR': {
es2015: since(36),
push: since(28),
Expand Down
6 changes: 6 additions & 0 deletions src/test/browser-capabilities_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ suite('capabilities', function() {
['es2015', 'push', 'serviceworker', 'modules']);
});

test('chrome headless has all the capabilities', () => {
assertBrowserCapabilities(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/61.0.3163.31 Safari/537.36',
['es2015', 'push', 'serviceworker', 'modules']);
});

test('edge es2015 support is predicated on minor browser version', () => {
assertBrowserCapabilities(
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.14986',
Expand Down

0 comments on commit b6321b9

Please sign in to comment.