Bug 1609885 - Port bug 1609271 to Thunderbird: Stop using ChromeUtils.import(..., null). rs=linting DONTBUILD
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 30 Jan 2020 11:43:11 +1300
changeset 37158 06b59eceaa1140d367b7972f8d1215d051b6eac9
parent 37157 fdc16e6a800631497a823feb28ea0e61f1a91262
child 37159 c07c42028c728ccee7938e88b723bde54a1d0347
push id2552
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:24:16 +0000
treeherdercomm-beta@f95a6f4408a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslinting
bugs1609885, 1609271
Bug 1609885 - Port bug 1609271 to Thunderbird: Stop using ChromeUtils.import(..., null). rs=linting DONTBUILD
common/test/xpcshell/head_addons.js
common/test/xpcshell/test_bootstrap.js
mail/components/enterprisepolicies/tests/browser/browser_policies_setAndLockPref_API.js
mail/components/enterprisepolicies/tests/browser/head.js
mail/components/enterprisepolicies/tests/xpcshell/head.js
mail/components/enterprisepolicies/tests/xpcshell/test_proxy.js
mail/components/enterprisepolicies/tests/xpcshell/test_runOnce_helper.js
mail/components/im/modules/chatHandler.jsm
--- a/common/test/xpcshell/head_addons.js
+++ b/common/test/xpcshell/head_addons.js
@@ -185,21 +185,21 @@ Object.defineProperty(this, "TEST_UNPACK
     return AddonTestUtils.testUnpacked;
   },
   set(val) {
     return (AddonTestUtils.testUnpacked = val);
   },
 });
 
 // We need some internal bits of AddonManager
-var AMscope = ChromeUtils.import(
-  "resource://gre/modules/AddonManager.jsm",
-  null
-);
-var { AddonManager, AddonManagerInternal, AddonManagerPrivate } = AMscope;
+var {
+  AddonManager,
+  AddonManagerInternal,
+  AddonManagerPrivate,
+} = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 
 const promiseAddonByID = AddonManager.getAddonByID;
 const promiseAddonsByIDs = AddonManager.getAddonsByIDs;
 
 var gPort = null;
 var gUrlToFileMap = {};
 
 // Map resource://xpcshell-data/ to the data directory
