Skip to content

Commit 34d0805

Browse files
Chris Lorenzoomnibs
Chris Lorenzo
authored andcommitted
Fix bestiejs#132 - Add Chrome Headless detection
Add Chrome Headless support as Chrome browser to keep it simple for others to see as Chrome per Issue bestiejs#127.
1 parent 815f51e commit 34d0805

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.
6868

6969
## Support
7070

71-
Tested in Chrome 62-63, Firefox 56-57, IE 11, Edge 15-16, Safari 10-11, Node.js 4-8, & PhantomJS 2.1.1.
71+
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.
7272

7373
## BestieJS
7474

platform.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@
392392
'Opera',
393393
{ 'label': 'Opera', 'pattern': 'OPR' },
394394
'Chrome',
395+
{ 'label': 'Chrome', 'pattern': '(?:HeadlessChrome)' },
395396
{ 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
396397
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
397398
{ 'label': 'Firefox for iOS', 'pattern': 'FxiOS' },
@@ -697,6 +698,7 @@
697698
version = getVersion([
698699
'(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))',
699700
'Version',
701+
'HeadlessChrome',
700702
qualify(name),
701703
'(?:Firefox|Minefield|NetFront)'
702704
]);
@@ -919,7 +921,7 @@
919921
version = null;
920922
}
921923
// Use the full Chrome version when available.
922-
data[1] = (/\bChrome\/([\d.]+)/i.exec(ua) || 0)[1];
924+
data[1] = (/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(ua) || 0)[1];
923925
// Detect Blink layout engine.
924926
if (data[0] == 537.36 && data[2] == 537.36 && parseFloat(data[1]) >= 28 && layout == 'WebKit') {
925927
layout = ['Blink'];

test/test.js

+16
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,22 @@
569569
'version': '54.0.2840.71'
570570
},
571571

572+
'Chrome 63.0.3239.132 on OS X 10.11.6 64-bit': {
573+
'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',
574+
'layout': 'Blink',
575+
'name': 'Chrome',
576+
'os': 'OS X 10.11.6 64-bit',
577+
'version': '63.0.3239.132'
578+
},
579+
580+
'Chrome 63.0.3239.132 on Linux 64-bit': {
581+
'ua': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/63.0.3239.132 Safari/537.36',
582+
'layout': 'Blink',
583+
'name': 'Chrome',
584+
'os': 'Linux 64-bit',
585+
'version': '63.0.3239.132'
586+
},
587+
572588
'Chrome Mobile 16.0.912.77 on HTC (Android 4.0.3)': {
573589
'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',
574590
'layout': 'WebKit',

0 commit comments

Comments
 (0)