Bug 1158868 - PeerConnection should not depend on navigator.onLine r=jesup

This commit is contained in:
Valentin Gosu 2015-04-28 18:29:57 +03:00
parent 8452755ec9
commit da7974f079

View File

@ -149,14 +149,18 @@ GlobalPCList.prototype = {
this._networkdown = false;
}
} else if (topic == "network:app-offline-status-changed") {
// App just went offline. The subject also contains the appId,
// but navigator.onLine checks that for us
if (!this._networkdown && !this._win.navigator.onLine) {
for (let winId in this._list) {
// App changed offline status. The subject contains the appId for which
// we need to check the status
let appId = subject.QueryInterface(Ci.nsIAppOfflineInfo).appId;
let ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
for (let winId in this._list) {
if (appId != this._list[winId]._appId) {
continue;
}
if (ios.isAppOffline(appId)) {
cleanupWinId(this._list, winId);
}
}
this._networkdown = !this._win.navigator.onLine;
} else if (topic == "gmp-plugin-crash") {
// a plugin crashed; if it's associated with any of our PCs, fire an
// event to the DOM window
@ -324,7 +328,19 @@ RTCPeerConnection.prototype = {
});
this._mustValidateRTCConfiguration(rtcConfig,
"RTCPeerConnection constructor passed invalid RTCConfiguration");
if (_globalPCList._networkdown || !this._win.navigator.onLine) {
// Save the appId
this._appId = Cu.getWebIDLCallerPrincipal().appId;
// Get the offline status for this appId
let appOffline = false;
if (this._appId != Ci.nsIScriptSecurityManager.NO_APP_ID &&
this._appId != Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID) {
let ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
appOffline = ios.isAppOffline(this._appId);
}
if (_globalPCList._networkdown || appOffline) {
throw new this._win.DOMException(
"Can't create RTCPeerConnections when the network is down",
"InvalidStateError");