--- a/common/test/xpcshell/test_bootstrap.js
+++ b/common/test/xpcshell/test_bootstrap.js
@@ -175,23 +175,22 @@ function getInstallOldVersion() {
 }
 
 function getUninstallNewVersion() {
   let info = BootstrapMonitor.uninstalled.get(ID1);
   return info ? info.data.newVersion : undefined;
 }
 
 async function checkBootstrappedPref() {
-  let XPIScope = ChromeUtils.import(
-    "resource://gre/modules/addons/XPIProvider.jsm",
-    null
+  let { XPIInternal } = ChromeUtils.import(
+    "resource://gre/modules/addons/XPIProvider.jsm"
   );
 
   let data = new Map();
-  for (let entry of XPIScope.XPIStates.enabledAddons()) {
+  for (let entry of XPIInternal.XPIStates.enabledAddons()) {
     data.set(entry.id, entry);
   }
 
   let addons = await AddonManager.getAddonsByTypes(["extension"]);
   for (let addon of addons) {
     if (!addon.id.endsWith("@tests.mozilla.org")) {
       continue;
     }
--- a/mail/components/enterprisepolicies/tests/browser/browser_policies_setAndLockPref_API.js
+++ b/mail/components/enterprisepolicies/tests/browser/browser_policies_setAndLockPref_API.js
@@ -1,13 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
+// eslint-disable-next-line mozilla/reject-chromeutils-import-null
 let { Policies, setAndLockPref, setDefaultPref } = ChromeUtils.import(
   "resource:///modules/policies/Policies.jsm",
   null
 );
 
 add_task(async function test_API_directly() {
   await setupPolicyEngineWithJson("");
   setAndLockPref("policies.test.boolPref", true);
--- a/mail/components/enterprisepolicies/tests/browser/head.js
+++ b/mail/components/enterprisepolicies/tests/browser/head.js
@@ -1,21 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { EnterprisePolicyTesting, PoliciesPrefTracker } = ChromeUtils.import(
-  "resource://testing-common/EnterprisePolicyTesting.jsm",
-  null
+  "resource://testing-common/EnterprisePolicyTesting.jsm"
 );
 const { TestUtils } = ChromeUtils.import(
-  "resource://testing-common/TestUtils.jsm",
-  null
+  "resource://testing-common/TestUtils.jsm"
 );
 
 PoliciesPrefTracker.start();
 
 async function setupPolicyEngineWithJson(json, customSchema) {
   PoliciesPrefTracker.restoreDefaultValues();
   if (typeof json != "object") {
     let filePath = getTestFilePath(json ? json : "non-existing-file.json");
--- a/mail/components/enterprisepolicies/tests/xpcshell/head.js
+++ b/mail/components/enterprisepolicies/tests/xpcshell/head.js
@@ -47,18 +47,17 @@ async function setupPolicyEngineWithJson
     }, "EnterprisePolicies:AllPoliciesApplied");
   });
 
   // Clear any previously used custom schema
   Cu.unload("resource:///modules/policies/schema.jsm");
 
   if (customSchema) {
     let schemaModule = ChromeUtils.import(
-      "resource:///modules/policies/schema.jsm",
-      null
+      "resource:///modules/policies/schema.jsm"
     );
     schemaModule.schema = customSchema;
   }
 
   Services.obs.notifyObservers(null, "EnterprisePolicies:Restart");
   return promise;
 }
 
--- a/mail/components/enterprisepolicies/tests/xpcshell/test_proxy.js
+++ b/mail/components/enterprisepolicies/tests/xpcshell/test_proxy.js
@@ -3,16 +3,17 @@
 "use strict";
 
 add_task(async function test_proxy_modes_and_autoconfig() {
   // Directly test the proxy Mode and AutoconfigURL parameters through
   // the API instead of the policy engine, because the test harness
   // uses these prefs, and changing them interfere with the harness.
 
   // Checks that every Mode value translates correctly to the expected pref value
+  // eslint-disable-next-line mozilla/reject-chromeutils-import-null
   let { ProxyPolicies, PROXY_TYPES_MAP } = ChromeUtils.import(
     "resource:///modules/policies/ProxyPolicies.jsm",
     null
   );
 
   for (let [mode, expectedValue] of PROXY_TYPES_MAP) {
     ProxyPolicies.configureProxySettings({ Mode: mode }, (_, value) => {
       equal(value, expectedValue, "Correct proxy mode");
--- a/mail/components/enterprisepolicies/tests/xpcshell/test_runOnce_helper.js
+++ b/mail/components/enterprisepolicies/tests/xpcshell/test_runOnce_helper.js
@@ -1,13 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
+// eslint-disable-next-line mozilla/reject-chromeutils-import-null
 let { runOnce } = ChromeUtils.import(
   "resource:///modules/policies/Policies.jsm",
   null
 );
 
 let runCount = 0;
 function callback() {
   runCount++;
--- a/mail/components/im/modules/chatHandler.jsm
+++ b/mail/components/im/modules/chatHandler.jsm
@@ -19,17 +19,17 @@ var ChatCore = {
   initialized: false,
   _initializing: false,
   init() {
     if (this._initializing) {
       return;
     }
     this._initializing = true;
 
-    ChromeUtils.import("resource:///modules/index_im.jsm", null);
+    ChromeUtils.import("resource:///modules/index_im.jsm");
 
     Services.obs.addObserver(this, "browser-request");
     Services.obs.addObserver(this, "contact-signed-on");
     Services.obs.addObserver(this, "contact-signed-off");
     Services.obs.addObserver(this, "contact-added");
     Services.obs.addObserver(this, "contact-removed");
 
     // The initialization of the im core may trigger a master password prompt,