From b6321b9acf119c37d309c4e5890a82e6035c9fa8 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Tue, 2 Jan 2018 12:27:14 -0800 Subject: [PATCH] Add Chrome Headless browser. (#4) --- CHANGELOG.md | 1 + package-lock.json | 2 +- package.json | 2 +- src/browser-capabilities.ts | 22 ++++++++++------------ src/test/browser-capabilities_test.ts | 6 ++++++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce4612669..556bec76b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/package-lock.json b/package-lock.json index d6b8cf8df..d2a00c8c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "browser-capabilities", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7b6f1056d..2bdcf5b92 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,6 @@ }, "dependencies": { "@types/ua-parser-js": "^0.7.31", - "ua-parser-js": "^0.7.14" + "ua-parser-js": "^0.7.15" } } diff --git a/src/browser-capabilities.ts b/src/browser-capabilities.ts index 737e95042..6deb2ef35 100644 --- a/src/browser-capabilities.ts +++ b/src/browser-capabilities.ts @@ -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), diff --git a/src/test/browser-capabilities_test.ts b/src/test/browser-capabilities_test.ts index 0e1f0b75c..e16887041 100644 --- a/src/test/browser-capabilities_test.ts +++ b/src/test/browser-capabilities_test.ts @@ -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',