mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
Bug 823512: Part 3: Deprecated API calls emit warnings to web-console. r=jesup,bz
This commit is contained in:
parent
1cfedb8565
commit
1bc4070ba9
@ -474,6 +474,44 @@ RTCPeerConnection.prototype = {
|
||||
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);
|
||||
},
|
||||
@ -503,7 +541,7 @@ RTCPeerConnection.prototype = {
|
||||
},
|
||||
|
||||
deprecated: function(name) {
|
||||
dump(name + " is deprecated!\n");
|
||||
this.reportWarning(name + " is deprecated!", null, 0);
|
||||
},
|
||||
|
||||
createOffer: function(onSuccess, onError, constraints) {
|
||||
@ -852,40 +890,11 @@ PeerConnectionObserver.prototype = {
|
||||
// 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",
|
||||
|
Loading…
Reference in New Issue
Block a user