Update eslint-plugin-mozilla, and enable mozilla/use-services rule.

This commit is contained in:
Mark Banner 2017-11-24 16:58:36 +00:00
parent c236790fb4
commit 3065197cc4
4 changed files with 8 additions and 14 deletions

View File

@ -1,8 +1,4 @@
{ {
"extends": [
../../.eslintrc
],
"parserOptions": { "parserOptions": {
"ecmaVersion": 6, "ecmaVersion": 6,
"sourceType": "script" "sourceType": "script"
@ -19,6 +15,7 @@
"rules": { "rules": {
"mozilla/import-globals": "error", "mozilla/import-globals": "error",
"mozilla/use-services": "error",
// Best Practices // Best Practices
"consistent-return": "error", "consistent-return": "error",

View File

@ -144,9 +144,7 @@ function startup(aData, aReason) {
pdfStreamConverterFactory.register(PdfStreamConverter); pdfStreamConverterFactory.register(PdfStreamConverter);
try { try {
let globalMM = Cc["@mozilla.org/globalmessagemanager;1"] Services.mm.loadFrameScript("chrome://pdf.js/content/content.js", true);
.getService(Ci.nsIFrameScriptLoader);
globalMM.loadFrameScript("chrome://pdf.js/content/content.js", true);
e10sEnabled = true; e10sEnabled = true;
} catch (ex) { } catch (ex) {
} }

View File

@ -122,9 +122,8 @@ function getDOMWindow(aChannel) {
} }
function getLocalizedStrings(path) { function getLocalizedStrings(path) {
var stringBundle = Cc["@mozilla.org/intl/stringbundle;1"]. var stringBundle =
getService(Ci.nsIStringBundleService). Services.strings.createBundle("chrome://pdf.js/locale/" + path);
createBundle("chrome://pdf.js/locale/" + path);
var map = {}; var map = {};
var enumerator = stringBundle.getSimpleEnumeration(); var enumerator = stringBundle.getSimpleEnumeration();
@ -1028,11 +1027,10 @@ PdfStreamConverter.prototype = {
// We can use the resource principal when data is fetched by the chrome, // We can use the resource principal when data is fetched by the chrome,
// e.g. useful for NoScript. Make make sure we reuse the origin attributes // e.g. useful for NoScript. Make make sure we reuse the origin attributes
// from the request channel to keep isolation consistent. // from the request channel to keep isolation consistent.
var ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE); var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE);
var resourcePrincipal = var resourcePrincipal =
ssm.createCodebasePrincipal(uri, aRequest.loadInfo.originAttributes); Services.scriptSecurityManager.createCodebasePrincipal(uri,
aRequest.loadInfo.originAttributes);
aRequest.owner = resourcePrincipal; aRequest.owner = resourcePrincipal;
channel.asyncOpen2(proxy); channel.asyncOpen2(proxy);

View File

@ -10,7 +10,8 @@
"core-js": "^2.5.1", "core-js": "^2.5.1",
"escodegen": "^1.9.0", "escodegen": "^1.9.0",
"eslint": "^4.10.0", "eslint": "^4.10.0",
"eslint-plugin-mozilla": "^0.4.5", "eslint-plugin-mozilla": "^0.4.9",
"eslint-plugin-no-unsanitized": "^2.0.1",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-rename": "^1.2.2", "gulp-rename": "^1.2.2",
"gulp-replace": "^0.6.1", "gulp-replace": "^0.6.1",