You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Handle WebRTC security errors as non-fatal
Fixes https://github.com/vector-im/riot-web/issues/10898 In some restricted modes of Firefox, the WebRTC classes aren't super available: accessing them can cause SecurityErrors to be raised. In these conditions, we should just disable WebRTC support instead of falling apart.
This commit is contained in:
@@ -1370,24 +1370,36 @@ module.exports.createNewMatrixCall = function(client, roomId, options) {
|
|||||||
return getUserMedia.apply(w.navigator, arguments);
|
return getUserMedia.apply(w.navigator, arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
webRtc.RtcPeerConnection = (
|
|
||||||
w.RTCPeerConnection || w.webkitRTCPeerConnection || w.mozRTCPeerConnection
|
// Firefox throws on so little as accessing the RTCPeerConnection when operating in
|
||||||
);
|
// a secure mode. There's some information at https://bugzilla.mozilla.org/show_bug.cgi?id=1542616
|
||||||
webRtc.RtcSessionDescription = (
|
// though the concern is that the browser throwing a SecurityError will brick the
|
||||||
w.RTCSessionDescription || w.webkitRTCSessionDescription ||
|
// client creation process.
|
||||||
w.mozRTCSessionDescription
|
try {
|
||||||
);
|
webRtc.RtcPeerConnection = (
|
||||||
webRtc.RtcIceCandidate = (
|
w.RTCPeerConnection || w.webkitRTCPeerConnection || w.mozRTCPeerConnection
|
||||||
w.RTCIceCandidate || w.webkitRTCIceCandidate || w.mozRTCIceCandidate
|
);
|
||||||
);
|
webRtc.RtcSessionDescription = (
|
||||||
webRtc.vendor = null;
|
w.RTCSessionDescription || w.webkitRTCSessionDescription ||
|
||||||
if (w.mozRTCPeerConnection) {
|
w.mozRTCSessionDescription
|
||||||
webRtc.vendor = "mozilla";
|
);
|
||||||
} else if (w.webkitRTCPeerConnection) {
|
webRtc.RtcIceCandidate = (
|
||||||
webRtc.vendor = "webkit";
|
w.RTCIceCandidate || w.webkitRTCIceCandidate || w.mozRTCIceCandidate
|
||||||
} else if (w.RTCPeerConnection) {
|
);
|
||||||
webRtc.vendor = "generic";
|
webRtc.vendor = null;
|
||||||
|
if (w.mozRTCPeerConnection) {
|
||||||
|
webRtc.vendor = "mozilla";
|
||||||
|
} else if (w.webkitRTCPeerConnection) {
|
||||||
|
webRtc.vendor = "webkit";
|
||||||
|
} else if (w.RTCPeerConnection) {
|
||||||
|
webRtc.vendor = "generic";
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logger.error("Failed to set up WebRTC object: possible browser interference?");
|
||||||
|
logger.error(e);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!webRtc.RtcIceCandidate || !webRtc.RtcSessionDescription ||
|
if (!webRtc.RtcIceCandidate || !webRtc.RtcSessionDescription ||
|
||||||
!webRtc.RtcPeerConnection || !webRtc.getUserMedia) {
|
!webRtc.RtcPeerConnection || !webRtc.getUserMedia) {
|
||||||
return null; // WebRTC is not supported.
|
return null; // WebRTC is not supported.
|
||||||
|
|||||||
Reference in New Issue
Block a user