• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

collab-project / videojs-record / 16785499749

06 Aug 2025 06:35PM UTC coverage: 71.445% (+1.6%) from 69.859%
16785499749

Pull #747

github

web-flow
Merge c48a16594 into 26aa124ff
Pull Request #747: build(deps): bump tmp from 0.2.1 to 0.2.4

373 of 581 branches covered (64.2%)

Branch coverage included in aggregate %.

843 of 1121 relevant lines covered (75.2%)

45.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.33
/src/js/utils/detect-browser.js
1
/**
2
 * @file detect-browser.js
3
 * @since 2.0.0
4
 */
5

6
import window from 'global/window';
7

8
/**
9
 * Browser detector.
10
 *
11
 * @private
12
 * @return {object} result containing browser, version and minVersion
13
 *     properties.
14
 */
15
const detectBrowser = function() {
1✔
16
    // returned result object
17
    let result = {};
9✔
18
    result.browser = null;
9✔
19
    result.version = null;
9✔
20
    result.minVersion = null;
9✔
21

22
    // fail early if it's not a browser
23
    if (typeof window === 'undefined' || !window.navigator) {
9!
24
        result.browser = 'Not a supported browser.';
×
25
        return result;
×
26
    }
27

28
    if (navigator.mozGetUserMedia) { // Firefox.
9!
29
        result.browser = 'firefox';
×
30
        result.version = extractVersion(navigator.userAgent,
×
31
            /Firefox\/(\d+)\./, 1);
32
        result.minVersion = 31;
×
33
    } else if (navigator.webkitGetUserMedia) {
9!
34
        // Chrome, Chromium, Webview, Opera.
35
        // Version matches Chrome/WebRTC version.
36
        result.browser = 'chrome';
9✔
37
        result.version = extractVersion(navigator.userAgent,
9✔
38
            /Chrom(e|ium)\/(\d+)\./, 2); // buddy ignore:line
39
        result.minVersion = 38;
9✔
40
    } else if (navigator.mediaDevices &&
×
41
               navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)) { // Edge.
42
        result.browser = 'edge';
×
43
        result.version = extractVersion(navigator.userAgent,
×
44
            /Edge\/(\d+).(\d+)$/, 2); // buddy ignore:line
45
        result.minVersion = 10547;
×
46
    } else if (window.RTCPeerConnection &&
×
47
        navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) { // Safari.
48
        result.browser = 'safari';
×
49
        result.version = extractVersion(navigator.userAgent,
×
50
            /AppleWebKit\/(\d+)\./, 1);
51
    } else {
52
        // Default fallthrough: not supported.
53
        result.browser = 'Not a supported browser.';
×
54
        return result;
×
55
    }
56

57
    return result;
9✔
58
};
59

60
/**
61
 * Extract browser version out of the provided user agent string.
62
 *
63
 * @private
64
 * @param {!string} uastring - userAgent string.
65
 * @param {!string} expr - Regular expression used as match criteria.
66
 * @param {!number} pos - position in the version string to be
67
 *     returned.
68
 * @return {!number} browser version.
69
 */
70
const extractVersion = function(uastring, expr, pos) {
1✔
71
    let match = uastring.match(expr);
9✔
72
    return match && match.length >= pos && parseInt(match[pos], 10); // buddy ignore:line
9✔
73
};
74

75
const isEdge = function() {
1✔
76
    return detectBrowser().browser === 'edge';
×
77
};
78

79
const isSafari = function() {
1✔
80
    return detectBrowser().browser === 'safari';
×
81
};
82

83
const isOpera = function() {
1✔
84
    return !!window.opera || navigator.userAgent.indexOf('OPR/') !== -1;
×
85
};
86

87
const isChrome = function() {
1✔
88
    return detectBrowser().browser === 'chrome';
×
89
};
90

91
const isFirefox = function() {
1✔
92
    return detectBrowser().browser === 'firefox';
4✔
93
};
94

95
export {
96
    detectBrowser, isEdge, isOpera, isChrome, isSafari, isFirefox
97
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc