From adc07ece4ea97f4e86b400b0af28ad1c8e2b6bb5 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Tue, 26 Sep 2023 13:38:20 +0000 Subject: [PATCH] Bug 1854913 - Turn off ESLint rule mozilla/use-chromeutils-generateqi for plain mochitests as it should not apply there. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D189099 --- .eslintrc.js | 3 --- .../test/navigation/test_contentpolicy_block_window.html | 1 - .../test/chrome/test_notification_system_principal.xhtml | 8 +------- dom/notification/test/mochitest/MockServices.js | 1 - image/test/mochitest/test_net_failedtoprocess.html | 1 - .../eslint-plugin-mozilla/lib/configs/mochitest-test.js | 3 +++ .../lib/rules/use-chromeutils-generateqi.js | 2 +- 7 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9d00a36cde75..731ed9e37c9d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -351,7 +351,6 @@ module.exports = { "mozilla/no-arbitrary-setTimeout": "off", "mozilla/no-define-cc-etc": "off", "mozilla/prefer-boolean-length-check": "off", - "mozilla/use-chromeutils-generateqi": "off", "mozilla/use-default-preference-values": "off", "mozilla/use-includes-instead-of-indexOf": "off", "mozilla/use-services": "off", @@ -439,7 +438,6 @@ module.exports = { "mozilla/no-define-cc-etc": "off", "mozilla/reject-importGlobalProperties": "off", "mozilla/use-cc-etc": "off", - "mozilla/use-chromeutils-generateqi": "off", "mozilla/use-includes-instead-of-indexOf": "off", "mozilla/use-ownerGlobal": "off", "mozilla/use-services": "off", @@ -580,7 +578,6 @@ module.exports = { rules: { "mozilla/no-useless-parameters": "off", "mozilla/no-useless-removeEventListener": "off", - "mozilla/use-chromeutils-generateqi": "off", "mozilla/use-services": "off", complexity: "off", "no-array-constructor": "off", diff --git a/docshell/test/navigation/test_contentpolicy_block_window.html b/docshell/test/navigation/test_contentpolicy_block_window.html index 7ce337c13156..8614844c041d 100644 --- a/docshell/test/navigation/test_contentpolicy_block_window.html +++ b/docshell/test/navigation/test_contentpolicy_block_window.html @@ -35,7 +35,6 @@ var policyID = SpecialPowers.wrap(SpecialPowers.Components).ID("{b80e19d0-878f-d var policyName = "@mozilla.org/testpolicy;1"; var policy = { // nsISupports implementation - // eslint-disable-next-line mozilla/use-chromeutils-generateqi QueryInterface(iid) { iid = SpecialPowers.wrap(iid); if (iid.equals(Ci.nsISupports) || diff --git a/dom/notification/test/chrome/test_notification_system_principal.xhtml b/dom/notification/test/chrome/test_notification_system_principal.xhtml index 27891caeede0..58126fbc9d4d 100644 --- a/dom/notification/test/chrome/test_notification_system_principal.xhtml +++ b/dom/notification/test/chrome/test_notification_system_principal.xhtml @@ -34,13 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874090 this.showAlert(); }, - QueryInterface: function(aIID) { - if (aIID.equals(Ci.nsISupports) || - aIID.equals(Ci.nsIAlertsService)) { - return this; - } - throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE); - }, + QueryInterface: ChromeUtils.generateQI(["nsIAlertsService"]), createInstance: function(aIID) { return this.QueryInterface(aIID); diff --git a/dom/notification/test/mochitest/MockServices.js b/dom/notification/test/mochitest/MockServices.js index 0f50bcf5bfd6..4b2526c26a0b 100644 --- a/dom/notification/test/mochitest/MockServices.js +++ b/dom/notification/test/mochitest/MockServices.js @@ -1,4 +1,3 @@ -/* eslint-disable mozilla/use-chromeutils-generateqi */ var MockServices = (function () { "use strict"; diff --git a/image/test/mochitest/test_net_failedtoprocess.html b/image/test/mochitest/test_net_failedtoprocess.html index 470f3f5b315e..95ab5c0cc3e7 100644 --- a/image/test/mochitest/test_net_failedtoprocess.html +++ b/image/test/mochitest/test_net_failedtoprocess.html @@ -23,7 +23,6 @@ var obs = Cc["@mozilla.org/observer-service;1"].getService(); obs = obs.QueryInterface(Ci.nsIObserverService); var observer = { - /* eslint-disable-next-line mozilla/use-chromeutils-generateqi */ QueryInterface (aIID) { if (aIID.equals(Ci.nsISupports) || aIID.equals(Ci.nsIObserver)) diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js index 3f72193d4d89..a4ff5dcdd125 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js @@ -54,6 +54,9 @@ module.exports = { // We mis-predict globals for HTML test files in directories shared // with browser tests, so don't try to "fix" imports that are needed. "mozilla/no-redeclare-with-import-autofix": "off", + // Turn off use-chromeutils-generateqi as these tests don't have ChromeUtils + // available. + "mozilla/use-chromeutils-generateqi": "off", "no-shadow": "error", }, }; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js index 42227648400b..f69562e36651 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/use-chromeutils-generateqi.js @@ -48,7 +48,7 @@ module.exports = { fixable: "code", messages: { noJSQueryInterface: - "Please use ChromeUtils.generateQI rather than" + + "Please use ChromeUtils.generateQI rather than " + "manually creating JavaScript QueryInterface functions", noXpcomUtilsGenerateQI: "Please use ChromeUtils.generateQI instead of XPCOMUtils.generateQI",