Bug 1447154 - Use AppConstants.jsm instead of devtools/shared/system to get constants;r=jryans,nchevobbe
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 19 Mar 2018 22:18:20 +0100
changeset 408997 0500c3c587140e787272da07346380c98245c5e2
parent 408996 d5f46438881b8110515c568a67b92697f029812f
child 408998 28088e11bfc458d12e809b79628d4c2dd942bd83
push id33671
push usercsabou@mozilla.com
push dateTue, 20 Mar 2018 22:23:32 +0000
treeherdermozilla-central@e2e874ceae78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans, nchevobbe
bugs1447154
milestone61.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 1447154 - Use AppConstants.jsm instead of devtools/shared/system to get constants;r=jryans,nchevobbe devtools/shared/system is a complex module retrieving details device/platform information. Modules that only need to get AppConstants should not pull down such a complex dependency. MozReview-Commit-ID: 2FmCO8nBSpP
devtools/client/framework/ToolboxProcess.jsm
devtools/client/framework/toolbox-hosts.js
devtools/client/framework/toolbox-options.js
devtools/client/inspector/rules/test/browser_rules_edit-property-increments.js
devtools/client/shared/inplace-editor.js
devtools/client/shared/webpack/shims/app-constants-stub.js
devtools/client/shared/webpack/shims/system-stub.js
devtools/client/webconsole/new-webconsole.js
devtools/client/webconsole/webconsole.js
devtools/client/webconsole/webpack.config.js
devtools/shared/system.js
--- a/devtools/client/framework/ToolboxProcess.jsm
+++ b/devtools/client/framework/ToolboxProcess.jsm
@@ -8,25 +8,25 @@
 
 const DBG_XUL = "chrome://devtools/content/framework/toolbox-process-window.xul";
 const CHROME_DEBUGGER_PROFILE_NAME = "chrome_debugger_profile";
 
 const { require, DevToolsLoader } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
 const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.defineModuleGetter(this, "Subprocess", "resource://gre/modules/Subprocess.jsm");
+ChromeUtils.defineModuleGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm");
+
 XPCOMUtils.defineLazyGetter(this, "Telemetry", function() {
   return require("devtools/client/shared/telemetry");
 });
 XPCOMUtils.defineLazyGetter(this, "EventEmitter", function() {
   return require("devtools/shared/event-emitter");
 });
-XPCOMUtils.defineLazyGetter(this, "system", function() {
-  return require("devtools/shared/system");
-});
+
 const promise = require("promise");
 const Services = require("Services");
 
 this.EXPORTED_SYMBOLS = ["BrowserToolboxProcess"];
 
 var processes = new Set();
 
 /**
@@ -284,17 +284,17 @@ BrowserToolboxProcess.prototype = {
 
     // During local development, incremental builds can trigger the main process
     // to clear its startup cache with the "flag file" .purgecaches, but this
     // file is removed during app startup time, so we aren't able to know if it
     // was present in order to also clear the child profile's startup cache as
     // well.
     //
     // As an approximation of "isLocalBuild", check for an unofficial build.
-    if (!system.constants.MOZILLA_OFFICIAL) {
+    if (!AppConstants.MOZILLA_OFFICIAL) {
       args.push("-purgecaches");
     }
 
     this._dbgProcessPromise = Subprocess.call({
       command,
       arguments: args,
       environmentAppend: true,
       stderr: "stdout",
--- a/devtools/client/framework/toolbox-hosts.js
+++ b/devtools/client/framework/toolbox-hosts.js
@@ -7,17 +7,17 @@
 "use strict";
 
 const EventEmitter = require("devtools/shared/event-emitter");
 const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const Services = require("Services");
 const {DOMHelpers} = require("resource://devtools/client/shared/DOMHelpers.jsm");
 
-loader.lazyRequireGetter(this, "system", "devtools/shared/system");
+loader.lazyRequireGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm", true);
 loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
 
 /* A host should always allow this much space for the page to be displayed.
  * There is also a min-height on the browser, but we still don't want to set
  * frame.height to be larger than that, since it can cause problems with
  * resizing the toolbox and panel layout. */
 const MIN_PAGE_SIZE = 25;
 
