Bug 1230369 - Manually fix some remaining instances of Ci/Cc/Cu definitions and switch Components.* to using the shorthand in some places. r=florian
authorMark Banner <standard8@mozilla.com>
Wed, 07 Feb 2018 09:24:15 +0000
changeset 402799 76c1582d760e117d1ce2befbc2af998c24760231
parent 402798 04244826251464b44170d17b066a322c4c45d654
child 402800 f58c1a70c026749c97d3df1bd9a22d2473c1c056
push id99659
push useraciure@mozilla.com
push dateWed, 07 Feb 2018 22:33:57 +0000
treeherdermozilla-inbound@5ceb1098fef3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1230369
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1230369 - Manually fix some remaining instances of Ci/Cc/Cu definitions and switch Components.* to using the shorthand in some places. r=florian MozReview-Commit-ID: 9SmoR9RlvZE
browser/base/content/test/general/browser_bug567306.js
browser/components/preferences/in-content/main.js
chrome/test/unit/test_abi.js
mobile/android/chrome/content/aboutAddons.js
mobile/android/chrome/content/aboutLogins.js
testing/xpcshell/dbg-actors.js
toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
toolkit/components/reader/AboutReader.jsm
toolkit/modules/PopupNotifications.jsm
toolkit/modules/Promise-backend.js
tools/code-coverage/tests/xpcshell/test_basic_child_and_parent.js
tools/quitter/QuitterObserver.js
--- a/browser/base/content/test/general/browser_bug567306.js
+++ b/browser/base/content/test/general/browser_bug567306.js
@@ -1,14 +1,12 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-var {Ci: interfaces, Cc: classes} = Components;
-
 var HasFindClipboard = Services.clipboard.supportsFindClipboard();
 
 add_task(async function() {
   let newwindow = await BrowserTestUtils.openNewBrowserWindow();
 
   let selectedBrowser = newwindow.gBrowser.selectedBrowser;
   await new Promise((resolve, reject) => {
     BrowserTestUtils.waitForContentEvent(selectedBrowser, "pageshow", true, (event) => {
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -678,17 +678,16 @@ var gMainPane = {
       let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
       let button_index = confirmRestartPrompt(separateProfileModeCheckbox.checked,
         0, false, true);
       switch (button_index) {
         case CONFIRM_RESTART_PROMPT_CANCEL:
           revertCheckbox();
           return;
         case CONFIRM_RESTART_PROMPT_RESTART_NOW:
-          const Cc = Components.classes, Ci = Components.interfaces;
           let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
             .createInstance(Ci.nsISupportsPRBool);
           Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
             "restart");
           if (!cancelQuit.data) {
             createOrRemoveSpecialDevEditionFile(quitApp);
             return;
           }
@@ -881,21 +880,18 @@ var gMainPane = {
     let prefName = "pref.browser.homepage.disable_button.current_page";
     if (Preferences.get(prefName).locked)
       return;
 
     useCurrent.disabled = !tabs.length;
   },
 
   _getTabsForHomePage() {
-    var win;
     var tabs = [];
-
-    const Cc = Components.classes, Ci = Components.interfaces;
-    win = Services.wm.getMostRecentWindow("navigator:browser");
+    var win = Services.wm.getMostRecentWindow("navigator:browser");
 
     if (win && win.document.documentElement
       .getAttribute("windowtype") == "navigator:browser") {
       // We should only include visible & non-pinned tabs
 
       tabs = win.gBrowser.visibleTabs.slice(win.gBrowser._numPinnedTabs);
       tabs = tabs.filter(this.isNotAboutPreferences);
     }
--- a/chrome/test/unit/test_abi.js
+++ b/chrome/test/unit/test_abi.js
@@ -3,18 +3,18 @@ updateAppInfo({
   name: "XPCShell",
   ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
   version: "5",
   platformVersion: "1.9",
 });
 
 registerManifests([do_get_file("data/test_abi.manifest")]);
 
-const catman = Components.classes["@mozilla.org/categorymanager;1"].
-  getService(Components.interfaces.nsICategoryManager);
+const catman = Cc["@mozilla.org/categorymanager;1"].
+  getService(Ci.nsICategoryManager);
 
 function is_registered(name) {
   try {
     var d = catman.getCategoryEntry("abitest", name);
     return d == "found";
   } catch (e) {
     return false;
   }
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -1,18 +1,16 @@
 /* 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";
 
 /* globals gChromeWin */
 
-var Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
-
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const AMO_ICON = "chrome://browser/skin/images/amo-logo.png";
 const UPDATE_INDICATOR = "chrome://browser/skin/images/extension-update.svg";
 
 var gStringBundle = Services.strings.createBundle("chrome://browser/locale/aboutAddons.properties");
--- a/mobile/android/chrome/content/aboutLogins.js
+++ b/mobile/android/chrome/content/aboutLogins.js
@@ -1,14 +1,12 @@
 /* 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 Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
-
 ChromeUtils.import("resource://services-common/utils.js"); /* global: CommonUtils */
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/TelemetryStopwatch.jsm");
 
 XPCOMUtils.defineLazyGetter(window, "gChromeWin", () =>
   window.QueryInterface(Ci.nsIInterfaceRequestor)
     .getInterface(Ci.nsIWebNavigation)
--- a/testing/xpcshell/dbg-actors.js
+++ b/testing/xpcshell/dbg-actors.js
@@ -2,16 +2,17 @@
  * 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";
 
 /* import-globals-from ../../devtools/server/main.js */
 /* eslint "mozilla/use-chromeutils-import": ["error", {allowCu: true}] */
 
+// eslint-disable-next-line mozilla/no-define-cc-etc
 const Cu = Components.utils;
 const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
 var { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
 const { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
 const { RootActor } = devtools.require("devtools/server/actors/root");
 const { BrowserTabList } = devtools.require("devtools/server/actors/webbrowser");
 
 /**
--- a/toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
+++ b/toolkit/components/osfile/modules/osfile_shared_allthreads.jsm
@@ -17,22 +17,16 @@
  * - a few additional utilities.
  */
 
 /* eslint-env worker */
 
 // Boilerplate used to be able to import this module both from the main
 // thread and from worker threads.
 
-// Since const is lexically scoped, hoist the
-// conditionally-useful definition ourselves.
-const Cu = typeof Components != "undefined" ? Components.utils : undefined;
-const Ci = typeof Components != "undefined" ? Components.interfaces : undefined;
-const Cc = typeof Components != "undefined" ? Components.classes : undefined;
-
 /**
  * A constructor for messages that require transfers instead of copies.
  *
  * See BasePromiseWorker.Meta.
  *
  * @constructor
  */
 var Meta;
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -1,16 +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/. */
 
 "use strict";
 
-var Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
-
 this.EXPORTED_SYMBOLS = [ "AboutReader" ];
 
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/ReaderMode.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "AsyncPrefs", "resource://gre/modules/AsyncPrefs.jsm");
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -1,16 +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/. */
 
 this.EXPORTED_SYMBOLS = ["PopupNotifications"];
 
-var Cc = Components.classes, Ci = Components.interfaces, Cu = Components.utils;
-
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
 
 const NOTIFICATION_EVENT_DISMISSED = "dismissed";
 const NOTIFICATION_EVENT_REMOVED = "removed";
 const NOTIFICATION_EVENT_SHOWING = "showing";
 const NOTIFICATION_EVENT_SHOWN = "shown";
--- a/toolkit/modules/Promise-backend.js
+++ b/toolkit/modules/Promise-backend.js
@@ -39,19 +39,21 @@
 // that Components is not defined in worker threads, so no instance of Cu can
 // be obtained.
 
 // As this can be loaded in several ways, allow require and module to be defined.
 /* global module:false require:false */
 // This is allowed in workers.
 /* global setImmediate:false */
 
+/* eslint-disable mozilla/no-define-cc-etc */
 var Cu = this.require ? require("chrome").Cu : Components.utils;
 var Cc = this.require ? require("chrome").Cc : Components.classes;
 var Ci = this.require ? require("chrome").Ci : Components.interfaces;
+/* eslint-enable mozilla/no-define-cc-etc */
 // If we can access Components, then we use it to capture an async
 // parent stack trace; see scheduleWalkerLoop.  However, as it might
 // not be available (see above), users of this must check it first.
 var Components_ = this.require ? require("chrome").components : Components;
 
 // If Cu is defined, use it to lazily define the FinalizationWitnessService.
 if (Cu) {
   // If we're in a devtools module environment, ChromeUtils won't exist.
--- a/tools/code-coverage/tests/xpcshell/test_basic_child_and_parent.js
+++ b/tools/code-coverage/tests/xpcshell/test_basic_child_and_parent.js
@@ -2,16 +2,16 @@
  * 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/. */
 
 function run_test() {
   do_load_child_test_harness();
   do_test_pending();
 
   sendCommand("let v = 'test';", function() {
-      let codeCoverage = Components.classes["@mozilla.org/tools/code-coverage;1"].getService(Components.interfaces.nsICodeCoverage);
+      let codeCoverage = Cc["@mozilla.org/tools/code-coverage;1"].getService(Ci.nsICodeCoverage);
 
       codeCoverage.dumpCounters();
       codeCoverage.resetCounters();
 
       do_test_finished();
   });
 }
--- a/tools/quitter/QuitterObserver.js
+++ b/tools/quitter/QuitterObserver.js
@@ -9,17 +9,17 @@ const CHILD_SCRIPT = "chrome://quitter/c
 
 /* XPCOM gunk */
 function QuitterObserver() {}
 
 QuitterObserver.prototype = {
   classDescription: "Quitter Observer for use in testing.",
   classID:          Components.ID("{c235a986-5ac1-4f28-ad73-825dae9bad90}"),
   contractID:       "@mozilla.org/quitter-observer;1",
-  QueryInterface:   XPCOMUtils.generateQI([Components.interfaces.nsIObserver]),
+  QueryInterface:   XPCOMUtils.generateQI([Ci.nsIObserver]),
   _xpcom_categories: [{category: "profile-after-change", service: true }],
   isFrameScriptLoaded: false,
 
   observe(aSubject, aTopic, aData) {
     if (aTopic == "profile-after-change") {
       this.init();
     } else if (!this.isFrameScriptLoaded &&
                aTopic == "chrome-document-global-created") {