diff options
author | Basilisk-Dev <basiliskdev@protonmail.com> | 2023-10-09 17:00:40 -0400 |
---|---|---|
committer | Basilisk-Dev <basiliskdev@protonmail.com> | 2023-10-09 17:00:40 -0400 |
commit | 69cfed48da18688dc48e9a2576fa5a8b29747e09 (patch) | |
tree | 1467f3760b79269ed5278a76baabbcab9d4f66cf /dom | |
parent | 1b2c1d8eac22fa1ab1c4fff72f2de9aa025fccff (diff) | |
download | uxp-69cfed48da18688dc48e9a2576fa5a8b29747e09.tar.gz |
Issue #2332 - Add deprecation warnings to writable RTCSessionDescription
Backport of https://bugzilla.mozilla.org/show_bug.cgi?id=1313966
Diffstat (limited to 'dom')
-rw-r--r-- | dom/media/PeerConnection.js | 60 | ||||
-rw-r--r-- | dom/webidl/RTCSessionDescription.webidl | 9 |
2 files changed, 51 insertions, 18 deletions
diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index 622b1f08be..f735e371c1 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -38,6 +38,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_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 // a page is torn down. (Maps inner window ID to an array of PC objects). function GlobalPCList() { @@ -236,9 +246,7 @@ RTCIceCandidate.prototype = { } }; -function RTCSessionDescription() { - this.type = this.sdp = null; -} +function RTCSessionDescription() {} RTCSessionDescription.prototype = { classDescription: "RTCSessionDescription", classID: PC_SESSION_CID, @@ -246,11 +254,41 @@ RTCSessionDescription.prototype = { QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, 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) { - this.type = dict.type; - this.sdp = dict.sdp; + __init: function({ type, sdp }) { + Object.assign(this, { _type: type, _sdp: 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); } }; @@ -645,13 +683,7 @@ RTCPeerConnection.prototype = { }, logMsg: function(msg, file, line, flag) { - let scriptErrorClass = Cc["@mozilla.org/scripterror;1"]; - 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); + return logMsg(msg, file, line, flag, this._winID); }, getEH: function(type) { diff --git a/dom/webidl/RTCSessionDescription.webidl b/dom/webidl/RTCSessionDescription.webidl index 07bfb36f02..4dafe01e1b 100644 --- a/dom/webidl/RTCSessionDescription.webidl +++ b/dom/webidl/RTCSessionDescription.webidl @@ -15,16 +15,17 @@ enum RTCSdpType { }; dictionary RTCSessionDescriptionInit { - RTCSdpType? type = null; - DOMString? sdp = ""; + required RTCSdpType type; + DOMString sdp = ""; }; [Pref="media.peerconnection.enabled", JSImplementation="@mozilla.org/dom/rtcsessiondescription;1", Constructor(optional RTCSessionDescriptionInit descriptionInitDict)] interface RTCSessionDescription { - attribute RTCSdpType? type; - attribute DOMString? sdp; + // These should be readonly, but writing causes deprecation warnings for a bit + attribute RTCSdpType type; + attribute DOMString sdp; jsonifier; }; |