From 3065197cc466a49e6ff78ee711be85852c01505f Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Fri, 24 Nov 2017 16:58:36 +0000 Subject: [PATCH] Update eslint-plugin-mozilla, and enable mozilla/use-services rule. --- extensions/firefox/.eslintrc | 5 +---- extensions/firefox/bootstrap.js | 4 +--- extensions/firefox/content/PdfStreamConverter.jsm | 10 ++++------ package.json | 3 ++- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/extensions/firefox/.eslintrc b/extensions/firefox/.eslintrc index e6ace0bb3..941d31897 100644 --- a/extensions/firefox/.eslintrc +++ b/extensions/firefox/.eslintrc @@ -1,8 +1,4 @@ { - "extends": [ - ../../.eslintrc - ], - "parserOptions": { "ecmaVersion": 6, "sourceType": "script" @@ -19,6 +15,7 @@ "rules": { "mozilla/import-globals": "error", + "mozilla/use-services": "error", // Best Practices "consistent-return": "error", diff --git a/extensions/firefox/bootstrap.js b/extensions/firefox/bootstrap.js index 50faf44ed..16d508f88 100644 --- a/extensions/firefox/bootstrap.js +++ b/extensions/firefox/bootstrap.js @@ -144,9 +144,7 @@ function startup(aData, aReason) { pdfStreamConverterFactory.register(PdfStreamConverter); try { - let globalMM = Cc["@mozilla.org/globalmessagemanager;1"] - .getService(Ci.nsIFrameScriptLoader); - globalMM.loadFrameScript("chrome://pdf.js/content/content.js", true); + Services.mm.loadFrameScript("chrome://pdf.js/content/content.js", true); e10sEnabled = true; } catch (ex) { } diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm index e2b56584e..48779e25d 100644 --- a/extensions/firefox/content/PdfStreamConverter.jsm +++ b/extensions/firefox/content/PdfStreamConverter.jsm @@ -122,9 +122,8 @@ function getDOMWindow(aChannel) { } function getLocalizedStrings(path) { - var stringBundle = Cc["@mozilla.org/intl/stringbundle;1"]. - getService(Ci.nsIStringBundleService). - createBundle("chrome://pdf.js/locale/" + path); + var stringBundle = + Services.strings.createBundle("chrome://pdf.js/locale/" + path); var map = {}; var enumerator = stringBundle.getSimpleEnumeration(); @@ -1028,11 +1027,10 @@ PdfStreamConverter.prototype = { // 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 // 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 resourcePrincipal = - ssm.createCodebasePrincipal(uri, aRequest.loadInfo.originAttributes); + Services.scriptSecurityManager.createCodebasePrincipal(uri, + aRequest.loadInfo.originAttributes); aRequest.owner = resourcePrincipal; channel.asyncOpen2(proxy); diff --git a/package.json b/package.json index 35a3bf19a..c9e1064b7 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "core-js": "^2.5.1", "escodegen": "^1.9.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-rename": "^1.2.2", "gulp-replace": "^0.6.1",