Bug 1600448 - Follow-up for Bug 1434737. Replace ChromeUtils.import() part 2 in suite. r=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Thu, 12 Dec 2019 19:49:40 +0100
changeset 37744 8ef25eb8c092d8d57719260a8aa019e9b793dbd1
parent 37743 8876b708ba297b57ad0fb7f88f3c50b0c3b558ee
child 37745 f4555c61a7b9fa3d011baf1eada893392162ef81
push id397
push userclokep@gmail.com
push dateMon, 10 Feb 2020 21:16:13 +0000
reviewersIanN
bugs1600448, 1434737
Bug 1600448 - Follow-up for Bug 1434737. Replace ChromeUtils.import() part 2 in suite. r=IanN
suite/base/content/utilityOverlay.js
suite/browser/linkToolbarHandler.js
suite/browser/pageinfo/security.js
suite/browser/test/browser/browser_bug409624.js
suite/browser/test/browser/browser_bug413915.js
suite/components/downloads/DownloadsCommon.jsm
suite/components/downloads/DownloadsTaskbar.jsm
suite/components/helpviewer/content/contextHelp.js
suite/components/helpviewer/content/help.js
suite/components/migration/SuiteProfileMigrator.js
suite/components/places/content/controller.js
suite/components/places/content/places.js
suite/components/pref/content/pref-download.js
suite/modules/Feeds.jsm
suite/modules/Sanitizer.jsm
--- a/suite/base/content/utilityOverlay.js
+++ b/suite/base/content/utilityOverlay.js
@@ -3,19 +3,19 @@
  * 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/. */
 
 /**
  * Communicator Shared Utility Library
  * for shared application glue for the Communicator suite of applications
  **/
 
-// Services = object with smart getters for common XPCOM services
-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { XPCOMUtils } =
+  ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   RecentWindow: "resource:///modules/RecentWindow.jsm",
 });
 
