Bug 1313966 - Add deprecation warnings to writable RTCSessionDescription. r=drno,smaug

MozReview-Commit-ID: AZAjbgJHTAc

--HG--
extra : rebase_source : 23e368ed80414fb3a9b546b2842d5141dbcb4c0a
This commit is contained in:
Jan-Ivar Bruaroey 2016-11-08 17:50:24 -05:00
Родитель d28e124637
Коммит 42cfd0d3ab
2 изменённых файлов: 51 добавлений и 18 удалений

Просмотреть файл

@ -40,6 +40,16 @@ const PC_RECEIVER_CID = Components.ID("{d974b814-8fde-411c-8c45-b86791b81030}");
const PC_COREQUEST_CID = Components.ID("{74b2122d-65a8-4824-aa9e-3d664cb75dc2}"); const PC_COREQUEST_CID = Components.ID("{74b2122d-65a8-4824-aa9e-3d664cb75dc2}");
const PC_DTMF_SENDER_CID = Components.ID("{3610C242-654E-11E6-8EC0-6D1BE389A607}"); const PC_DTMF_SENDER_CID = Components.ID("{3610C242-654E-11E6-8EC0-6D1BE389A607}");
function logMsg(msg, file, line, flag, winID) {
let scriptErrorClass = Cc["@mozilla.org/scripterror;1"];
let scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError);
scriptError.initWithWindowID(msg, file, null, line, 0, flag,
"content javascript", winID);
let console = Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService);
console.logMessage(scriptError);
};
// Global list of PeerConnection objects, so they can be cleaned up when // Global list of PeerConnection objects, so they can be cleaned up when
// a page is torn down. (Maps inner window ID to an array of PC objects). // a page is torn down. (Maps inner window ID to an array of PC objects).
function GlobalPCList() { function GlobalPCList() {
@ -238,9 +248,7 @@ RTCIceCandidate.prototype = {
} }
}; };
function RTCSessionDescription() { function RTCSessionDescription() {}
this.type = this.sdp = null;
}
RTCSessionDescription.prototype = { RTCSessionDescription.prototype = {
classDescription: "RTCSessionDescription", classDescription: "RTCSessionDescription",
classID: PC_SESSION_CID, classID: PC_SESSION_CID,
@ -248,11 +256,41 @@ RTCSessionDescription.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
Ci.nsIDOMGlobalPropertyInitializer]), Ci.nsIDOMGlobalPropertyInitializer]),
init: function(win) { this._win = win; }, init: function(win) {
this._win = win;
this._winID = this._win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
},
__init: function(dict) { __init: function({ type, sdp }) {
this.type = dict.type; Object.assign(this, { _type: type, _sdp: sdp });
this.sdp = dict.sdp; },
get type() { return this._type; },
set type(type) {
this.warn();
this._type = type;
},
get sdp() { return this._sdp; },
set sdp(sdp) {
this.warn();
this._sdp = sdp;
},
warn: function() {
if (!this._warned) {
// Warn once per RTCSessionDescription about deprecated writable usage.
this.logWarning("RTCSessionDescription's members are readonly! " +
"Writing to them is deprecated and will break soon!");
this._warned = true;
}
},
logWarning: function(msg) {
let err = this._win.Error();
logMsg(msg, err.fileName, err.lineNumber, Ci.nsIScriptError.warningFlag,
this._winID);
} }
}; };
@ -635,13 +673,7 @@ RTCPeerConnection.prototype = {
}, },
logMsg: function(msg, file, line, flag) { logMsg: function(msg, file, line, flag) {
let scriptErrorClass = Cc["@mozilla.org/scripterror;1"]; return logMsg(msg, file, line, flag, this._winID);
let scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError);
scriptError.initWithWindowID(msg, file, null, line, 0, flag,
"content javascript", this._winID);
let console = Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService);
console.logMessage(scriptError);
}, },
getEH: function(type) { getEH: function(type) {

Просмотреть файл

@ -15,16 +15,17 @@ enum RTCSdpType {
}; };
dictionary RTCSessionDescriptionInit { dictionary RTCSessionDescriptionInit {
RTCSdpType? type = null; required RTCSdpType type;
DOMString? sdp = ""; DOMString sdp = "";
}; };
[Pref="media.peerconnection.enabled", [Pref="media.peerconnection.enabled",
JSImplementation="@mozilla.org/dom/rtcsessiondescription;1", JSImplementation="@mozilla.org/dom/rtcsessiondescription;1",
Constructor(optional RTCSessionDescriptionInit descriptionInitDict)] Constructor(optional RTCSessionDescriptionInit descriptionInitDict)]
interface RTCSessionDescription { interface RTCSessionDescription {
attribute RTCSdpType? type; // These should be readonly, but writing causes deprecation warnings for a bit
attribute DOMString? sdp; attribute RTCSdpType type;
attribute DOMString sdp;
jsonifier; jsonifier;
}; };