Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js/common_shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export function removeExtmapAllowMixed(window, browserDetails) {
if (browserDetails.browser === 'chrome' && browserDetails.version >= 71) {
return;
}
if (browserDetails.browser === 'safari' && browserDetails.version >= 605) {
if (browserDetails.browser === 'safari' && browserDetails.version >= 13.1) {
return;
}
const nativeSRD = window.RTCPeerConnection.prototype.setRemoteDescription;
Expand Down
4 changes: 2 additions & 2 deletions src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let deprecationWarnings_ = true;
*/
export function extractVersion(uastring, expr, pos) {
const match = uastring.match(expr);
return match && match.length >= pos && parseInt(match[pos], 10);
return match && match.length >= pos && parseFloat(match[pos], 10);
}

// Wraps the peerconnection event eventNameToWrap in a function
Expand Down Expand Up @@ -177,7 +177,7 @@ export function detectBrowser(window) {
navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) { // Safari.
result.browser = 'safari';
result.version = extractVersion(navigator.userAgent,
/AppleWebKit\/(\d+)\./, 1);
/version\/(\d+(\.?\d+))/i, 1);
Comment thread
lukasIO marked this conversation as resolved.
Outdated
result.supportsUnifiedPlan = window.RTCRtpTransceiver &&
'currentDirection' in window.RTCRtpTransceiver.prototype;
} else { // Default fallthrough: not supported.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/detectBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ describe('detectBrowser', () => {

const browserDetails = detectBrowser(window);
expect(browserDetails.browser).to.equal('safari');
expect(browserDetails.version).to.equal(604);
expect(browserDetails.version).to.equal(10.2);
});
});
10 changes: 5 additions & 5 deletions test/unit/extmap-allow-mixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ describe('removal of extmap-allow-mixed', () => {
window.RTCPeerConnection.prototype.setRemoteDescription = function() {
return origSetRemoteDescription.apply(this, arguments);
};
browserDetails = {browser: 'safari', version: '605'};
browserDetails = {browser: 'safari', version: 13.1};
});

it('does not remove the extmap-allow-mixed line after 605', () => {
browserDetails.version = 605;
it('does not remove the extmap-allow-mixed line after 13.1', () => {
browserDetails.version = 13.1;
shim.removeExtmapAllowMixed(window, browserDetails);

const pc = new window.RTCPeerConnection();
Expand All @@ -83,8 +83,8 @@ describe('removal of extmap-allow-mixed', () => {
.to.equal('\n' + sdp);
});

it('does remove the extmap-allow-mixed line before 605', () => {
browserDetails.version = 604;
it('does remove the extmap-allow-mixed line before 13.1', () => {
browserDetails.version = 13.0;
shim.removeExtmapAllowMixed(window, browserDetails);

const pc = new window.RTCPeerConnection();
Expand Down
23 changes: 15 additions & 8 deletions test/unit/extractVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,30 +116,37 @@ describe('extractVersion', () => {
});

describe('Safari regular expression', () => {
const expr = /AppleWebKit\/(\d+)/;
it('matches the webkit version', () => {
const expr = /version\/(\d+(\.?\d+))/i;
Comment thread
lukasIO marked this conversation as resolved.
Outdated
it('matches the Safari version', () => {
ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) ' +
'AppleWebKit/604.1.6 (KHTML, like Gecko) Version/10.2 Safari/604.1.6';
expect(extractVersion(ua, expr, 1)).to.equal(604);
expect(extractVersion(ua, expr, 1)).to.equal(10.2);
});

it('drops patch version numbers', () => {
ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) ' +
'AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0.4 ' +
'Mobile/11D167 Safari/9537.53';
expect(extractVersion(ua, expr, 1)).to.equal(7.0);
});

it('matches the iphone simulator', () => {
ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) ' +
'AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 ' +
'Mobile/12A4345d Safari/600.1.4';
expect(extractVersion(ua, expr, 1)).to.equal(600);
expect(extractVersion(ua, expr, 1)).to.equal(8.0);
});

it('matches Chrome (by design, do not use for Chrome)', () => {
it('does not match Chrome', () => {
ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like ' +
'Gecko) Chrome/45.0.2454.101 Safari/537.36';
expect(extractVersion(ua, expr, 1)).to.equal(537);
expect(extractVersion(ua, expr, 1)).to.equal(null);
});

it('matches Edge (by design, do not use for Edge', () => {
it('does not match Edge', () => {
ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' +
'(KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10547';
expect(extractVersion(ua, expr, 1)).to.equal(537);
expect(extractVersion(ua, expr, 1)).to.equal(null);
});

it('does not match Firefox', () => {
Expand Down