-
Notifications
You must be signed in to change notification settings - Fork 1
/
capabilities.js
35 lines (32 loc) · 1.22 KB
/
capabilities.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
var browser = require('detect-browser').detect();
var compareVersions = require('compare-versions')
var capabilities = module.exports = {
moz: typeof navigator != 'undefined' && !!navigator.mozGetUserMedia,
browser: browser.name,
browserVersion: browser.version
};
// Mozilla constraings handling
if (capabilities.moz) {
capabilities.constraintsType = (compareVersions(browser.version, '38.0.0') >= 0 ? 'standard' : 'legacy');
}
// Chrome constraints handling
else if (browser.name === 'chrome') {
capabilities.constraintsType = (compareVersions(browser.version, '53.0.0') >= 0 ? 'standard' : 'legacy');
}
// Safari constraints handling
else if (browser.name === 'safari') {
capabilities.constraintsType = (compareVersions(browser.version, '12.0.0') >= 0 ? 'standard' : 'legacy');
}
// Edge constraints handling
else if ((/^edge.*$/).test(browser.name)) {
capabilities.constraintsType = (compareVersions(browser.version, '79.0.0') >= 0 ? 'standard' : 'legacy');
}
// iOS Safari constraints handling
else if (browser.name === 'ios') {
capabilities.constraintsType = (compareVersions(browser.version, '11.0.0') >= 0 ? 'standard' : 'legacy');
}
// Default constraints handling
else {
capabilities.constraintsType = 'legacy';
}