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

--HG--
rename : devtools/client/shared/webpack/shims/system-stub.js => devtools/client/shared/webpack/shims/app-constants-stub.js
extra : rebase_source : 0ec5e4d320c8b1543d5fe579d8adf51c5fa4286d
This commit is contained in:
Julian Descottes 2018-03-19 22:18:20 +01:00
parent 20047883ca
commit f960ea774c
10 changed files with 23 additions and 22 deletions

View File

@ -13,15 +13,15 @@ const { require, DevToolsLoader } = ChromeUtils.import("resource://devtools/shar
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");
@ -289,7 +289,7 @@ BrowserToolboxProcess.prototype = {
// well.
//
// As an approximation of "isLocalBuild", check for an unofficial build.
if (!system.constants.MOZILLA_OFFICIAL) {
if (!AppConstants.MOZILLA_OFFICIAL) {
args.push("-purgecaches");
}

View File

@ -12,7 +12,7 @@ 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.
@ -295,7 +295,7 @@ WindowHost.prototype = {
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");

View File

@ -11,7 +11,7 @@ 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;
@ -310,7 +310,7 @@ OptionsPanel.prototype = {
* Add common preferences enabled only on Nightly.
*/
setupNightlyOptions: function() {
let isNightly = system.constants.NIGHTLY_BUILD;
let isNightly = AppConstants.NIGHTLY_BUILD;
if (!isNightly) {
return;
}

View File

@ -10,7 +10,7 @@
// 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>
@ -294,7 +294,7 @@ function* testIncrement(editor, options, view) {
}
let smallIncrementKey = {ctrlKey: options.ctrl};
if (system.constants.platform === "macosx") {
if (AppConstants.platform === "macosx") {
smallIncrementKey = {altKey: options.alt};
}
@ -313,7 +313,7 @@ function* testIncrement(editor, options, view) {
}
function getSmallIncrementKey() {
if (system.constants.platform === "macosx") {
if (AppConstants.platform === "macosx") {
return { alt: true };
}
return { ctrl: true };

View File

@ -27,7 +27,7 @@ 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 = {
@ -1209,7 +1209,7 @@ InplaceEditor.prototype = {
*/
_getIncrement: function(event) {
const getSmallIncrementKey = (evt) => {
if (system.constants.platform === "macosx") {
if (AppConstants.platform === "macosx") {
return evt.altKey;
}
return evt.ctrlKey;

View File

@ -11,7 +11,7 @@ if (/Mac OS X/.test(window.navigator.userAgent)) {
}
module.exports = {
constants: {
platform: platform
AppConstants: {
platform
}
};

View File

@ -16,7 +16,9 @@ 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";
@ -240,7 +242,7 @@ NewWebConsoleFrame.prototype = {
});
let clearShortcut;
if (system.constants.platform === "macosx") {
if (AppConstants.platform === "macosx") {
clearShortcut = l10n.getStr("webconsole.clear.keyOSX");
} else {
clearShortcut = l10n.getStr("webconsole.clear.key");
@ -254,7 +256,7 @@ NewWebConsoleFrame.prototype = {
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.

View File

@ -25,12 +25,12 @@ 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");
@ -642,7 +642,7 @@ WebConsoleFrame.prototype = {
});
let clearShortcut;
if (system.constants.platform === "macosx") {
if (AppConstants.platform === "macosx") {
clearShortcut = l10n.getStr("webconsole.clear.keyOSX");
} else {
clearShortcut = l10n.getStr("webconsole.clear.key");

View File

@ -87,7 +87,7 @@ webpackConfig.resolve = {
"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",

View File

@ -293,4 +293,3 @@ function getSetting(name) {
exports.getSystemInfo = getSystemInfo;
exports.getSetting = getSetting;
exports.getScreenDimensions = getScreenDimensions;
exports.constants = AppConstants;