--- a/suite/browser/linkToolbarHandler.js
+++ b/suite/browser/linkToolbarHandler.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
-XPCOMUtils.defineLazyModuleGetter(this, "Feeds",
-                                  "resource:///modules/Feeds.jsm");
+ChromeUtils.defineModuleGetter(this, "Feeds",
+  "resource:///modules/Feeds.jsm");
 
 /**
  * LinkToolbarHandler is a Singleton that displays LINK elements
  * and nodeLists of LINK elements in the Link Toolbar.  It
  * associates the LINK with a corresponding LinkToolbarItem based
  * on it's REL attribute and the toolbar item's ID attribute.
  * LinkToolbarHandler is also a Factory and will create
  * LinkToolbarItems as necessary.
--- a/suite/browser/pageinfo/security.js
+++ b/suite/browser/pageinfo/security.js
@@ -1,15 +1,15 @@
 /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
-                                  "resource://gre/modules/PluralForm.jsm");
+ChromeUtils.defineModuleGetter(this, "PluralForm",
+  "resource://gre/modules/PluralForm.jsm");
 
 var security = {
   init: function(uri, windowInfo) {
     this.uri = uri;
     this.windowInfo = windowInfo;
   },
 
   // Display the server certificate (static)
--- a/suite/browser/test/browser/browser_bug409624.js
+++ b/suite/browser/test/browser/browser_bug409624.js
@@ -1,13 +1,13 @@
 /* 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/. */
 ChromeUtils.defineModuleGetter(this, "FormHistory",
-                               "resource://gre/modules/FormHistory.jsm");
+  "resource://gre/modules/FormHistory.jsm");
 
 function test() {
   waitForExplicitFinish();
 
   // This test relies on the form history being empty to start with delete
   // all the items first.
   FormHistory.update({ op: "remove" },
                      { handleError: function (error) {
--- a/suite/browser/test/browser/browser_bug413915.js
+++ b/suite/browser/test/browser/browser_bug413915.js
@@ -1,10 +1,10 @@
-XPCOMUtils.defineLazyModuleGetter(this, "Feeds",
-                                  "resource:///modules/Feeds.jsm");
+ChromeUtils.defineModuleGetter(this, "Feeds",
+  "resource:///modules/Feeds.jsm");
 
 function test() {
   var exampleUri = Services.io.newURI("http://example.com/");
   var secman = Cc["@mozilla.org/scriptsecuritymanager;1"]
                  .getService(Ci.nsIScriptSecurityManager);
   var principal = secman.createCodebasePrincipal(exampleUri, {});
 
   function testIsFeed(aTitle, aHref, aType, aKnown) {
--- a/suite/components/downloads/DownloadsCommon.jsm
+++ b/suite/components/downloads/DownloadsCommon.jsm
@@ -21,32 +21,35 @@ var EXPORTED_SYMBOLS = [
  *
  * DownloadsData
  * Retrieves the list of past and completed downloads from the underlying
  * Downloads API data, and provides asynchronous notifications allowing
  * to build a consistent view of the available data.
  */
 
 // Globals
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { XPCOMUtils } =
+  ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+const { AppConstants } =
+  ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   NetUtil: "resource://gre/modules/NetUtil.jsm",
   PluralForm: "resource://gre/modules/PluralForm.jsm",
   DownloadHistory: "resource://gre/modules/DownloadHistory.jsm",
   Downloads: "resource://gre/modules/Downloads.jsm",
   DownloadUIHelper: "resource://gre/modules/DownloadUIHelper.jsm",
   DownloadUtils: "resource://gre/modules/DownloadUtils.jsm",
   OS: "resource://gre/modules/osfile.jsm",
 });
 
 XPCOMUtils.defineLazyGetter(this, "DownloadsLogger", () => {
-  let { ConsoleAPI } = Cu.import("resource://gre/modules/Console.jsm", {});
+  let { ConsoleAPI } =
+    ChromeUtils.import("resource://gre/modules/Console.jsm", {});
   let consoleOptions = {
     maxLogLevelPref: "browser.download.loglevel",
     prefix: "Downloads"
   };
   return new ConsoleAPI(consoleOptions);
 });
 
 const kDownloadsStringBundleUrl =
@@ -180,19 +183,21 @@ var DownloadsCommon = {
     }
     return DownloadsData;
   },
 
   /**
    * Initializes the Downloads Manager common code.
    */
   init() {
-    Cu.import("resource://gre/modules/Downloads.jsm");
-    Cu.import("resource://gre/modules/DownloadIntegration.jsm");
-    DownloadIntegration.shouldPersistDownload = function() { return true; }
+    const { DownloadsData } =
+      ChromeUtils.import("resource://gre/modules/Downloads.jsm");
+    const { DownloadIntegration } =
+        ChromeUtils.import("resource://gre/modules/DownloadIntegration.jsm");
+    DownloadIntegration.shouldPersistDownload = function() { return true; };
     DownloadsData.initializeDataLink();
   },
 
   /**
    * Returns the legacy state integer value for the provided Download object.
    */
   stateOfDownload(download) {
     // Collapse state using the correct priority.
--- a/suite/components/downloads/DownloadsTaskbar.jsm
+++ b/suite/components/downloads/DownloadsTaskbar.jsm
@@ -3,22 +3,22 @@
  * 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/. */
 
 var EXPORTED_SYMBOLS = [
   "DownloadsTaskbar",
 ];
 
-const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { XPCOMUtils } =
+  ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "Downloads",
-                               "resource://gre/modules/Downloads.jsm");
-ChromeUtils.defineModuleGetter(this, "Services",
-                               "resource://gre/modules/Services.jsm");
+  "resource://gre/modules/Downloads.jsm");
 
 XPCOMUtils.defineLazyGetter(this, "gWinTaskbar", function() {
   if (!("@mozilla.org/windows-taskbar;1" in Cc)) {
     return null;
   }
   let winTaskbar = Cc["@mozilla.org/windows-taskbar;1"]
                      .getService(Ci.nsIWinTaskbar);
   return winTaskbar.available && winTaskbar;
--- a/suite/components/helpviewer/content/contextHelp.js
+++ b/suite/components/helpviewer/content/contextHelp.js
@@ -1,16 +1,15 @@
 /* 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/. */
 
-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var { AppConstants } = ChromeUtils.import(
-  "resource://gre/modules/AppConstants.jsm"
-);
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { AppConstants } =
+  ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 // Set the default content pack to the Mozilla content pack. Use the
 // setHelpFileURI function to set this value.
 var helpFileURI;
 
 // openHelp - Opens up the Mozilla Help Viewer with the specified
 //    topic and content pack.
 // see http://www.mozilla.org/projects/help-viewer/content_packs.html
--- a/suite/components/helpviewer/content/help.js
+++ b/suite/components/helpviewer/content/help.js
@@ -1,17 +1,15 @@
 /* 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/. */
 
-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
-var {AppConstants} = ChromeUtils.import(
-  "resource://gre/modules/AppConstants.jsm"
-);
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { AppConstants } =
+  ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 // Global Variables
 var helpExternal;
 var helpBrowser;
 var helpSearchPanel;
 var emptySearch;
 var emptySearchText;
 var emptySearchLink = "about:blank";
--- a/suite/components/migration/SuiteProfileMigrator.js
+++ b/suite/components/migration/SuiteProfileMigrator.js
@@ -1,19 +1,22 @@
 /* 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";
 
-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-const {FileUtils} = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
-const {AppConstants} = ChromeUtils.import('resource://gre/modules/AppConstants.jsm');
-+
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { XPCOMUtils } =
+  ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+const { FileUtils } =
+  ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
+const { AppConstants } =
+  ChromeUtils.import('resource://gre/modules/AppConstants.jsm');
+
 ChromeUtils.defineModuleGetter(this, "FileUtils",
   "resource://gre/modules/FileUtils.jsm");
 
 function ProfileMigrator() {
 }
 
 ProfileMigrator.prototype = {
   migrate: function PM_migrate(aStartup) {
--- a/suite/components/places/content/controller.js
+++ b/suite/components/places/content/controller.js
@@ -1,13 +1,15 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* 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/. */
 
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+
 /**
  * Represents an insertion point within a container where we can insert
  * items.
  * @param {object} an object containing the following properties:
  *   - parentId
  *     The identifier of the parent container
  *   - parentGuid
  *     The unique identifier of the parent container
--- a/suite/components/places/content/places.js
+++ b/suite/components/places/content/places.js
@@ -1,30 +1,30 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* 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/. */
 
 /* import-globals-from editBookmarkOverlay.js */
 /* import-globals-from ../../../../../toolkit/content/contentAreaUtils.js */
 
-var {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var { AppConstants } =
+  ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 ChromeUtils.defineModuleGetter(this, "MigrationUtils",
-                               "resource:///modules/MigrationUtils.jsm");
+  "resource:///modules/MigrationUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "BookmarkJSONUtils",
-                               "resource://gre/modules/BookmarkJSONUtils.jsm");
+  "resource://gre/modules/BookmarkJSONUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "PlacesBackups",
-                               "resource://gre/modules/PlacesBackups.jsm");
+  "resource://gre/modules/PlacesBackups.jsm");
 ChromeUtils.defineModuleGetter(this, "DownloadUtils",
-                               "resource://gre/modules/DownloadUtils.jsm");
+  "resource://gre/modules/DownloadUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "OS",
-                               "resource://gre/modules/osfile.jsm");
+  "resource://gre/modules/osfile.jsm");
 
 const RESTORE_FILEPICKER_FILTER_EXT = "*.json;*.jsonlz4";
 
 var PlacesOrganizer = {
   _places: null,
 
   // IDs of fields from editBookmarkOverlay that should be hidden when infoBox
   // is minimal. IDs should be kept in sync with the IDs of the elements
--- a/suite/components/pref/content/pref-download.js
+++ b/suite/components/pref/content/pref-download.js
@@ -1,19 +1,19 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-const {FileUtils} = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
+var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const { FileUtils } =
+  ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
-                                  "resource://gre/modules/Downloads.jsm");
+ChromeUtils.defineModuleGetter(this, "Downloads",
+  "resource://gre/modules/Downloads.jsm");
 
 const kDesktop = 0;
 const kDownloads = 1;
 const kUserDir = 2;
 var gFPHandler;
 var gSoundUrlPref;
 
 function Startup()
--- a/suite/modules/Feeds.jsm
+++ b/suite/modules/Feeds.jsm
@@ -3,21 +3,18 @@
 /* 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";
 
 var EXPORTED_SYMBOLS = [ "Feeds" ];
 
-const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetters(this, {
-  BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
-});
+ChromeUtils.defineModuleGetter(this, "BrowserUtils",
+  "resource://gre/modules/BrowserUtils.jsm");
 
 var Feeds = {
 
   /**
    * isValidFeed: checks whether the given data represents a valid feed.
    *
    * @param  aLink
    *         An object representing a feed with title, href and type.
--- a/suite/modules/Sanitizer.jsm
+++ b/suite/modules/Sanitizer.jsm
@@ -181,18 +181,16 @@ var Sanitizer = {
         } catch (e) {}
       },
 
       canClear: true
     },
 
     history: {
       clear: function() {
-        const {PlacesUtils} = ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm");
-
         // use try/catch for everything but the last task so we clear as much as possible
         try {
           PlacesUtils.history.clear();
         } catch(ex) {}
 
         try {
           Services.obs.notifyObservers(null, "browser:purge-session-history");
         } catch(ex) {}