mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1167922 - Handle broken entries in media.peerconnection.default_iceservers more gracefully. r=jib
This commit is contained in:
parent
dc360b12a8
commit
1053e1971e
@ -323,25 +323,30 @@ RTCPeerConnection.prototype = {
|
|||||||
__init: function(rtcConfig) {
|
__init: function(rtcConfig) {
|
||||||
this._winID = this._win.QueryInterface(Ci.nsIInterfaceRequestor)
|
this._winID = this._win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
|
.getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
|
||||||
|
|
||||||
if (!rtcConfig.iceServers ||
|
if (!rtcConfig.iceServers ||
|
||||||
!Services.prefs.getBoolPref("media.peerconnection.use_document_iceservers")) {
|
!Services.prefs.getBoolPref("media.peerconnection.use_document_iceservers")) {
|
||||||
rtcConfig.iceServers =
|
try {
|
||||||
JSON.parse(Services.prefs.getCharPref("media.peerconnection.default_iceservers"));
|
rtcConfig.iceServers =
|
||||||
}
|
JSON.parse(Services.prefs.getCharPref("media.peerconnection.default_iceservers") || "[]");
|
||||||
// Normalize iceServers input
|
} catch (e) {
|
||||||
rtcConfig.iceServers.forEach(server => {
|
this.logWarning(
|
||||||
if (typeof server.urls === "string") {
|
"Ignoring invalid media.peerconnection.default_iceservers in about:config",
|
||||||
server.urls = [server.urls];
|
null, 0);
|
||||||
} else if (!server.urls && server.url) {
|
rtcConfig.iceServers = [];
|
||||||
// TODO: Remove support for legacy iceServer.url eventually (Bug 1116766)
|
|
||||||
server.urls = [server.url];
|
|
||||||
this.logWarning("RTCIceServer.url is deprecated! Use urls instead.", null, 0);
|
|
||||||
}
|
}
|
||||||
});
|
try {
|
||||||
this._mustValidateRTCConfiguration(rtcConfig,
|
this._mustValidateRTCConfiguration(rtcConfig,
|
||||||
|
"Ignoring invalid media.peerconnection.default_iceservers in about:config");
|
||||||
|
} catch (e) {
|
||||||
|
this.logWarning(e.message, null, 0);
|
||||||
|
rtcConfig.iceServers = [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// This gets executed in the typical case when iceServers
|
||||||
|
// are passed in through the web page.
|
||||||
|
this._mustValidateRTCConfiguration(rtcConfig,
|
||||||
"RTCPeerConnection constructor passed invalid RTCConfiguration");
|
"RTCPeerConnection constructor passed invalid RTCConfiguration");
|
||||||
|
}
|
||||||
// Save the appId
|
// Save the appId
|
||||||
this._appId = Cu.getWebIDLCallerPrincipal().appId;
|
this._appId = Cu.getWebIDLCallerPrincipal().appId;
|
||||||
|
|
||||||
@ -463,12 +468,23 @@ RTCPeerConnection.prototype = {
|
|||||||
* { urls: ["turn:turn1.x.org", "turn:turn2.x.org"],
|
* { urls: ["turn:turn1.x.org", "turn:turn2.x.org"],
|
||||||
* username:"jib", credential:"mypass"} ] }
|
* username:"jib", credential:"mypass"} ] }
|
||||||
*
|
*
|
||||||
* WebIDL normalizes structure for us, so we test well-formed stun/turn urls,
|
* This function normalizes the structure of the input for rtcConfig.iceServers for us,
|
||||||
* but not validity of servers themselves, before passing along to C++.
|
* so we test well-formed stun/turn urls before passing along to C++.
|
||||||
*
|
|
||||||
* msg - Error message to detail which array-entry failed, if any.
|
* msg - Error message to detail which array-entry failed, if any.
|
||||||
*/
|
*/
|
||||||
_mustValidateRTCConfiguration: function(rtcConfig, msg) {
|
_mustValidateRTCConfiguration: function(rtcConfig, msg) {
|
||||||
|
|
||||||
|
// Normalize iceServers input
|
||||||
|
rtcConfig.iceServers.forEach(server => {
|
||||||
|
if (typeof server.urls === "string") {
|
||||||
|
server.urls = [server.urls];
|
||||||
|
} else if (!server.urls && server.url) {
|
||||||
|
// TODO: Remove support for legacy iceServer.url eventually (Bug 1116766)
|
||||||
|
server.urls = [server.url];
|
||||||
|
this.logWarning("RTCIceServer.url is deprecated! Use urls instead.", null, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
|
let ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
|
||||||
|
|
||||||
let nicerNewURI = uriStr => {
|
let nicerNewURI = uriStr => {
|
||||||
|
@ -72,7 +72,21 @@ runNetworkTest(() => {
|
|||||||
"mozRTCPeerConnection() constructor has readable exceptions");
|
"mozRTCPeerConnection() constructor has readable exceptions");
|
||||||
}
|
}
|
||||||
|
|
||||||
networkTestFinished();
|
// Below tests are setting the about:config User preferences for default
|
||||||
|
// ice servers and checking the outputs when mozRTCPeerConnection() is
|
||||||
|
// invoked. See Bug 1167922 for more information.
|
||||||
|
// Note - We use promises here since the SpecialPowers API will be
|
||||||
|
// performed asynchronously.
|
||||||
|
var push = prefs => new Promise(resolve =>
|
||||||
|
SpecialPowers.pushPrefEnv(prefs, resolve));
|
||||||
|
|
||||||
|
push({ set: [['media.peerconnection.default_iceservers', ""]] })
|
||||||
|
.then(() => makePC())
|
||||||
|
.then(() => push({ set: [['media.peerconnection.default_iceservers', "k"]] }))
|
||||||
|
.then(() => makePC())
|
||||||
|
.then(() => push({ set: [['media.peerconnection.default_iceservers', "[{\"urls\": [\"stun:stun.services.mozilla.com\"]}]"]] }))
|
||||||
|
.then(() => makePC())
|
||||||
|
.then(networkTestFinished);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
|
Loading…
Reference in New Issue
Block a user