Bug 823512: Part 3: Deprecated API calls emit warnings to web-console. r=jesup,bz
authorJan-Ivar Bruaroey <jib@mozilla.com>
Sat, 11 May 2013 20:48:29 -0400
changeset 143721 b115d0dbc1d50464629101242e2f1742e1b89548
parent 143720 0221d61cef72d22159bc023be50000feea0b2a03
child 143722 4f60fe3eefc58a9eda9071a66d8800cec7a59aba
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, bz
bugs823512
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 823512: Part 3: Deprecated API calls emit warnings to web-console. r=jesup,bz
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -469,16 +469,54 @@ RTCPeerConnection.prototype = {
       throw new Components.Exception("Peer connection is closed");
     }
   },
 
   dispatchEvent: function(event) {
     this.__DOM_IMPL__.dispatchEvent(event);
   },
 
+  // Log error message to web console and window.onerror, if present.
+  reportError: function(msg, file, line) {
+    this.reportMsg(msg, file, line, Ci.nsIScriptError.exceptionFlag);
+  },
+
+  reportWarning: function(msg, file, line) {
+    this.reportMsg(msg, file, line, Ci.nsIScriptError.warningFlag);
+  },
+
+  reportMsg: 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);
+
+    if (flag != Ci.nsIScriptError.warningFlag) {
+      // Safely call onerror directly if present (necessary for testing)
+      try {
+        if (typeof this._win.onerror === "function") {
+          this._win.onerror(msg, file, line);
+        }
+      } catch(e) {
+        // If onerror itself throws, service it.
+        try {
+          let scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError);
+          scriptError.initWithWindowID(e.message, e.fileName, null, e.lineNumber,
+                                       0, Ci.nsIScriptError.exceptionFlag,
+                                       "content javascript",
+                                       this._winID);
+          console.logMessage(scriptError);
+        } catch(e) {}
+      }
+    }
+  },
+
   getEH: function(type) {
     return this.__DOM_IMPL__.getEventHandler(type);
   },
 
   setEH: function(type, handler) {
     this.__DOM_IMPL__.setEventHandler(type, handler);
   },
 
@@ -498,17 +536,17 @@ RTCPeerConnection.prototype = {
     this._onicechange = cb;
   },
   set ongatheringchange(cb) {
     this.deprecated("ongatheringchange");
     this._ongatheringchange = cb;
   },
 
   deprecated: function(name) {
-    dump(name + " is deprecated!\n");
+    this.reportWarning(name + " is deprecated!", null, 0);
   },
 
   createOffer: function(onSuccess, onError, constraints) {
     if (!constraints) {
       constraints = {};
     }
     if (!onError) {
       this.deprecated("calling createOffer without failureCallback");
@@ -847,50 +885,21 @@ PeerConnectionObserver.prototype = {
   callCB: function(callback, arg) {
     if (callback) {
       try {
         callback(arg);
       } catch(e) {
         // A content script (user-provided) callback threw an error. We don't
         // want this to take down peerconnection, but we still want the user
         // to see it, so we catch it, report it, and move on.
-        this.reportError(e.message, e.fileName, e.lineNumber);
+        this._dompc.reportError(e.message, e.fileName, e.lineNumber);
       }
     }
   },
 
-  // Log error message to web console and window.onerror, if present.
-  reportError: function(msg, file, line) {
-    let scriptErrorClass = Cc["@mozilla.org/scripterror;1"];
-    let scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError);
-    scriptError.initWithWindowID(msg, file, null, line,0,
-                                 Ci.nsIScriptError.exceptionFlag,
-                                 "content javascript", this._dompc._winID);
-    let console = Cc["@mozilla.org/consoleservice;1"].
-      getService(Ci.nsIConsoleService);
-    console.logMessage(scriptError);
-
-    // Safely call onerror directly if present (necessary for testing)
-    try {
-      if (typeof this._dompc._win.onerror === "function") {
-        this._dompc._win.onerror(msg, file, line);
-      }
-    } catch(e) {
-      // If onerror itself throws, service it.
-      try {
-        let scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError);
-        scriptError.initWithWindowID(e.message, e.fileName, null, e.lineNumber,
-                                     0, Ci.nsIScriptError.exceptionFlag,
-                                     "content javascript",
-                                     this._dompc._winID);
-        console.logMessage(scriptError);
-      } catch(e) {}
-    }
-  },
-
   onCreateOfferSuccess: function(sdp) {
     this.callCB(this._dompc._onCreateOfferSuccess,
                 new this._dompc._win.mozRTCSessionDescription({ type: "offer",
                                                                 sdp: sdp }));
     this._dompc._executeNext();
   },
 
   onCreateOfferError: function(code, message) {