Bug 1427745 - Enable ESLint rule mozilla/use-services for dom/media. r?jib
MozReview-Commit-ID: 5UfN1TJH6D4
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -29,17 +29,16 @@ module.exports = {
// so turn off mozilla/use-services for them for now.
"files": [
"accessible/**",
// Browser: Bug 1421379
"browser/extensions/shield-recipe-client/test/browser/head.js",
"browser/modules/offlineAppCache.jsm",
"devtools/**",
"dom/indexedDB/**",
- "dom/media/**",
"extensions/pref/**",
"mobile/android/**",
"security/**",
"testing/**",
"tools/profiler/**",
],
"rules": {
"mozilla/use-services": "off",
--- a/dom/media/IdpSandbox.jsm
+++ b/dom/media/IdpSandbox.jsm
@@ -151,19 +151,17 @@ IdpSandbox.checkProtocol = function(prot
*/
IdpSandbox.createIdpUri = function(domain, protocol) {
IdpSandbox.checkDomain(domain);
IdpSandbox.checkProtocol(protocol);
let message = "Invalid IdP parameters: ";
try {
let wkIdp = "https://" + domain + "/.well-known/idp-proxy/" + protocol;
- let ioService = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Ci.nsIIOService);
- let uri = ioService.newURI(wkIdp);
+ let uri = Services.io.newURI(wkIdp);
if (uri.hostPort !== domain) {
throw new Error(message + "domain is invalid");
}
if (uri.pathQueryRef.indexOf("/.well-known/idp-proxy/") !== 0) {
throw new Error(message + "must produce a /.well-known/idp-proxy/ URI");
}
@@ -247,19 +245,17 @@ IdpSandbox.prototype = {
let winID = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
let scriptError = Cc["@mozilla.org/scripterror;1"]
.createInstance(Ci.nsIScriptError);
scriptError.initWithWindowID(e.message, e.fileName, null,
e.lineNumber, e.columnNumber,
Ci.nsIScriptError.errorFlag,
"content javascript", winID);
- let consoleService = Cc["@mozilla.org/consoleservice;1"]
- .getService(Ci.nsIConsoleService);
- consoleService.logMessage(scriptError);
+ Services.console.logMessage(scriptError);
},
stop() {
if (this.sandbox) {
Cu.nukeSandbox(this.sandbox);
}
this.sandbox = null;
this.active = null;
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -42,19 +42,17 @@ const PC_TRANSCEIVER_CID = Components.ID
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);
+ Services.console.logMessage(scriptError);
}
let setupPrototype = (_class, dict) => {
_class.prototype.classDescription = _class.name;
Object.assign(_class.prototype, dict);
};
// Global list of PeerConnection objects, so they can be cleaned up when
@@ -644,21 +642,19 @@ class RTCPeerConnection {
server.urls = [server.urls];
} else if (!server.urls && server.url) {
// TODO: Remove support for legacy iceServer.url eventually (Bug 1116766)
server.urls = [server.url];
this.logWarning("RTCIceServer.url is deprecated! Use urls instead.");
}
});
- let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-
let nicerNewURI = uriStr => {
try {
- return ios.newURI(uriStr);
+ return Services.io.newURI(uriStr);
} catch (e) {
if (e.result == Cr.NS_ERROR_MALFORMED_URI) {
throw new this._win.DOMException(msg + " - malformed URI: " + uriStr,
"SyntaxError");
}
throw e;
}
};