@@ -290,17 +290,17 @@ WindowHost.prototype = {
     let win = Services.ww.openWindow(null, this.WINDOW_URL, "_blank",
                                      flags, null);
 
     let frameLoad = () => {
       win.removeEventListener("load", frameLoad, true);
       win.focus();
 
       let key;
-      if (system.constants.platform === "macosx") {
+      if (AppConstants.platform === "macosx") {
         key = win.document.getElementById("toolbox-key-toggle-osx");
       } else {
         key = win.document.getElementById("toolbox-key-toggle");
       }
       key.removeAttribute("disabled");
 
       this.frame = win.document.getElementById("toolbox-iframe");
       this.emit("ready", this.frame);
--- a/devtools/client/framework/toolbox-options.js
+++ b/devtools/client/framework/toolbox-options.js
@@ -6,17 +6,17 @@
 
 const Services = require("Services");
 const defer = require("devtools/shared/defer");
 const {gDevTools} = require("devtools/client/framework/devtools");
 
 const {LocalizationHelper} = require("devtools/shared/l10n");
 const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
 
-loader.lazyRequireGetter(this, "system", "devtools/shared/system");
+loader.lazyRequireGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm", true);
 
 exports.OptionsPanel = OptionsPanel;
 
 function GetPref(name) {
   let type = Services.prefs.getPrefType(name);
   switch (type) {
     case Services.prefs.PREF_STRING:
       return Services.prefs.getCharPref(name);
@@ -305,17 +305,17 @@ OptionsPanel.prototype = {
 
     this.updateCurrentTheme();
   },
 
   /**
    * Add common preferences enabled only on Nightly.
    */
   setupNightlyOptions: function() {
-    let isNightly = system.constants.NIGHTLY_BUILD;
+    let isNightly = AppConstants.NIGHTLY_BUILD;
     if (!isNightly) {
       return;
     }
 
     // Labels for these new buttons are nightly only and mostly intended for working on
     // devtools.
     let prefDefinitions = [{
       pref: "devtools.webconsole.new-frontend-enabled",
--- a/devtools/client/inspector/rules/test/browser_rules_edit-property-increments.js
+++ b/devtools/client/inspector/rules/test/browser_rules_edit-property-increments.js
@@ -5,17 +5,17 @@
 "use strict";
 
 // Test that increasing/decreasing values in rule view using
 // arrow keys works correctly.
 
 // Bug 1275446 - This test happen to hit the default timeout on linux32
 requestLongerTimeout(2);
 
-loader.lazyRequireGetter(this, "system", "devtools/shared/system");
+loader.lazyRequireGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm", true);
 
 const TEST_URI = `
   <style>
     #test {
       margin-top: 0px;
       padding-top: 0px;
       color: #000000;
       background-color: #000000;
@@ -289,17 +289,17 @@ function* testIncrement(editor, options,
   key = options.down ? "VK_DOWN" : "VK_UP";
   if (options.pageDown) {
     key = "VK_PAGE_DOWN";
   } else if (options.pageUp) {
     key = "VK_PAGE_UP";
   }
 
   let smallIncrementKey = {ctrlKey: options.ctrl};
-  if (system.constants.platform === "macosx") {
+  if (AppConstants.platform === "macosx") {
     smallIncrementKey = {altKey: options.alt};
   }
 
   EventUtils.synthesizeKey(key, {...smallIncrementKey, shiftKey: options.shift},
     view.styleWindow);
 
   yield onKeyUp;
 
@@ -308,13 +308,13 @@ function* testIncrement(editor, options,
     view.debounce.flush();
     yield onRuleViewChanged;
   }
 
   is(input.value, options.end, "Value changed to " + options.end);
 }
 
 function getSmallIncrementKey() {
-  if (system.constants.platform === "macosx") {
+  if (AppConstants.platform === "macosx") {
     return { alt: true };
   }
   return { ctrl: true };
 }
--- a/devtools/client/shared/inplace-editor.js
+++ b/devtools/client/shared/inplace-editor.js
@@ -22,17 +22,17 @@
  */
 
 "use strict";
 
 const Services = require("Services");
 const focusManager = Services.focus;
 const {KeyCodes} = require("devtools/client/shared/keycodes");
 
-loader.lazyRequireGetter(this, "system", "devtools/shared/system");
+loader.lazyRequireGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm", true);
 
 const HTML_NS = "http://www.w3.org/1999/xhtml";
 const CONTENT_TYPES = {
   PLAIN_TEXT: 0,
   CSS_VALUE: 1,
   CSS_MIXED: 2,
   CSS_PROPERTY: 3,
 };
@@ -1204,17 +1204,17 @@ InplaceEditor.prototype = {
     this.popup.hidePopup();
   },
 
   /**
    * Get the increment/decrement step to use for the provided key event.
    */
   _getIncrement: function(event) {
     const getSmallIncrementKey = (evt) => {
-      if (system.constants.platform === "macosx") {
+      if (AppConstants.platform === "macosx") {
         return evt.altKey;
       }
       return evt.ctrlKey;
     };
 
     const largeIncrement = 100;
     const mediumIncrement = 10;
     const smallIncrement = 0.1;
rename from devtools/client/shared/webpack/shims/system-stub.js
rename to devtools/client/shared/webpack/shims/app-constants-stub.js
--- a/devtools/client/shared/webpack/shims/system-stub.js
+++ b/devtools/client/shared/webpack/shims/app-constants-stub.js
@@ -6,12 +6,12 @@
 
 var platform = "";
 
 if (/Mac OS X/.test(window.navigator.userAgent)) {
   platform = "macosx";
 }
 
 module.exports = {
-  constants: {
-    platform: platform
+  AppConstants: {
+    platform
   }
 };
--- a/devtools/client/webconsole/new-webconsole.js
+++ b/devtools/client/webconsole/new-webconsole.js
@@ -11,17 +11,19 @@ const EventEmitter = require("devtools/s
 const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const Services = require("Services");
 const { gDevTools } = require("devtools/client/framework/devtools");
 const { JSTerm } = require("devtools/client/webconsole/jsterm");
 const { WebConsoleConnectionProxy } = require("devtools/client/webconsole/webconsole-connection-proxy");
 const KeyShortcuts = require("devtools/client/shared/key-shortcuts");
 const { l10n } = require("devtools/client/webconsole/new-console-output/utils/messages");
-const system = require("devtools/shared/system");
+
+loader.lazyRequireGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm", true);
+
 const ZoomKeys = require("devtools/client/shared/zoom-keys");
 
 const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages";
 const PREF_PERSISTLOG = "devtools.webconsole.persistlog";
 const PREF_SIDEBAR_ENABLED = "devtools.webconsole.sidebarToggle";
 
 // XXX: This file is incomplete (see bug 1326937).
 // It's used when loading the webconsole with devtools-launchpad, but will ultimately be
@@ -235,31 +237,31 @@ NewWebConsoleFrame.prototype = {
 
     shortcuts.on(l10n.getStr("webconsole.find.key"),
                  event => {
                    this.filterBox.focus();
                    event.preventDefault();
                  });
 
     let clearShortcut;
-    if (system.constants.platform === "macosx") {
+    if (AppConstants.platform === "macosx") {
       clearShortcut = l10n.getStr("webconsole.clear.keyOSX");
     } else {
       clearShortcut = l10n.getStr("webconsole.clear.key");
     }
 
     shortcuts.on(clearShortcut, () => this.jsterm.clearOutput(true));
 
     if (this.isBrowserConsole) {
       shortcuts.on(l10n.getStr("webconsole.close.key"),
                    this.window.top.close.bind(this.window.top));
 
       ZoomKeys.register(this.window);
 
-      if (!system.constants.MOZILLA_OFFICIAL) {
+      if (!AppConstants.MOZILLA_OFFICIAL) {
         // In local builds, inject the "quick restart" shortcut.
         // This script expects to have Services on the global and we haven't yet imported
         // it into the window, so assign it.
         this.window.Services = Services;
         Services.scriptloader.loadSubScript(
           "chrome://browser/content/browser-development-helpers.js", this.window);
         shortcuts.on("CmdOrCtrl+Alt+R", this.window.DevelopmentHelpers.quickRestart);
       }
--- a/devtools/client/webconsole/webconsole.js
+++ b/devtools/client/webconsole/webconsole.js
@@ -20,22 +20,22 @@ const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const Services = require("Services");
 const Telemetry = require("devtools/client/shared/telemetry");
 const {PrefObserver} = require("devtools/client/shared/prefs");
 
 loader.lazyServiceGetter(this, "clipboardHelper",
                          "@mozilla.org/widget/clipboardhelper;1",
                          "nsIClipboardHelper");
+loader.lazyRequireGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm", true);
 loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
 loader.lazyRequireGetter(this, "ConsoleOutput", "devtools/client/webconsole/console-output", true);
 loader.lazyRequireGetter(this, "Messages", "devtools/client/webconsole/console-output", true);
 loader.lazyRequireGetter(this, "EnvironmentClient", "devtools/shared/client/environment-client");
 loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/object-client");
-loader.lazyRequireGetter(this, "system", "devtools/shared/system");
 loader.lazyRequireGetter(this, "JSTerm", "devtools/client/webconsole/jsterm", true);
 loader.lazyRequireGetter(this, "gSequenceId", "devtools/client/webconsole/jsterm", true);
 loader.lazyImporter(this, "VariablesView", "resource://devtools/client/shared/widgets/VariablesView.jsm");
 loader.lazyImporter(this, "VariablesViewController", "resource://devtools/client/shared/widgets/VariablesViewController.jsm");
 loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
 loader.lazyRequireGetter(this, "KeyShortcuts", "devtools/client/shared/key-shortcuts");
 loader.lazyRequireGetter(this, "ZoomKeys", "devtools/client/shared/zoom-keys");
 loader.lazyRequireGetter(this, "WebConsoleConnectionProxy", "devtools/client/webconsole/webconsole-connection-proxy", true);
@@ -637,17 +637,17 @@ WebConsoleFrame.prototype = {
 
     shortcuts.on(l10n.getStr("webconsole.find.key"),
                  event => {
                    this.filterBox.focus();
                    event.preventDefault();
                  });
 
     let clearShortcut;
-    if (system.constants.platform === "macosx") {
+    if (AppConstants.platform === "macosx") {
       clearShortcut = l10n.getStr("webconsole.clear.keyOSX");
     } else {
       clearShortcut = l10n.getStr("webconsole.clear.key");
     }
     shortcuts.on(clearShortcut,
                  () => this.jsterm.clearOutput(true));
 
     if (this.isBrowserConsole) {
--- a/devtools/client/webconsole/webpack.config.js
+++ b/devtools/client/webconsole/webpack.config.js
@@ -82,17 +82,17 @@ webpackConfig.resolve = {
 
     "devtools/client/shared/vendor/immutable": "immutable",
     "devtools/client/shared/vendor/react": "react",
     "devtools/client/shared/vendor/react-dom": "react-dom",
     "devtools/client/shared/vendor/react-redux": "react-redux",
     "devtools/client/shared/vendor/redux": "redux",
     "devtools/client/shared/vendor/reselect": "reselect",
 
-    "devtools/shared/system": path.join(__dirname, "../../client/shared/webpack/shims/system-stub"),
+    "resource://gre/modules/AppConstants.jsm": path.join(__dirname, "../../client/shared/webpack/shims/app-constants-stub"),
 
     "devtools/client/framework/devtools": path.join(__dirname, "../../client/shared/webpack/shims/framework-devtools-shim"),
     "devtools/client/framework/menu": "devtools-modules/src/menu",
     "devtools/client/sourceeditor/editor": "devtools-source-editor/src/source-editor",
 
     "devtools/client/shared/zoom-keys": "devtools-modules/src/zoom-keys",
 
     "devtools/shared/fronts/timeline": path.join(__dirname, "../../client/shared/webpack/shims/fronts-timeline-shim"),
--- a/devtools/shared/system.js
+++ b/devtools/shared/system.js
@@ -288,9 +288,8 @@ function getSetting(name) {
     deferred.reject(new Error("No settings service"));
   }
   return deferred.promise;
 }
 
 exports.getSystemInfo = getSystemInfo;
 exports.getSetting = getSetting;
 exports.getScreenDimensions = getScreenDimensions;
-exports.constants = AppConstants;