From 6e6be1052684002f455217d59dd1321cc6571974 Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Tue, 10 Nov 2020 15:14:07 +0000 Subject: [PATCH] Bug 1675769 - [devtools] Remove usage of devtools-environment isTesting. r=bomsy. When possible, we switch to the plain devtools/shared/flags module. In some cases, the check was only done for jest test, so we use isNodeTest instead. Differential Revision: https://phabricator.services.mozilla.com/D96382 --- .../client/debugger/bin/module-manifest.json | 6 ++--- .../configs/mozilla-central-mappings.js | 1 - .../client/debugger/dist/search-worker.js | 24 ++++--------------- devtools/client/debugger/dist/vendors.js | 24 ++++--------------- .../packages/devtools-environment/README.md | 1 - .../packages/devtools-environment/index.js | 7 ------ .../client/debugger/src/actions/preview.js | 4 ++-- .../src/actions/utils/middleware/log.js | 5 ++-- .../client/debugger/src/test/tests-setup.js | 3 --- .../client/debugger/src/utils/bootstrap.js | 5 ++-- .../client/shared/build/build-debugger.js | 1 - 11 files changed, 21 insertions(+), 60 deletions(-) diff --git a/devtools/client/debugger/bin/module-manifest.json b/devtools/client/debugger/bin/module-manifest.json index 38c7ba204b71..7d50a4fae63e 100644 --- a/devtools/client/debugger/bin/module-manifest.json +++ b/devtools/client/debugger/bin/module-manifest.json @@ -2194,7 +2194,7 @@ "byName": {}, "byBlocks": {}, "usedIds": { - "1": 1 + "0": 0 } } } @@ -2215,7 +2215,7 @@ "byName": {}, "byBlocks": {}, "usedIds": { - "1": 1 + "0": 0 } } } @@ -2236,7 +2236,7 @@ "byName": {}, "byBlocks": {}, "usedIds": { - "1": 1 + "0": 0 } } } diff --git a/devtools/client/debugger/configs/mozilla-central-mappings.js b/devtools/client/debugger/configs/mozilla-central-mappings.js index 4cff556bec15..43aee2bb8de0 100644 --- a/devtools/client/debugger/configs/mozilla-central-mappings.js +++ b/devtools/client/debugger/configs/mozilla-central-mappings.js @@ -48,7 +48,6 @@ const whatwgUrl = ` module.exports = { "./source-editor": "devtools/client/sourceeditor/editor", "../editor/source-editor": "devtools/client/sourceeditor/editor", - "./test-flag": "devtools/shared/flags", immutable: "devtools/client/shared/vendor/immutable", lodash: "devtools/client/shared/vendor/lodash", react: "devtools/client/shared/vendor/react", diff --git a/devtools/client/debugger/dist/search-worker.js b/devtools/client/debugger/dist/search-worker.js index 0e6269f23dfe..abfef8742a99 100644 --- a/devtools/client/debugger/dist/search-worker.js +++ b/devtools/client/debugger/dist/search-worker.js @@ -4,14 +4,14 @@ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("devtools/shared/flags")); + module.exports = factory(); else if(typeof define === 'function' && define.amd) - define(["devtools/shared/flags"], factory); + define([], factory); else { - var a = typeof exports === 'object' ? factory(require("devtools/shared/flags")) : factory(root["devtools/shared/flags"]); + var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } -})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_103__) { +})(typeof self !== 'undefined' ? self : this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -79,13 +79,6 @@ return /******/ (function(modules) { // webpackBootstrap /************************************************************************/ /******/ ({ -/***/ 103: -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE_103__; - -/***/ }), - /***/ 560: /***/ (function(module, exports, __webpack_require__) { @@ -886,8 +879,6 @@ module.exports = arrayMap; /* WEBPACK VAR INJECTION */(function(process) {/* 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 . */ -const flag = __webpack_require__(103); - function isNode() { return process && process.release && process.release.name == "node"; } @@ -896,14 +887,9 @@ function isNodeTest() { return isNode() && "production" != "production"; } -function isTesting() { - return flag.testing; -} - module.exports = { isNode, - isNodeTest, - isTesting + isNodeTest }; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(607))) diff --git a/devtools/client/debugger/dist/vendors.js b/devtools/client/debugger/dist/vendors.js index b2aa26f46b18..248dae5f1bcc 100644 --- a/devtools/client/debugger/dist/vendors.js +++ b/devtools/client/debugger/dist/vendors.js @@ -4,14 +4,14 @@ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(require("devtools/client/shared/vendor/react-prop-types"), require("devtools/client/shared/vendor/react-dom-factories"), require("devtools/client/shared/vendor/react"), require("devtools/shared/flags"), require("devtools/client/shared/vendor/react-dom")); + module.exports = factory(require("devtools/client/shared/vendor/react-prop-types"), require("devtools/client/shared/vendor/react-dom-factories"), require("devtools/client/shared/vendor/react"), require("devtools/client/shared/vendor/react-dom")); else if(typeof define === 'function' && define.amd) - define(["devtools/client/shared/vendor/react-prop-types", "devtools/client/shared/vendor/react-dom-factories", "devtools/client/shared/vendor/react", "devtools/shared/flags", "devtools/client/shared/vendor/react-dom"], factory); + define(["devtools/client/shared/vendor/react-prop-types", "devtools/client/shared/vendor/react-dom-factories", "devtools/client/shared/vendor/react", "devtools/client/shared/vendor/react-dom"], factory); else { - var a = typeof exports === 'object' ? factory(require("devtools/client/shared/vendor/react-prop-types"), require("devtools/client/shared/vendor/react-dom-factories"), require("devtools/client/shared/vendor/react"), require("devtools/shared/flags"), require("devtools/client/shared/vendor/react-dom")) : factory(root["devtools/client/shared/vendor/react-prop-types"], root["devtools/client/shared/vendor/react-dom-factories"], root["devtools/client/shared/vendor/react"], root["devtools/shared/flags"], root["devtools/client/shared/vendor/react-dom"]); + var a = typeof exports === 'object' ? factory(require("devtools/client/shared/vendor/react-prop-types"), require("devtools/client/shared/vendor/react-dom-factories"), require("devtools/client/shared/vendor/react"), require("devtools/client/shared/vendor/react-dom")) : factory(root["devtools/client/shared/vendor/react-prop-types"], root["devtools/client/shared/vendor/react-dom-factories"], root["devtools/client/shared/vendor/react"], root["devtools/client/shared/vendor/react-dom"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } -})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_103__, __WEBPACK_EXTERNAL_MODULE_112__) { +})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_112__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -93,13 +93,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_1__; /***/ }), -/***/ 103: -/***/ (function(module, exports) { - -module.exports = __WEBPACK_EXTERNAL_MODULE_103__; - -/***/ }), - /***/ 112: /***/ (function(module, exports) { @@ -850,8 +843,6 @@ process.umask = function() { return 0; }; /* WEBPACK VAR INJECTION */(function(process) {/* 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 . */ -const flag = __webpack_require__(103); - function isNode() { return process && process.release && process.release.name == "node"; } @@ -860,14 +851,9 @@ function isNodeTest() { return isNode() && "production" != "production"; } -function isTesting() { - return flag.testing; -} - module.exports = { isNode, - isNodeTest, - isTesting + isNodeTest }; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(607))) diff --git a/devtools/client/debugger/packages/devtools-environment/README.md b/devtools/client/debugger/packages/devtools-environment/README.md index d39c7438b211..45a1274a8f71 100644 --- a/devtools/client/debugger/packages/devtools-environment/README.md +++ b/devtools/client/debugger/packages/devtools-environment/README.md @@ -3,4 +3,3 @@ - `isNode` - is the code running in a node environment (e.g. in a jest test, or when running a node script, like bin/bundle.js). - `isNodeTest` - is the code running in a node test environment (e.g. jest test). -- `isTesting` - is the tool running in a mochitest environment diff --git a/devtools/client/debugger/packages/devtools-environment/index.js b/devtools/client/debugger/packages/devtools-environment/index.js index 1c55fafcfd83..515324c451ee 100644 --- a/devtools/client/debugger/packages/devtools-environment/index.js +++ b/devtools/client/debugger/packages/devtools-environment/index.js @@ -2,8 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at . */ -const flag = require("./test-flag"); - function isNode() { return process && process.release && process.release.name == "node"; } @@ -12,12 +10,7 @@ function isNodeTest() { return isNode() && process.env.NODE_ENV != "production"; } -function isTesting() { - return flag.testing; -} - module.exports = { isNode, isNodeTest, - isTesting, }; diff --git a/devtools/client/debugger/src/actions/preview.js b/devtools/client/debugger/src/actions/preview.js index fba2a3b48ad8..72ead222a2d2 100644 --- a/devtools/client/debugger/src/actions/preview.js +++ b/devtools/client/debugger/src/actions/preview.js @@ -9,7 +9,7 @@ import { findBestMatchExpression } from "../utils/ast"; import { getGrip, getFront } from "../utils/evaluation-result"; import { getExpressionFromCoords } from "../utils/editor/get-expression"; import { isOriginal } from "../utils/source"; -import { isTesting } from "devtools-environment"; +import { isNodeTest } from "devtools-environment"; import { getPreview, @@ -150,7 +150,7 @@ export function setPreview( // The first time a popup is rendered, the mouse should be hovered // on the token. If it happens to be hovered on whitespace, it should // not render anything - if (!target.matches(":hover") && !isTesting()) { + if (!target.matches(":hover") && !isNodeTest()) { return; } diff --git a/devtools/client/debugger/src/actions/utils/middleware/log.js b/devtools/client/debugger/src/actions/utils/middleware/log.js index 0470a300a7f8..3b688c090f0b 100644 --- a/devtools/client/debugger/src/actions/utils/middleware/log.js +++ b/devtools/client/debugger/src/actions/utils/middleware/log.js @@ -4,7 +4,8 @@ // @flow -import { isTesting } from "devtools-environment"; +// $FlowIgnore +import flags from "devtools/shared/flags"; import type { ThunkArgs } from "../../types"; import { prefs } from "../../../utils/prefs"; @@ -100,7 +101,7 @@ export function log({ dispatch, getState }: ThunkArgs) { const asyncMsg = !action.status ? "" : `[${action.status}]`; if (prefs.logActions) { - if (isTesting()) { + if (flags.testing) { // $FlowIgnore dump( `[ACTION] ${action.type} ${asyncMsg} - ${serializeAction(action)}\n` diff --git a/devtools/client/debugger/src/test/tests-setup.js b/devtools/client/debugger/src/test/tests-setup.js index 488856bef5b2..689b5ac9b6ee 100644 --- a/devtools/client/debugger/src/test/tests-setup.js +++ b/devtools/client/debugger/src/test/tests-setup.js @@ -28,9 +28,6 @@ import { } from "../workers/search"; import { clearDocuments } from "../utils/editor"; -import env from "devtools-environment/test-flag"; -env.testing = true; - const rootPath = path.join(__dirname, "../../"); Enzyme.configure({ adapter: new Adapter() }); diff --git a/devtools/client/debugger/src/utils/bootstrap.js b/devtools/client/debugger/src/utils/bootstrap.js index 6e026d55aca5..25edae505826 100644 --- a/devtools/client/debugger/src/utils/bootstrap.js +++ b/devtools/client/debugger/src/utils/bootstrap.js @@ -10,7 +10,8 @@ import ReactDOM from "react-dom"; const { Provider } = require("react-redux"); import ToolboxProvider from "devtools/client/framework/store-provider"; -import { isTesting } from "devtools-environment"; +// $FlowIgnore +import flags from "devtools/shared/flags"; // $FlowIgnore const { AppConstants } = require("resource://gre/modules/AppConstants.jsm"); @@ -44,7 +45,7 @@ export function bootstrapStore( ): any { const debugJsModules = AppConstants.DEBUG_JS_MODULES == "1"; const createStore = configureStore({ - log: prefs.logging || isTesting(), + log: prefs.logging || flags.testing, timing: debugJsModules, makeThunkArgs: (args, state) => { return { ...args, client, ...workers, panel }; diff --git a/devtools/client/shared/build/build-debugger.js b/devtools/client/shared/build/build-debugger.js index 0df713025360..1866074e720f 100644 --- a/devtools/client/shared/build/build-debugger.js +++ b/devtools/client/shared/build/build-debugger.js @@ -11,7 +11,6 @@ const _path = require("path"); const mappings = { "./source-editor": "devtools/client/shared/sourceeditor/editor", "../editor/source-editor": "devtools/client/shared/sourceeditor/editor", - "./test-flag": "devtools/shared/flags", immutable: "devtools/client/shared/vendor/immutable", lodash: "devtools/client/shared/vendor/lodash", react: "devtools/client/shared/vendor/react",