Skip to content

Commit

Permalink
Fix bestiejs#132 - Add Chrome Headless detection
Browse files Browse the repository at this point in the history
Add Chrome Headless support as Chrome browser to keep it simple
for others to see as Chrome per Issue bestiejs#127.
  • Loading branch information
Chris Lorenzo authored and omnibs committed Jul 16, 2018
1 parent 815f51e commit 34d0805
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.

## Support

Tested in Chrome 62-63, Firefox 56-57, IE 11, Edge 15-16, Safari 10-11, Node.js 4-8, & PhantomJS 2.1.1.
Tested in Chrome 62-63, Chrome Headless 63, Firefox 56-57, IE 11, Edge 15-16, Safari 10-11, Node.js 4-8, & PhantomJS 2.1.1.

## BestieJS

Expand Down
4 changes: 3 additions & 1 deletion platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@
'Opera',
{ 'label': 'Opera', 'pattern': 'OPR' },
'Chrome',
{ 'label': 'Chrome', 'pattern': '(?:HeadlessChrome)' },
{ 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
{ 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
Expand Down Expand Up @@ -697,6 +698,7 @@
version = getVersion([
'(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))',
'Version',
'HeadlessChrome',
qualify(name),
'(?:Firefox|Minefield|NetFront)'
]);
Expand Down Expand Up @@ -919,7 +921,7 @@
version = null;
}
// Use the full Chrome version when available.
data[1] = (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1];
data[1] = (/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(ua) || 0)[1];
// Detect Blink layout engine.
if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
layout = ['Blink'];
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,22 @@
'version': '54.0.2840.71'
},

'Chrome 63.0.3239.132 on OS X 10.11.6 64-bit': {
'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/63.0.3239.132 Safari/537.36',
'layout': 'Blink',
'name': 'Chrome',
'os': 'OS X 10.11.6 64-bit',
'version': '63.0.3239.132'
},

'Chrome 63.0.3239.132 on Linux 64-bit': {
'ua': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/63.0.3239.132 Safari/537.36',
'layout': 'Blink',
'name': 'Chrome',
'os': 'Linux 64-bit',
'version': '63.0.3239.132'
},

'Chrome Mobile 16.0.912.77 on HTC (Android 4.0.3)': {
'ua': 'Mozilla/5.0 (Linux; U; Android 4.0.3; zh-cn; HTC Sensation XE with Beats Audio Build/IML74K) AppleWebKit/535.7 (KHTML, like Gecko) CrMo/16.0.912.77 Mobile Safari/535.7',
'layout': 'WebKit',
Expand Down

0 comments on commit 34d0805

Please sign in to comment.