From 523c563b92ef78718e773b2af1a73c84b17c9022 Mon Sep 17 00:00:00 2001 From: tdraebing Date: Wed, 21 Dec 2016 15:21:24 +0100 Subject: [PATCH] Bug 1251728 - Make devtools/client/memory/ eslint clean. r=ntim MozReview-Commit-ID: KlM4HF81imy --- .eslintignore | 1 - devtools/client/memory/.eslintrc.js | 11 ++ .../client/memory/actions/census-display.js | 3 +- devtools/client/memory/actions/diffing.js | 13 +- devtools/client/memory/actions/io.js | 11 +- .../client/memory/actions/label-display.js | 3 +- devtools/client/memory/actions/snapshot.js | 40 +++--- .../client/memory/actions/tree-map-display.js | 3 +- devtools/client/memory/app.js | 51 ++++--- .../client/memory/components/census-header.js | 4 +- .../memory/components/census-tree-item.js | 52 +++---- devtools/client/memory/components/census.js | 7 +- .../components/dominator-tree-header.js | 6 +- .../memory/components/dominator-tree-item.js | 4 +- .../memory/components/dominator-tree.js | 16 ++- devtools/client/memory/components/heap.js | 134 +++++++++--------- .../memory/components/individuals-header.js | 6 +- .../client/memory/components/individuals.js | 9 +- devtools/client/memory/components/list.js | 4 +- .../memory/components/shortest-paths.js | 88 ++++++------ .../memory/components/snapshot-list-item.js | 21 ++- devtools/client/memory/components/toolbar.js | 3 +- devtools/client/memory/components/tree-map.js | 4 +- .../components/tree-map/canvas-utils.js | 2 +- .../memory/components/tree-map/drag-zoom.js | 1 - devtools/client/memory/constants.js | 5 +- .../memory/dominator-tree-lazy-children.js | 2 + devtools/client/memory/initializer.js | 16 ++- devtools/client/memory/models.js | 16 ++- devtools/client/memory/panel.js | 2 - .../client/memory/reducers/allocations.js | 2 + devtools/client/memory/reducers/errors.js | 2 + devtools/client/memory/reducers/filter.js | 4 +- devtools/client/memory/reducers/snapshots.js | 32 +++-- devtools/client/memory/store.js | 3 +- devtools/client/memory/telemetry.js | 7 +- .../client/memory/test/browser/.eslintrc.js | 13 +- .../browser/browser_memory_clear_snapshots.js | 50 +++---- .../test/browser/browser_memory_diff_01.js | 5 +- .../browser_memory_dominator_trees_01.js | 4 +- .../test/browser/browser_memory_filter_01.js | 7 +- .../browser/browser_memory_individuals_01.js | 6 +- .../browser_memory_keyboard-snapshot-list.js | 1 - .../test/browser/browser_memory_keyboard.js | 1 - .../browser_memory_no_allocation_stacks.js | 3 +- .../browser/browser_memory_no_auto_expand.js | 4 +- .../browser_memory_refresh_does_not_leak.js | 16 +-- .../test/browser/browser_memory_simple_01.js | 15 +- ...ser_memory_transferHeapSnapshot_e10s_01.js | 2 + .../browser/browser_memory_tree_map-02.js | 6 +- .../memory/test/browser/doc_big_tree.html | 26 ++-- .../test/browser/doc_steady_allocation.html | 24 ++-- devtools/client/memory/test/browser/head.js | 6 +- .../client/memory/test/chrome/.eslintrc.js | 14 ++ devtools/client/memory/test/chrome/head.js | 10 +- devtools/client/memory/test/unit/.eslintrc.js | 8 +- devtools/client/memory/test/unit/head.js | 24 ++-- .../unit/test_action-clear-snapshots_01.js | 4 +- .../unit/test_action-clear-snapshots_02.js | 2 + .../unit/test_action-clear-snapshots_03.js | 2 + .../unit/test_action-clear-snapshots_04.js | 5 +- .../unit/test_action-clear-snapshots_05.js | 4 +- .../unit/test_action-clear-snapshots_06.js | 1 - .../test/unit/test_action-export-snapshot.js | 4 +- .../memory/test/unit/test_action-filter-01.js | 2 + .../memory/test/unit/test_action-filter-02.js | 24 +--- .../memory/test/unit/test_action-filter-03.js | 2 + .../test_action-import-snapshot-and-census.js | 22 ++- ...t_action-import-snapshot-dominator-tree.js | 1 + .../test/unit/test_action-select-snapshot.js | 12 +- .../test_action-set-display-and-refresh-01.js | 41 +++--- .../test_action-set-display-and-refresh-02.js | 6 +- .../test/unit/test_action-set-display.js | 3 +- .../test/unit/test_action-take-census.js | 6 +- .../test_action-take-snapshot-and-census.js | 12 +- .../test/unit/test_action-take-snapshot.js | 5 +- ...t_action-toggle-inverted-and-refresh-01.js | 31 ++-- ...t_action-toggle-inverted-and-refresh-02.js | 7 +- .../test/unit/test_action-toggle-inverted.js | 1 + ...est_action-toggle-recording-allocations.js | 1 + .../test/unit/test_action_diffing_01.js | 2 + .../test/unit/test_action_diffing_02.js | 9 +- .../test/unit/test_action_diffing_03.js | 7 +- .../test/unit/test_action_diffing_04.js | 7 +- .../test/unit/test_action_diffing_05.js | 7 +- .../test/unit/test_dominator_trees_01.js | 3 +- .../test/unit/test_dominator_trees_02.js | 3 +- .../test/unit/test_dominator_trees_03.js | 3 +- .../test/unit/test_dominator_trees_04.js | 9 +- .../test/unit/test_dominator_trees_05.js | 7 +- .../test/unit/test_dominator_trees_06.js | 10 +- .../test/unit/test_dominator_trees_07.js | 4 +- .../test/unit/test_dominator_trees_08.js | 4 +- .../test/unit/test_dominator_trees_09.js | 4 +- .../test/unit/test_dominator_trees_10.js | 3 +- .../memory/test/unit/test_individuals_01.js | 1 + .../memory/test/unit/test_individuals_02.js | 1 + .../memory/test/unit/test_individuals_03.js | 5 +- .../memory/test/unit/test_individuals_04.js | 1 + .../memory/test/unit/test_individuals_05.js | 1 + .../memory/test/unit/test_individuals_06.js | 1 + .../memory/test/unit/test_pop_view_01.js | 1 + .../memory/test/unit/test_tree-map-01.js | 11 +- .../unit/test_utils-get-snapshot-totals.js | 3 +- .../client/memory/test/unit/test_utils.js | 7 +- devtools/client/memory/utils.js | 9 +- 106 files changed, 662 insertions(+), 492 deletions(-) create mode 100644 devtools/client/memory/.eslintrc.js create mode 100644 devtools/client/memory/test/chrome/.eslintrc.js diff --git a/.eslintignore b/.eslintignore index bfc8d5831846..b66f8eb0fe92 100644 --- a/.eslintignore +++ b/.eslintignore @@ -86,7 +86,6 @@ devtools/client/framework/** !devtools/client/framework/selection.js !devtools/client/framework/toolbox.js devtools/client/jsonview/lib/** -devtools/client/memory/** devtools/client/netmonitor/test/** devtools/client/netmonitor/har/test/** devtools/client/projecteditor/** diff --git a/devtools/client/memory/.eslintrc.js b/devtools/client/memory/.eslintrc.js new file mode 100644 index 000000000000..ac42ec2ff1c9 --- /dev/null +++ b/devtools/client/memory/.eslintrc.js @@ -0,0 +1,11 @@ +"use strict"; + +module.exports = { + "env": { + "browser": true, + }, + "globals": { + "d3": true, + "dagreD3": true, + } +}; diff --git a/devtools/client/memory/actions/census-display.js b/devtools/client/memory/actions/census-display.js index 348a8951a88c..416f5d1b5a1c 100644 --- a/devtools/client/memory/actions/census-display.js +++ b/devtools/client/memory/actions/census-display.js @@ -25,7 +25,8 @@ const setCensusDisplay = exports.setCensusDisplay = function (display) { && display && display.breakdown && display.breakdown.by, - `Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`); + "Breakdowns must be an object with a \`by\` property, attempted to set: " + + uneval(display)); return { type: actions.SET_CENSUS_DISPLAY, diff --git a/devtools/client/memory/actions/diffing.js b/devtools/client/memory/actions/diffing.js index 70af307bbb69..964dfe32989b 100644 --- a/devtools/client/memory/actions/diffing.js +++ b/devtools/client/memory/actions/diffing.js @@ -1,6 +1,7 @@ /* 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"; const { assert, reportException } = require("devtools/shared/DevToolsUtils"); @@ -12,13 +13,11 @@ const { snapshotIsDiffable, findSelectedSnapshot, } = require("../utils"); -// This is a circular dependency, so do not destructure the needed properties. -const snapshotActions = require("./snapshot"); /** * Toggle diffing mode on or off. */ -const toggleDiffing = exports.toggleDiffing = function () { +exports.toggleDiffing = function () { return function (dispatch, getState) { dispatch({ type: actions.CHANGE_VIEW, @@ -155,7 +154,7 @@ const refreshDiffing = exports.refreshDiffing = function (heapWorker) { * @param {HeapAnalysesClient} heapWorker * @param {snapshotModel} snapshot */ -const selectSnapshotForDiffingAndRefresh = exports.selectSnapshotForDiffingAndRefresh = function (heapWorker, snapshot) { +exports.selectSnapshotForDiffingAndRefresh = function (heapWorker, snapshot) { return function* (dispatch, getState) { assert(getState().diffing, "If we are selecting for diffing, we must be in diffing mode"); @@ -169,7 +168,7 @@ const selectSnapshotForDiffingAndRefresh = exports.selectSnapshotForDiffingAndRe * * @param {CensusTreeNode} node */ -const expandDiffingCensusNode = exports.expandDiffingCensusNode = function (node) { +exports.expandDiffingCensusNode = function (node) { return { type: actions.EXPAND_DIFFING_CENSUS_NODE, node, @@ -181,7 +180,7 @@ const expandDiffingCensusNode = exports.expandDiffingCensusNode = function (node * * @param {CensusTreeNode} node */ -const collapseDiffingCensusNode = exports.collapseDiffingCensusNode = function (node) { +exports.collapseDiffingCensusNode = function (node) { return { type: actions.COLLAPSE_DIFFING_CENSUS_NODE, node, @@ -193,7 +192,7 @@ const collapseDiffingCensusNode = exports.collapseDiffingCensusNode = function ( * * @param {DominatorTreeNode} node */ -const focusDiffingCensusNode = exports.focusDiffingCensusNode = function (node) { +exports.focusDiffingCensusNode = function (node) { return { type: actions.FOCUS_DIFFING_CENSUS_NODE, node, diff --git a/devtools/client/memory/actions/io.js b/devtools/client/memory/actions/io.js index 10b45aee535f..ab578d1436e0 100644 --- a/devtools/client/memory/actions/io.js +++ b/devtools/client/memory/actions/io.js @@ -4,16 +4,14 @@ "use strict"; const { immutableUpdate, reportException, assert } = require("devtools/shared/DevToolsUtils"); -const { snapshotState: states, actions, viewState } = require("../constants"); +const { snapshotState: states, actions} = require("../constants"); const { L10N, openFilePicker, createSnapshot } = require("../utils"); const telemetry = require("../telemetry"); const { OS } = require("resource://gre/modules/osfile.jsm"); const { selectSnapshot, computeSnapshotData, - readSnapshot, - takeCensus, - takeTreeMap + readSnapshot } = require("./snapshot"); const VALID_EXPORT_STATES = [states.SAVED, states.READ]; @@ -54,7 +52,7 @@ const exportSnapshot = exports.exportSnapshot = function (snapshot, dest) { }; }; -const pickFileAndImportSnapshotAndCensus = exports.pickFileAndImportSnapshotAndCensus = function (heapWorker) { +exports.pickFileAndImportSnapshotAndCensus = function (heapWorker) { return function* (dispatch, getState) { let input = yield openFilePicker({ title: L10N.getFormatStr("snapshot.io.import.window"), @@ -70,7 +68,7 @@ const pickFileAndImportSnapshotAndCensus = exports.pickFileAndImportSnapshotAndC }; }; -const importSnapshotAndCensus = exports.importSnapshotAndCensus = function (heapWorker, path) { +const importSnapshotAndCensus = function (heapWorker, path) { return function* (dispatch, getState) { telemetry.countImportSnapshot(); @@ -95,3 +93,4 @@ const importSnapshotAndCensus = exports.importSnapshotAndCensus = function (heap dispatch({ type: actions.IMPORT_SNAPSHOT_END, id }); }; }; +exports.importSnapshotAndCensus = importSnapshotAndCensus; diff --git a/devtools/client/memory/actions/label-display.js b/devtools/client/memory/actions/label-display.js index 6e68293ab8e0..82f7d4f5249d 100644 --- a/devtools/client/memory/actions/label-display.js +++ b/devtools/client/memory/actions/label-display.js @@ -29,7 +29,8 @@ const setLabelDisplay = exports.setLabelDisplay = function (display) { && display && display.breakdown && display.breakdown.by, - `Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`); + "Breakdowns must be an object with a \`by\` property, attempted to set: " + + uneval(display)); return { type: actions.SET_LABEL_DISPLAY, diff --git a/devtools/client/memory/actions/snapshot.js b/devtools/client/memory/actions/snapshot.js index adb24977eb67..3d5ca9c757b5 100644 --- a/devtools/client/memory/actions/snapshot.js +++ b/devtools/client/memory/actions/snapshot.js @@ -34,7 +34,7 @@ const TaskCache = require("./task-cache"); * @param {HeapAnalysesClient} * @param {Object} */ -const takeSnapshotAndCensus = exports.takeSnapshotAndCensus = function (front, heapWorker) { +exports.takeSnapshotAndCensus = function (front, heapWorker) { return function* (dispatch, getState) { const id = yield dispatch(takeSnapshot(front)); if (id === null) { @@ -82,7 +82,7 @@ const computeSnapshotData = exports.computeSnapshotData = function (heapWorker, * @param {HeapAnalysesClient} heapWorker * @param {snapshotId} id */ -const selectSnapshotAndRefresh = exports.selectSnapshotAndRefresh = function (heapWorker, id) { +exports.selectSnapshotAndRefresh = function (heapWorker, id) { return function* (dispatch, getState) { if (getState().diffing || getState().individuals) { dispatch(view.changeView(viewState.CENSUS)); @@ -200,7 +200,9 @@ function makeTakeCensusTask({ getDisplay, getFilter, getCensus, beginAction, // Assert that snapshot is in a valid state assert(canTakeCensus(snapshot), - `Attempting to take a census when the snapshot is not in a ready state. snapshot.state = ${snapshot.state}, census.state = ${(getCensus(snapshot) || { state: null }).state}`); + "Attempting to take a census when the snapshot is not in a ready state. " + + `snapshot.state = ${snapshot.state}, ` + + `census.state = ${(getCensus(snapshot) || { state: null }).state}`); let report, parentMap; let display = getDisplay(getState()); @@ -322,7 +324,7 @@ const getCurrentCensusTaker = exports.getCurrentCensusTaker = function (currentV * * @param {DominatorTreeNode} node. */ -const focusIndividual = exports.focusIndividual = function (node) { +exports.focusIndividual = function (node) { return { type: actions.FOCUS_INDIVIDUAL, node, @@ -412,7 +414,7 @@ function (heapWorker, id, censusBreakdown, reportLeafIndex) { * * @param {HeapAnalysesClient} heapWorker */ -const refreshIndividuals = exports.refreshIndividuals = function (heapWorker) { +exports.refreshIndividuals = function (heapWorker) { return function* (dispatch, getState) { assert(getState().view.state === viewState.INDIVIDUALS, "Should be in INDIVIDUALS view."); @@ -453,7 +455,7 @@ const refreshIndividuals = exports.refreshIndividuals = function (heapWorker) { * * @param {HeapAnalysesClient} heapWorker */ -const refreshSelectedCensus = exports.refreshSelectedCensus = function (heapWorker) { +exports.refreshSelectedCensus = function (heapWorker) { return function* (dispatch, getState) { let snapshot = getState().snapshots.find(s => s.selected); if (!snapshot || snapshot.state !== states.READ) { @@ -479,7 +481,7 @@ const refreshSelectedCensus = exports.refreshSelectedCensus = function (heapWork * * @param {HeapAnalysesClient} heapWorker */ -const refreshSelectedTreeMap = exports.refreshSelectedTreeMap = function (heapWorker) { +exports.refreshSelectedTreeMap = function (heapWorker) { return function* (dispatch, getState) { let snapshot = getState().snapshots.find(s => s.selected); if (!snapshot || snapshot.state !== states.READ) { @@ -596,8 +598,7 @@ TaskCache.declareCacheableTask({ * @param {SnapshotId} id * @param {DominatorTreeLazyChildren} lazyChildren */ -const fetchImmediatelyDominated = exports.fetchImmediatelyDominated = -TaskCache.declareCacheableTask({ +exports.fetchImmediatelyDominated = TaskCache.declareCacheableTask({ getCacheKey(_, id, lazyChildren) { return `${id}-${lazyChildren.key()}`; }, @@ -630,7 +631,7 @@ TaskCache.declareCacheableTask({ removeFromCache(); reportException("actions/snapshot/fetchImmediatelyDominated", error); dispatch({ type: actions.DOMINATOR_TREE_ERROR, id, error }); - return null; + return; } } while (display !== getState().labelDisplay); @@ -643,6 +644,7 @@ TaskCache.declareCacheableTask({ nodes: response.nodes, moreChildrenAvailable: response.moreChildrenAvailable, }); + return; } }); @@ -684,7 +686,7 @@ TaskCache.declareCacheableTask({ * * @param {HeapAnalysesClient} heapWorker */ -const refreshSelectedDominatorTree = exports.refreshSelectedDominatorTree = function (heapWorker) { +exports.refreshSelectedDominatorTree = function (heapWorker) { return function* (dispatch, getState) { let snapshot = getState().snapshots.find(s => s.selected); if (!snapshot) { @@ -731,7 +733,7 @@ const selectSnapshot = exports.selectSnapshot = function (id) { * * @param {HeapAnalysesClient} heapWorker */ -const clearSnapshots = exports.clearSnapshots = function (heapWorker) { +exports.clearSnapshots = function (heapWorker) { return function* (dispatch, getState) { let snapshots = getState().snapshots.filter(s => { let snapshotReady = s.state === states.READ || s.state === states.ERROR; @@ -769,7 +771,7 @@ const clearSnapshots = exports.clearSnapshots = function (heapWorker) { * @param {HeapAnalysesClient} heapWorker * @param {snapshotModel} snapshot */ -const deleteSnapshot = exports.deleteSnapshot = function (heapWorker, snapshot) { +exports.deleteSnapshot = function (heapWorker, snapshot) { return function* (dispatch, getState) { dispatch({ type: actions.DELETE_SNAPSHOTS_START, ids: [snapshot.id] }); @@ -789,7 +791,7 @@ const deleteSnapshot = exports.deleteSnapshot = function (heapWorker, snapshot) * * @param {CensusTreeNode} node */ -const expandCensusNode = exports.expandCensusNode = function (id, node) { +exports.expandCensusNode = function (id, node) { return { type: actions.EXPAND_CENSUS_NODE, id, @@ -802,7 +804,7 @@ const expandCensusNode = exports.expandCensusNode = function (id, node) { * * @param {CensusTreeNode} node */ -const collapseCensusNode = exports.collapseCensusNode = function (id, node) { +exports.collapseCensusNode = function (id, node) { return { type: actions.COLLAPSE_CENSUS_NODE, id, @@ -816,7 +818,7 @@ const collapseCensusNode = exports.collapseCensusNode = function (id, node) { * @param {SnapshotId} id * @param {DominatorTreeNode} node */ -const focusCensusNode = exports.focusCensusNode = function (id, node) { +exports.focusCensusNode = function (id, node) { return { type: actions.FOCUS_CENSUS_NODE, id, @@ -829,7 +831,7 @@ const focusCensusNode = exports.focusCensusNode = function (id, node) { * * @param {DominatorTreeTreeNode} node */ -const expandDominatorTreeNode = exports.expandDominatorTreeNode = function (id, node) { +exports.expandDominatorTreeNode = function (id, node) { return { type: actions.EXPAND_DOMINATOR_TREE_NODE, id, @@ -842,7 +844,7 @@ const expandDominatorTreeNode = exports.expandDominatorTreeNode = function (id, * * @param {DominatorTreeTreeNode} node */ -const collapseDominatorTreeNode = exports.collapseDominatorTreeNode = function (id, node) { +exports.collapseDominatorTreeNode = function (id, node) { return { type: actions.COLLAPSE_DOMINATOR_TREE_NODE, id, @@ -856,7 +858,7 @@ const collapseDominatorTreeNode = exports.collapseDominatorTreeNode = function ( * @param {SnapshotId} id * @param {DominatorTreeNode} node */ -const focusDominatorTreeNode = exports.focusDominatorTreeNode = function (id, node) { +exports.focusDominatorTreeNode = function (id, node) { return { type: actions.FOCUS_DOMINATOR_TREE_NODE, id, diff --git a/devtools/client/memory/actions/tree-map-display.js b/devtools/client/memory/actions/tree-map-display.js index e4ab9988c998..69b205603e15 100644 --- a/devtools/client/memory/actions/tree-map-display.js +++ b/devtools/client/memory/actions/tree-map-display.js @@ -28,7 +28,8 @@ const setTreeMap = exports.setTreeMap = function (display) { && display && display.breakdown && display.breakdown.by, - `Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`); + "Breakdowns must be an object with a \`by\` property, attempted to set: " + + uneval(display)); return { type: actions.SET_TREE_MAP_DISPLAY, diff --git a/devtools/client/memory/app.js b/devtools/client/memory/app.js index b705e0a99333..66e5b328f3bf 100644 --- a/devtools/client/memory/app.js +++ b/devtools/client/memory/app.js @@ -2,6 +2,8 @@ * 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"; + const { assert } = require("devtools/shared/DevToolsUtils"); const { appinfo } = require("Services"); const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react"); @@ -54,10 +56,24 @@ const MemoryApp = createClass({ propTypes: appModel, + childContextTypes: { + front: PropTypes.any, + heapWorker: PropTypes.any, + toolbox: PropTypes.any, + }, + getDefaultProps() { return {}; }, + getChildContext() { + return { + front: this.props.front, + heapWorker: this.props.heapWorker, + toolbox: this.props.toolbox, + }; + }, + componentDidMount() { // Attach the keydown listener directly to the window. When an element that // has the focus (such as a tree node) is removed from the DOM, the focus @@ -69,20 +85,6 @@ const MemoryApp = createClass({ window.removeEventListener("keydown", this.onKeyDown); }, - childContextTypes: { - front: PropTypes.any, - heapWorker: PropTypes.any, - toolbox: PropTypes.any, - }, - - getChildContext() { - return { - front: this.props.front, - heapWorker: this.props.heapWorker, - toolbox: this.props.toolbox, - }; - }, - onKeyDown(e) { let { snapshots, dispatch, heapWorker } = this.props; const selectedSnapshot = snapshots.find(s => s.selected); @@ -219,7 +221,8 @@ const MemoryApp = createClass({ Heap({ snapshot: selectedSnapshot, diffing, - onViewSourceInDebugger: frame => toolbox.viewSourceInDebugger(frame.source, frame.line), + onViewSourceInDebugger: frame => + toolbox.viewSourceInDebugger(frame.source, frame.line), onSnapshotClick: () => dispatch(takeSnapshotAndCensus(front, heapWorker)), onLoadMoreSiblings: lazyChildren => @@ -249,7 +252,8 @@ const MemoryApp = createClass({ dispatch(expandDiffingCensusNode(node)); } else { assert(selectedSnapshot && selectedSnapshot.census === census, - "If not diffing, should be expanding on selected snapshot's census"); + "If not diffing, " + + "should be expanding on selected snapshot's census"); dispatch(expandCensusNode(selectedSnapshot.id, node)); } }, @@ -260,7 +264,8 @@ const MemoryApp = createClass({ dispatch(collapseDiffingCensusNode(node)); } else { assert(selectedSnapshot && selectedSnapshot.census === census, - "If not diffing, should be collapsing on selected snapshot's census"); + "If not diffing, " + + "should be collapsing on selected snapshot's census"); dispatch(collapseCensusNode(selectedSnapshot.id, node)); } }, @@ -271,13 +276,15 @@ const MemoryApp = createClass({ dispatch(focusDiffingCensusNode(node)); } else { assert(selectedSnapshot && selectedSnapshot.census === census, - "If not diffing, should be focusing on nodes in selected snapshot's census"); + "If not diffing, " + + "should be focusing on nodes in selected snapshot's census"); dispatch(focusCensusNode(selectedSnapshot.id, node)); } }, onDominatorTreeExpand: node => { assert(view.state === viewState.DOMINATOR_TREE, - "If expanding dominator tree nodes, should be in dominator tree view"); + "If expanding dominator tree nodes, " + + "should be in dominator tree view"); assert(selectedSnapshot, "...and we should have a selected snapshot"); assert(selectedSnapshot.dominatorTree, "...and that snapshot should have a dominator tree"); @@ -285,7 +292,8 @@ const MemoryApp = createClass({ }, onDominatorTreeCollapse: node => { assert(view.state === viewState.DOMINATOR_TREE, - "If collapsing dominator tree nodes, should be in dominator tree view"); + "If collapsing dominator tree nodes, " + + "should be in dominator tree view"); assert(selectedSnapshot, "...and we should have a selected snapshot"); assert(selectedSnapshot.dominatorTree, "...and that snapshot should have a dominator tree"); @@ -293,7 +301,8 @@ const MemoryApp = createClass({ }, onDominatorTreeFocus: node => { assert(view.state === viewState.DOMINATOR_TREE, - "If focusing dominator tree nodes, should be in dominator tree view"); + "If focusing dominator tree nodes, " + + "should be in dominator tree view"); assert(selectedSnapshot, "...and we should have a selected snapshot"); assert(selectedSnapshot.dominatorTree, "...and that snapshot should have a dominator tree"); diff --git a/devtools/client/memory/components/census-header.js b/devtools/client/memory/components/census-header.js index d897ed132fc9..dee1db6215a8 100644 --- a/devtools/client/memory/components/census-header.js +++ b/devtools/client/memory/components/census-header.js @@ -2,11 +2,13 @@ * 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"; + const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react"); const { L10N } = require("../utils"); const models = require("../models"); -const CensusHeader = module.exports = createClass({ +module.exports = createClass({ displayName: "CensusHeader", propTypes: { diff --git a/devtools/client/memory/components/census-tree-item.js b/devtools/client/memory/components/census-tree-item.js index c5d08cefcebe..8569513ed28a 100644 --- a/devtools/client/memory/components/census-tree-item.js +++ b/devtools/client/memory/components/census-tree-item.js @@ -9,7 +9,7 @@ const { L10N, formatNumber, formatPercent } = require("../utils"); const Frame = createFactory(require("devtools/client/shared/components/frame")); const { TREE_ROW_HEIGHT } = require("../constants"); -const CensusTreeItem = module.exports = createClass({ +module.exports = createClass({ displayName: "CensusTreeItem", shouldComponentUpdate(nextProps, nextState) { @@ -20,6 +20,31 @@ const CensusTreeItem = module.exports = createClass({ || this.props.diffing != nextProps.diffing; }, + toLabel(name, linkToDebugger) { + if (isSavedFrame(name)) { + return Frame({ + frame: name, + onClick: () => linkToDebugger(name), + showFunctionName: true, + showHost: true, + }); + } + + if (name === null) { + return L10N.getStr("tree-item.root"); + } + + if (name === "noStack") { + return L10N.getStr("tree-item.nostack"); + } + + if (name === "noFilename") { + return L10N.getStr("tree-item.nofilename"); + } + + return String(name); + }, + render() { let { item, @@ -106,29 +131,4 @@ const CensusTreeItem = module.exports = createClass({ ) ); }, - - toLabel(name, linkToDebugger) { - if (isSavedFrame(name)) { - return Frame({ - frame: name, - onClick: () => linkToDebugger(name), - showFunctionName: true, - showHost: true, - }); - } - - if (name === null) { - return L10N.getStr("tree-item.root"); - } - - if (name === "noStack") { - return L10N.getStr("tree-item.nostack"); - } - - if (name === "noFilename") { - return L10N.getStr("tree-item.nofilename"); - } - - return String(name); - }, }); diff --git a/devtools/client/memory/components/census.js b/devtools/client/memory/components/census.js index 3274b26bb06f..92e872ff10c1 100644 --- a/devtools/client/memory/components/census.js +++ b/devtools/client/memory/components/census.js @@ -2,14 +2,15 @@ * 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/. */ -const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react"); +"use strict"; + +const { createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react"); const Tree = createFactory(require("devtools/client/shared/components/tree")); const CensusTreeItem = createFactory(require("./census-tree-item")); -const { createParentMap } = require("../utils"); const { TREE_ROW_HEIGHT } = require("../constants"); const { censusModel, diffingModel } = require("../models"); -const Census = module.exports = createClass({ +module.exports = createClass({ displayName: "Census", propTypes: { diff --git a/devtools/client/memory/components/dominator-tree-header.js b/devtools/client/memory/components/dominator-tree-header.js index ae1c7520eca0..b2e22fed9790 100644 --- a/devtools/client/memory/components/dominator-tree-header.js +++ b/devtools/client/memory/components/dominator-tree-header.js @@ -2,10 +2,12 @@ * 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/. */ -const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react"); +"use strict"; + +const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react"); const { L10N } = require("../utils"); -const DominatorTreeHeader = module.exports = createClass({ +module.exports = createClass({ displayName: "DominatorTreeHeader", propTypes: { }, diff --git a/devtools/client/memory/components/dominator-tree-item.js b/devtools/client/memory/components/dominator-tree-item.js index bf76ee9b44bf..9933bc3d2982 100644 --- a/devtools/client/memory/components/dominator-tree-item.js +++ b/devtools/client/memory/components/dominator-tree-item.js @@ -2,6 +2,8 @@ * 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"; + const { assert, isSavedFrame } = require("devtools/shared/DevToolsUtils"); const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react"); const { L10N, formatNumber, formatPercent } = require("../utils"); @@ -16,7 +18,7 @@ const Separator = createFactory(createClass({ } })); -const DominatorTreeItem = module.exports = createClass({ +module.exports = createClass({ displayName: "DominatorTreeItem", propTypes: { diff --git a/devtools/client/memory/components/dominator-tree.js b/devtools/client/memory/components/dominator-tree.js index a1105a4fc541..6ec7c6a3bdcf 100644 --- a/devtools/client/memory/components/dominator-tree.js +++ b/devtools/client/memory/components/dominator-tree.js @@ -2,8 +2,10 @@ * 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"; + const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react"); -const { assert, safeErrorString } = require("devtools/shared/DevToolsUtils"); +const { assert } = require("devtools/shared/DevToolsUtils"); const { createParentMap } = require("devtools/shared/heapsnapshot/CensusUtils"); const Tree = createFactory(require("devtools/client/shared/components/tree")); const DominatorTreeItem = createFactory(require("./dominator-tree-item")); @@ -21,16 +23,16 @@ const DOMINATOR_TREE_AUTO_EXPAND_DEPTH = 3; const DominatorTreeSubtreeFetching = createFactory(createClass({ displayName: "DominatorTreeSubtreeFetching", - shouldComponentUpdate(nextProps, nextState) { - return this.props.depth !== nextProps.depth - || this.props.focused !== nextProps.focused; - }, - propTypes: { depth: PropTypes.number.isRequired, focused: PropTypes.bool.isRequired, }, + shouldComponentUpdate(nextProps, nextState) { + return this.props.depth !== nextProps.depth + || this.props.focused !== nextProps.focused; + }, + render() { let { depth, @@ -103,7 +105,7 @@ const DominatorTreeSiblingLink = createFactory(createClass({ /** * The actual dominator tree rendered as an expandable and collapsible tree. */ -const DominatorTree = module.exports = createClass({ +module.exports = createClass({ displayName: "DominatorTree", propTypes: { diff --git a/devtools/client/memory/components/heap.js b/devtools/client/memory/components/heap.js index 786f37ae1960..8735021f3efc 100644 --- a/devtools/client/memory/components/heap.js +++ b/devtools/client/memory/components/heap.js @@ -2,6 +2,8 @@ * 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"; + const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react"); const { assert, safeErrorString } = require("devtools/shared/DevToolsUtils"); const Census = createFactory(require("./census")); @@ -178,7 +180,7 @@ function getError(snapshot, diffing, individuals) { * state of only a button to take a snapshot, loading states, the census view * tree, the dominator tree, etc. */ -const Heap = module.exports = createClass({ +module.exports = createClass({ displayName: "Heap", propTypes: { @@ -202,68 +204,6 @@ const Heap = module.exports = createClass({ sizes: PropTypes.object.isRequired, }, - render() { - let { - snapshot, - diffing, - onSnapshotClick, - onLoadMoreSiblings, - onViewSourceInDebugger, - onViewIndividuals, - individuals, - view, - } = this.props; - - - if (!diffing && !snapshot && !individuals) { - return this._renderInitial(onSnapshotClick); - } - - const state = getState(view, snapshot, diffing, individuals); - const statusText = getStateStatusText(state, diffing); - - if (shouldDisplayStatus(state, view, snapshot)) { - return this._renderStatus(state, statusText, diffing); - } - - const error = getError(snapshot, diffing, individuals); - if (error) { - return this._renderError(state, statusText, error); - } - - if (view.state === viewState.CENSUS || view.state === viewState.DIFFING) { - const census = view.state === viewState.CENSUS - ? snapshot.census - : diffing.census; - if (!census) { - return this._renderStatus(state, statusText, diffing); - } - return this._renderCensus(state, census, diffing, onViewSourceInDebugger, - onViewIndividuals); - } - - if (view.state === viewState.TREE_MAP) { - return this._renderTreeMap(state, snapshot.treeMap); - } - - if (view.state === viewState.INDIVIDUALS) { - assert(individuals.state === individualsState.FETCHED, - "Should have fetched the individuals -- other states are rendered as statuses"); - return this._renderIndividuals(state, individuals, - individuals.dominatorTree, - onViewSourceInDebugger); - } - - assert(view.state === viewState.DOMINATOR_TREE, - "If we aren't in progress, looking at a census, or diffing, then we " + - "must be looking at a dominator tree"); - assert(!diffing, "Should not have diffing"); - assert(snapshot.dominatorTree, "Should have a dominator tree"); - - return this._renderDominatorTree(state, onViewSourceInDebugger, snapshot.dominatorTree, - onLoadMoreSiblings); - }, - /** * Render the heap view's container panel with the given contents inside of * it. @@ -325,9 +265,10 @@ const Heap = module.exports = createClass({ assert(census.report, "Should not render census that does not have a report"); if (!census.report.children) { + const censusFilterMsg = census.filter ? L10N.getStr("heapview.none-match") + : L10N.getStr("heapview.empty"); const msg = diffing ? L10N.getStr("heapview.no-difference") - : census.filter ? L10N.getStr("heapview.none-match") - : L10N.getStr("heapview.empty"); + : censusFilterMsg; return this._renderHeapView(state, dom.div({ className: "empty" }, msg)); } @@ -452,4 +393,67 @@ const Heap = module.exports = createClass({ }) ); }, + + render() { + let { + snapshot, + diffing, + onSnapshotClick, + onLoadMoreSiblings, + onViewSourceInDebugger, + onViewIndividuals, + individuals, + view, + } = this.props; + + if (!diffing && !snapshot && !individuals) { + return this._renderInitial(onSnapshotClick); + } + + const state = getState(view, snapshot, diffing, individuals); + const statusText = getStateStatusText(state, diffing); + + if (shouldDisplayStatus(state, view, snapshot)) { + return this._renderStatus(state, statusText, diffing); + } + + const error = getError(snapshot, diffing, individuals); + if (error) { + return this._renderError(state, statusText, error); + } + + if (view.state === viewState.CENSUS || view.state === viewState.DIFFING) { + const census = view.state === viewState.CENSUS + ? snapshot.census + : diffing.census; + if (!census) { + return this._renderStatus(state, statusText, diffing); + } + return this._renderCensus(state, census, diffing, onViewSourceInDebugger, + onViewIndividuals); + } + + if (view.state === viewState.TREE_MAP) { + return this._renderTreeMap(state, snapshot.treeMap); + } + + if (view.state === viewState.INDIVIDUALS) { + assert(individuals.state === individualsState.FETCHED, + "Should have fetched the individuals -- " + + "other states are rendered as statuses"); + return this._renderIndividuals(state, individuals, + individuals.dominatorTree, + onViewSourceInDebugger); + } + + assert(view.state === viewState.DOMINATOR_TREE, + "If we aren't in progress, looking at a census, or diffing, then we " + + "must be looking at a dominator tree"); + assert(!diffing, "Should not have diffing"); + assert(snapshot.dominatorTree, "Should have a dominator tree"); + + return this._renderDominatorTree(state, onViewSourceInDebugger, + snapshot.dominatorTree, + onLoadMoreSiblings); + }, }); diff --git a/devtools/client/memory/components/individuals-header.js b/devtools/client/memory/components/individuals-header.js index 7cacd163ec29..6da3c09049a0 100644 --- a/devtools/client/memory/components/individuals-header.js +++ b/devtools/client/memory/components/individuals-header.js @@ -2,10 +2,12 @@ * 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/. */ -const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react"); +"use strict"; + +const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react"); const { L10N } = require("../utils"); -const IndividualsHeader = module.exports = createClass({ +module.exports = createClass({ displayName: "IndividualsHeader", propTypes: { }, diff --git a/devtools/client/memory/components/individuals.js b/devtools/client/memory/components/individuals.js index 56c784820471..b629e2421c14 100644 --- a/devtools/client/memory/components/individuals.js +++ b/devtools/client/memory/components/individuals.js @@ -2,19 +2,18 @@ * 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/. */ -const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react"); -const { assert } = require("devtools/shared/DevToolsUtils"); -const { createParentMap } = require("devtools/shared/heapsnapshot/CensusUtils"); +"use strict"; + +const { createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react"); const Tree = createFactory(require("devtools/client/shared/components/tree")); const DominatorTreeItem = createFactory(require("./dominator-tree-item")); -const { L10N } = require("../utils"); const { TREE_ROW_HEIGHT } = require("../constants"); const models = require("../models"); /** * The list of individuals in a census group. */ -const Individuals = module.exports = createClass({ +module.exports = createClass({ displayName: "Individuals", propTypes: { diff --git a/devtools/client/memory/components/list.js b/devtools/client/memory/components/list.js index 3aa27da69899..6568c7ce59fa 100644 --- a/devtools/client/memory/components/list.js +++ b/devtools/client/memory/components/list.js @@ -2,6 +2,8 @@ * 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"; + const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react"); /** @@ -9,7 +11,7 @@ const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/ven * the children nodes as `itemComponent`, and a list of items to render * as that component with a click handler. */ -const List = module.exports = createClass({ +module.exports = createClass({ displayName: "List", propTypes: { diff --git a/devtools/client/memory/components/shortest-paths.js b/devtools/client/memory/components/shortest-paths.js index 23cb8134b5b8..51d2293a73a1 100644 --- a/devtools/client/memory/components/shortest-paths.js +++ b/devtools/client/memory/components/shortest-paths.js @@ -1,6 +1,7 @@ /* 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"; const { @@ -29,7 +30,8 @@ function stringifyLabel(label, id) { if (isSavedFrame(piece)) { const { short } = getSourceNames(piece.source); - sanitized[i] = `${piece.functionDisplayName} @ ${short}:${piece.line}:${piece.column}`; + sanitized[i] = `${piece.functionDisplayName} @ ` + + `${short}:${piece.line}:${piece.column}`; } else if (piece === NO_STACK) { sanitized[i] = L10N.getStr("tree-item.nostack"); } else if (piece === NO_FILENAME) { @@ -62,16 +64,16 @@ module.exports = createClass({ return { zoom: null }; }, - shouldComponentUpdate(nextProps) { - return this.props.graph != nextProps.graph; - }, - componentDidMount() { if (this.props.graph) { this._renderGraph(this.refs.container, this.props.graph); } }, + shouldComponentUpdate(nextProps) { + return this.props.graph != nextProps.graph; + }, + componentDidUpdate() { if (this.props.graph) { this._renderGraph(this.refs.container, this.props.graph); @@ -84,44 +86,6 @@ module.exports = createClass({ } }, - render() { - let contents; - if (this.props.graph) { - // Let the componentDidMount or componentDidUpdate method draw the graph - // with DagreD3. We just provide the container for the graph here. - contents = dom.div({ - ref: "container", - style: { - flex: 1, - height: "100%", - width: "100%", - } - }); - } else { - contents = dom.div( - { - id: "shortest-paths-select-node-msg" - }, - L10N.getStr("shortest-paths.select-node") - ); - } - - return dom.div( - { - id: "shortest-paths", - className: "vbox", - }, - dom.label( - { - id: "shortest-paths-header", - className: "header", - }, - L10N.getStr("shortest-paths.header") - ), - contents - ); - }, - _renderGraph(container, { nodes, edges }) { if (!container.firstChild) { const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); @@ -181,4 +145,42 @@ module.exports = createClass({ const layout = dagreD3.layout(); renderer.layout(layout).run(graph, target); }, + + render() { + let contents; + if (this.props.graph) { + // Let the componentDidMount or componentDidUpdate method draw the graph + // with DagreD3. We just provide the container for the graph here. + contents = dom.div({ + ref: "container", + style: { + flex: 1, + height: "100%", + width: "100%", + } + }); + } else { + contents = dom.div( + { + id: "shortest-paths-select-node-msg" + }, + L10N.getStr("shortest-paths.select-node") + ); + } + + return dom.div( + { + id: "shortest-paths", + className: "vbox", + }, + dom.label( + { + id: "shortest-paths-header", + className: "header", + }, + L10N.getStr("shortest-paths.header") + ), + contents + ); + }, }); diff --git a/devtools/client/memory/components/snapshot-list-item.js b/devtools/client/memory/components/snapshot-list-item.js index 37db81d13be9..31c490f93912 100644 --- a/devtools/client/memory/components/snapshot-list-item.js +++ b/devtools/client/memory/components/snapshot-list-item.js @@ -2,7 +2,8 @@ * 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/. */ -const { assert } = require("devtools/shared/DevToolsUtils"); +"use strict"; + const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react"); const { L10N, @@ -12,15 +13,10 @@ const { snapshotIsDiffable, getSavedCensus } = require("../utils"); -const { - snapshotState: states, - diffingState, - censusState, - treeMapState -} = require("../constants"); +const { diffingState } = require("../constants"); const { snapshot: snapshotModel } = require("../models"); -const SnapshotListItem = module.exports = createClass({ +module.exports = createClass({ displayName: "SnapshotListItem", propTypes: { @@ -32,7 +28,7 @@ const SnapshotListItem = module.exports = createClass({ }, render() { - let { index, item: snapshot, onClick, onSave, onDelete, diffing } = this.props; + let { item: snapshot, onClick, onSave, onDelete, diffing } = this.props; let className = `snapshot-list-item ${snapshot.selected ? " selected" : ""}`; let statusText = getStatusText(snapshot.state); let wantThrobber = !!statusText; @@ -75,7 +71,8 @@ const SnapshotListItem = module.exports = createClass({ // If there is census data, fill in the total bytes. if (census) { let { bytes } = getSnapshotTotals(census); - let formatBytes = L10N.getFormatStr("aggregate.mb", L10N.numberWithDecimals(bytes / 1000000, 2)); + let formatBytes = L10N.getFormatStr("aggregate.mb", + L10N.numberWithDecimals(bytes / 1000000, 2)); details = dom.span({ className: "snapshot-totals" }, dom.span({ className: "total-bytes" }, formatBytes) @@ -99,7 +96,9 @@ const SnapshotListItem = module.exports = createClass({ return ( dom.li({ className, onClick }, - dom.span({ className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}` }, + dom.span({ + className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}` + }, checkbox, title, deleteButton diff --git a/devtools/client/memory/components/toolbar.js b/devtools/client/memory/components/toolbar.js index de60b2af9484..7945b7dfe7ad 100644 --- a/devtools/client/memory/components/toolbar.js +++ b/devtools/client/memory/components/toolbar.js @@ -260,7 +260,8 @@ module.exports = createClass({ dom.button( { id: "diff-snapshots", - className: "devtools-button devtools-monospace" + (!!diffing ? " checked" : ""), + className: "devtools-button devtools-monospace" + + (diffing ? " checked" : ""), disabled: snapshots.length < 2, onClick: onToggleDiffing, title: L10N.getStr("diff-snapshots.tooltip"), diff --git a/devtools/client/memory/components/tree-map.js b/devtools/client/memory/components/tree-map.js index b6764605eb2f..9e952b109996 100644 --- a/devtools/client/memory/components/tree-map.js +++ b/devtools/client/memory/components/tree-map.js @@ -9,12 +9,12 @@ const { treeMapModel } = require("../models"); const startVisualization = require("./tree-map/start"); module.exports = createClass({ + displayName: "TreeMap", + propTypes: { treeMap: treeMapModel }, - displayName: "TreeMap", - getInitialState() { return {}; }, diff --git a/devtools/client/memory/components/tree-map/canvas-utils.js b/devtools/client/memory/components/tree-map/canvas-utils.js index c7d67a0bf0c7..50d94f0802c6 100644 --- a/devtools/client/memory/components/tree-map/canvas-utils.js +++ b/devtools/client/memory/components/tree-map/canvas-utils.js @@ -51,7 +51,7 @@ Canvases.prototype = { * * @return {type} description */ - destroy : function () { + destroy: function () { this.removeHandlers(); this.container.removeChild(this.main.canvas); this.container.removeChild(this.zoom.canvas); diff --git a/devtools/client/memory/components/tree-map/drag-zoom.js b/devtools/client/memory/components/tree-map/drag-zoom.js index 3de970725440..c7ddf5109b6b 100644 --- a/devtools/client/memory/components/tree-map/drag-zoom.js +++ b/devtools/client/memory/components/tree-map/drag-zoom.js @@ -238,7 +238,6 @@ function setScrollHandlers(container, dragZoom, emitChanged, update) { let scrollDelta = getScrollDelta(event, window); let prevZoom = dragZoom.zoom; dragZoom.zoom = Math.max(0, dragZoom.zoom - scrollDelta * ZOOM_SPEED); - let deltaZoom = dragZoom.zoom - prevZoom; // Calculate the updated width and height let prevZoomedWidth = container.offsetWidth * (1 + prevZoom); diff --git a/devtools/client/memory/constants.js b/devtools/client/memory/constants.js index b8e382c73b34..e10f4f13bb3e 100644 --- a/devtools/client/memory/constants.js +++ b/devtools/client/memory/constants.js @@ -122,7 +122,10 @@ actions.RESIZE_SHORTEST_PATHS = "resize-shortest-paths"; const COUNT = Object.freeze({ by: "count", count: true, bytes: true }); const INTERNAL_TYPE = Object.freeze({ by: "internalType", then: COUNT }); -const ALLOCATION_STACK = Object.freeze({ by: "allocationStack", then: COUNT, noStack: COUNT }); +const ALLOCATION_STACK = Object.freeze({ + by: "allocationStack", then: COUNT, + noStack: COUNT +}); const OBJECT_CLASS = Object.freeze({ by: "objectClass", then: COUNT, other: COUNT }); const COARSE_TYPE = Object.freeze({ by: "coarseType", diff --git a/devtools/client/memory/dominator-tree-lazy-children.js b/devtools/client/memory/dominator-tree-lazy-children.js index 85ae29a56697..f61efbc39161 100644 --- a/devtools/client/memory/dominator-tree-lazy-children.js +++ b/devtools/client/memory/dominator-tree-lazy-children.js @@ -2,6 +2,8 @@ * 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"; + /** * The `DominatorTreeLazyChildren` is a placeholder that represents a future * subtree in an existing `DominatorTreeNode` tree that is currently being diff --git a/devtools/client/memory/initializer.js b/devtools/client/memory/initializer.js index adb6e40c19f4..7f8271c30907 100644 --- a/devtools/client/memory/initializer.js +++ b/devtools/client/memory/initializer.js @@ -2,9 +2,11 @@ * 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/. */ +/* exported initialize, destroy */ + "use strict"; -const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; +const { utils: Cu } = Components; const BrowserLoaderModule = {}; Cu.import("resource://devtools/client/shared/browser-loader.js", BrowserLoaderModule); const { require } = BrowserLoaderModule.BrowserLoader({ @@ -20,19 +22,21 @@ const Store = require("devtools/client/memory/store"); const { assert } = require("devtools/shared/DevToolsUtils"); /** - * The current target, toolbox, MemoryFront, and HeapAnalysesClient, set by this tool's host. + * The current target, toolbox, MemoryFront, and HeapAnalysesClient, + * set by this tool's host. */ -var gToolbox, gTarget, gFront, gHeapAnalysesClient; +var gToolbox, gFront, gHeapAnalysesClient; /** * Variables set by `initialize()` */ -var gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted, telemetry; +var gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted; var initialize = Task.async(function* () { gRoot = document.querySelector("#app"); gStore = Store(); - gApp = createElement(App, { toolbox: gToolbox, front: gFront, heapWorker: gHeapAnalysesClient }); + gApp = createElement(App, + { toolbox: gToolbox, front: gFront, heapWorker: gHeapAnalysesClient }); gProvider = createElement(Provider, { store: gStore }, gApp); ReactDOM.render(gProvider, gRoot); unsubscribe = gStore.subscribe(onStateChange); @@ -44,7 +48,7 @@ var destroy = Task.async(function* () { unsubscribe(); - gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted; + gStore = gRoot = gApp = gProvider = unsubscribe = isHighlighted = null; }); /** diff --git a/devtools/client/memory/models.js b/devtools/client/memory/models.js index 7624f7accc52..248c5085fb41 100644 --- a/devtools/client/memory/models.js +++ b/devtools/client/memory/models.js @@ -2,6 +2,11 @@ * 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/. */ +/* global treeMapState, censusState */ +/* eslint no-shadow: ["error", { "allow": ["app"] }] */ + +"use strict"; + const { assert } = require("devtools/shared/DevToolsUtils"); const { MemoryFront } = require("devtools/shared/fronts/memory"); const HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient"); @@ -39,7 +44,9 @@ function catchAndIgnore(fn) { return function (...args) { try { fn(...args); - } catch (err) { } + } catch (err) { + // continue regardless of error + } return null; }; @@ -103,6 +110,7 @@ const treeMapModel = exports.treeMapModel = PropTypes.shape({ assert(!treeMap.report, "Should not have a report"); assert(!treeMap.error, "Should not have an error"); break; + case treeMapState.SAVED: assert(treeMap.report, "Should have a report"); assert(!treeMap.error, "Should not have an error"); @@ -443,7 +451,7 @@ const individualsModel = exports.individuals = PropTypes.shape({ }), }); -let appModel = exports.app = { +exports.app = { // {MemoryFront} Used to communicate with platform front: PropTypes.instanceOf(MemoryFront), @@ -494,7 +502,7 @@ let appModel = exports.app = { break; default: - assert(false, `Unexpected type of view: ${view.state}`); + assert(false, `Unexpected type of view: ${app.view.state}`); } })(app); @@ -512,7 +520,7 @@ let appModel = exports.app = { break; default: - assert(false, `Unexpected type of view: ${view.state}`); + assert(false, `Unexpected type of view: ${app.view.state}`); } })(app); }, diff --git a/devtools/client/memory/panel.js b/devtools/client/memory/panel.js index cf867faff0b9..092f1cb8a7fb 100644 --- a/devtools/client/memory/panel.js +++ b/devtools/client/memory/panel.js @@ -4,12 +4,10 @@ "use strict"; -const { Cc, Ci, Cu, Cr } = require("chrome"); const { Task } = require("devtools/shared/task"); const EventEmitter = require("devtools/shared/event-emitter"); const { MemoryFront } = require("devtools/shared/fronts/memory"); const HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient"); -const promise = require("promise"); function MemoryPanel(iframeWindow, toolbox) { this.panelWin = iframeWindow; diff --git a/devtools/client/memory/reducers/allocations.js b/devtools/client/memory/reducers/allocations.js index ccb92f825914..fc2130a8bf46 100644 --- a/devtools/client/memory/reducers/allocations.js +++ b/devtools/client/memory/reducers/allocations.js @@ -2,6 +2,8 @@ * 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"; + const { assert } = require("devtools/shared/DevToolsUtils"); const { actions } = require("../constants"); diff --git a/devtools/client/memory/reducers/errors.js b/devtools/client/memory/reducers/errors.js index 5fc282df2891..adb042cd4fe6 100644 --- a/devtools/client/memory/reducers/errors.js +++ b/devtools/client/memory/reducers/errors.js @@ -2,6 +2,8 @@ * 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"; + const { ERROR_TYPE: TASK_ERROR_TYPE } = require("devtools/client/shared/redux/middleware/task"); /** diff --git a/devtools/client/memory/reducers/filter.js b/devtools/client/memory/reducers/filter.js index 99188142c39a..a0f5f57efe02 100644 --- a/devtools/client/memory/reducers/filter.js +++ b/devtools/client/memory/reducers/filter.js @@ -8,7 +8,7 @@ const { actions } = require("../constants"); module.exports = function (filterString = null, action) { if (action.type === actions.SET_FILTER_STRING) { return action.filter || null; - } else { - return filterString; } + + return filterString; }; diff --git a/devtools/client/memory/reducers/snapshots.js b/devtools/client/memory/reducers/snapshots.js index 6293bdded078..5bb7c06e6dfd 100644 --- a/devtools/client/memory/reducers/snapshots.js +++ b/devtools/client/memory/reducers/snapshots.js @@ -240,23 +240,24 @@ handlers[actions.COMPUTE_DOMINATOR_TREE_START] = function (snapshots, { id }) { }); }; -handlers[actions.COMPUTE_DOMINATOR_TREE_END] = function (snapshots, { id, dominatorTreeId }) { - return snapshots.map(snapshot => { - if (snapshot.id !== id) { - return snapshot; - } +handlers[actions.COMPUTE_DOMINATOR_TREE_END] = + function (snapshots, { id, dominatorTreeId }) { + return snapshots.map(snapshot => { + if (snapshot.id !== id) { + return snapshot; + } - assert(snapshot.dominatorTree, "Should have a dominator tree model"); - assert(snapshot.dominatorTree.state == dominatorTreeState.COMPUTING, - "Should be in the COMPUTING state"); + assert(snapshot.dominatorTree, "Should have a dominator tree model"); + assert(snapshot.dominatorTree.state == dominatorTreeState.COMPUTING, + "Should be in the COMPUTING state"); - const dominatorTree = immutableUpdate(snapshot.dominatorTree, { - state: dominatorTreeState.COMPUTED, - dominatorTreeId, + const dominatorTree = immutableUpdate(snapshot.dominatorTree, { + state: dominatorTreeState.COMPUTED, + dominatorTreeId, + }); + return immutableUpdate(snapshot, { dominatorTree }); }); - return immutableUpdate(snapshot, { dominatorTree }); - }); -}; + }; handlers[actions.FETCH_DOMINATOR_TREE_START] = function (snapshots, { id, display }) { return snapshots.map(snapshot => { @@ -267,7 +268,8 @@ handlers[actions.FETCH_DOMINATOR_TREE_START] = function (snapshots, { id, displa assert(snapshot.dominatorTree, "Should have a dominator tree model"); assert(snapshot.dominatorTree.state !== dominatorTreeState.COMPUTING && snapshot.dominatorTree.state !== dominatorTreeState.ERROR, - `Should have already computed the dominator tree, found state = ${snapshot.dominatorTree.state}`); + "Should have already computed the dominator tree, found state = " + + snapshot.dominatorTree.state); const dominatorTree = immutableUpdate(snapshot.dominatorTree, { state: dominatorTreeState.FETCHING, diff --git a/devtools/client/memory/store.js b/devtools/client/memory/store.js index 3fd2e8a6812e..c245ccc6e565 100644 --- a/devtools/client/memory/store.js +++ b/devtools/client/memory/store.js @@ -2,10 +2,11 @@ * 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"; + const { combineReducers } = require("../shared/vendor/redux"); const createStore = require("../shared/redux/create-store"); const reducers = require("./reducers"); -const { viewState } = require("./constants"); const flags = require("devtools/shared/flags"); module.exports = function () { diff --git a/devtools/client/memory/telemetry.js b/devtools/client/memory/telemetry.js index 1e55805d31a7..4724af1ba983 100644 --- a/devtools/client/memory/telemetry.js +++ b/devtools/client/memory/telemetry.js @@ -2,6 +2,8 @@ * 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"; + // This module exports methods to record telemetry data for memory tool usage. // // NB: Ensure that *every* exported function is wrapped in `makeInfallible` so @@ -10,7 +12,7 @@ const { telemetry } = require("Services"); const { makeInfallible, immutableUpdate } = require("devtools/shared/DevToolsUtils"); -const { labelDisplays, treeMapDisplays, censusDisplays } = require("./constants"); +const { labelDisplays, censusDisplays } = require("./constants"); exports.countTakeSnapshot = makeInfallible(function () { const histogram = telemetry.getHistogramById("DEVTOOLS_MEMORY_TAKE_SNAPSHOT_COUNT"); @@ -80,7 +82,8 @@ exports.countDominatorTree = makeInfallible(function ({ display }) { let histogram = telemetry.getHistogramById("DEVTOOLS_MEMORY_DOMINATOR_TREE_COUNT"); histogram.add(1); - histogram = telemetry.getKeyedHistogramById("DEVTOOLS_MEMORY_BREAKDOWN_DOMINATOR_TREE_COUNT"); + histogram = + telemetry.getKeyedHistogramById("DEVTOOLS_MEMORY_BREAKDOWN_DOMINATOR_TREE_COUNT"); if (display === labelDisplays.coarseType) { histogram.add(COARSE_TYPE); } else if (display === labelDisplays.allocationStack) { diff --git a/devtools/client/memory/test/browser/.eslintrc.js b/devtools/client/memory/test/browser/.eslintrc.js index 698ae9181a0a..b3e235559723 100644 --- a/devtools/client/memory/test/browser/.eslintrc.js +++ b/devtools/client/memory/test/browser/.eslintrc.js @@ -2,5 +2,16 @@ module.exports = { // Extend from the shared list of defined globals for mochitests. - "extends": "../../../../.eslintrc.mochitests.js" + "extends": "../../../../.eslintrc.mochitests.js", + "globals": { + "addTab": true, + "censusState": true, + "refreshTab": true, + "removeTab": true, + "waitForTime": true, + "waitUntilState": true + }, + "rules": { + "no-unused-vars": ["error", { "vars": "local", "args": "none" }], + } }; diff --git a/devtools/client/memory/test/browser/browser_memory_clear_snapshots.js b/devtools/client/memory/test/browser/browser_memory_clear_snapshots.js index ca577bcd2541..7a5686566e98 100644 --- a/devtools/client/memory/test/browser/browser_memory_clear_snapshots.js +++ b/devtools/client/memory/test/browser/browser_memory_clear_snapshots.js @@ -1,36 +1,38 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Tests taking and then clearing snapshots. */ - const { treeMapState } = require("devtools/client/memory/constants"); - const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html"; +const { treeMapState } = require("devtools/client/memory/constants"); +const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html"; - this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { - const { gStore, document } = panel.panelWin; - const { getState, dispatch } = gStore; +this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { + const { gStore, document } = panel.panelWin; + const { getState } = gStore; - let snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); - is(getState().snapshots.length, 0, "Starts with no snapshots in store"); - is(snapshotEls.length, 0, "No snapshots visible"); + let snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); + is(getState().snapshots.length, 0, "Starts with no snapshots in store"); + is(snapshotEls.length, 0, "No snapshots visible"); - info("Take two snapshots"); - takeSnapshot(panel.panelWin); - takeSnapshot(panel.panelWin); - yield waitUntilState(gStore, state => - state.snapshots.length === 2 && - state.snapshots[0].treeMap && state.snapshots[1].treeMap && - state.snapshots[0].treeMap.state === treeMapState.SAVED && - state.snapshots[1].treeMap.state === treeMapState.SAVED); + info("Take two snapshots"); + takeSnapshot(panel.panelWin); + takeSnapshot(panel.panelWin); + yield waitUntilState(gStore, state => + state.snapshots.length === 2 && + state.snapshots[0].treeMap && state.snapshots[1].treeMap && + state.snapshots[0].treeMap.state === treeMapState.SAVED && + state.snapshots[1].treeMap.state === treeMapState.SAVED); - snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); - is(snapshotEls.length, 2, "Two snapshots visible"); + snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); + is(snapshotEls.length, 2, "Two snapshots visible"); - info("Click on Clear Snapshots"); - yield clearSnapshots(panel.panelWin); - is(getState().snapshots.length, 0, "No snapshots in store"); - snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); - is(snapshotEls.length, 0, "No snapshot visible"); - }); + info("Click on Clear Snapshots"); + yield clearSnapshots(panel.panelWin); + is(getState().snapshots.length, 0, "No snapshots in store"); + snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); + is(snapshotEls.length, 0, "No snapshot visible"); +}); diff --git a/devtools/client/memory/test/browser/browser_memory_diff_01.js b/devtools/client/memory/test/browser/browser_memory_diff_01.js index 0deb2a078701..70ea9e4ab888 100644 --- a/devtools/client/memory/test/browser/browser_memory_diff_01.js +++ b/devtools/client/memory/test/browser/browser_memory_diff_01.js @@ -6,7 +6,6 @@ "use strict"; const { - snapshotState, diffingState, treeMapState } = require("devtools/client/memory/constants"); @@ -14,10 +13,8 @@ const { const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html"; this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { - const heapWorker = panel.panelWin.gHeapAnalysesClient; - const front = panel.panelWin.gFront; const store = panel.panelWin.gStore; - const { getState, dispatch } = store; + const { getState } = store; const doc = panel.panelWin.document; ok(!getState().diffing, "Not diffing by default."); diff --git a/devtools/client/memory/test/browser/browser_memory_dominator_trees_01.js b/devtools/client/memory/test/browser/browser_memory_dominator_trees_01.js index 3380d6e211de..90bc633f3a96 100644 --- a/devtools/client/memory/test/browser/browser_memory_dominator_trees_01.js +++ b/devtools/client/memory/test/browser/browser_memory_dominator_trees_01.js @@ -111,7 +111,9 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { // Find the most up-to-date version of the node whose children we just // incrementally fetched. - const newDeepest = (function findNewDeepest(node = getState().snapshots[0].dominatorTree.root) { + const newDeepest = (function findNewDeepest(node = getState().snapshots[0] + .dominatorTree + .root) { if (node.nodeId === deepest.nodeId) { return node; } diff --git a/devtools/client/memory/test/browser/browser_memory_filter_01.js b/devtools/client/memory/test/browser/browser_memory_filter_01.js index 448e2aaa914b..7950d987b943 100644 --- a/devtools/client/memory/test/browser/browser_memory_filter_01.js +++ b/devtools/client/memory/test/browser/browser_memory_filter_01.js @@ -7,7 +7,6 @@ const { dominatorTreeState, - snapshotState, viewState, censusState, } = require("devtools/client/memory/constants"); @@ -17,9 +16,8 @@ const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { const heapWorker = panel.panelWin.gHeapAnalysesClient; - const front = panel.panelWin.gFront; const store = panel.panelWin.gStore; - const { getState, dispatch } = store; + const { dispatch } = store; const doc = panel.panelWin.document; dispatch(changeView(viewState.CENSUS)); @@ -49,7 +47,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { let nameElem = doc.querySelector(".heap-tree-item-field.heap-tree-item-name"); ok(nameElem, "Should get a tree item row with a name"); - is(nameElem.textContent.trim(), "js::Shape", "the tree item should be the one we filtered for"); + is(nameElem.textContent.trim(), "js::Shape", + "the tree item should be the one we filtered for"); is(filterInput.value, "js::Shape", "and filter input contains the user value"); diff --git a/devtools/client/memory/test/browser/browser_memory_individuals_01.js b/devtools/client/memory/test/browser/browser_memory_individuals_01.js index eae8248c3602..b902a569ba6c 100644 --- a/devtools/client/memory/test/browser/browser_memory_individuals_01.js +++ b/devtools/client/memory/test/browser/browser_memory_individuals_01.js @@ -11,15 +11,13 @@ const { viewState, censusState, } = require("devtools/client/memory/constants"); -const { changeViewAndRefresh, changeView } = require("devtools/client/memory/actions/view"); +const { changeView } = require("devtools/client/memory/actions/view"); const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html"; this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { - const heapWorker = panel.panelWin.gHeapAnalysesClient; - const front = panel.panelWin.gFront; const store = panel.panelWin.gStore; - const { getState, dispatch } = store; + const { dispatch } = store; const doc = panel.panelWin.document; dispatch(changeView(viewState.CENSUS)); diff --git a/devtools/client/memory/test/browser/browser_memory_keyboard-snapshot-list.js b/devtools/client/memory/test/browser/browser_memory_keyboard-snapshot-list.js index eb7cb8acaff1..3271c3330b0a 100644 --- a/devtools/client/memory/test/browser/browser_memory_keyboard-snapshot-list.js +++ b/devtools/client/memory/test/browser/browser_memory_keyboard-snapshot-list.js @@ -6,7 +6,6 @@ "use strict"; const { - snapshotState, viewState, censusState } = require("devtools/client/memory/constants"); diff --git a/devtools/client/memory/test/browser/browser_memory_keyboard.js b/devtools/client/memory/test/browser/browser_memory_keyboard.js index 243570f83269..f04e054b6731 100644 --- a/devtools/client/memory/test/browser/browser_memory_keyboard.js +++ b/devtools/client/memory/test/browser/browser_memory_keyboard.js @@ -7,7 +7,6 @@ "use strict"; const { - snapshotState, censusState, viewState } = require("devtools/client/memory/constants"); diff --git a/devtools/client/memory/test/browser/browser_memory_no_allocation_stacks.js b/devtools/client/memory/test/browser/browser_memory_no_allocation_stacks.js index cd87702856eb..0f309d6245d5 100644 --- a/devtools/client/memory/test/browser/browser_memory_no_allocation_stacks.js +++ b/devtools/client/memory/test/browser/browser_memory_no_allocation_stacks.js @@ -35,5 +35,6 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { "Should still not be recording allocagtions"); ok(doc.querySelector(".no-allocation-stacks"), - "Because we did not record allocations, the no-allocation-stack warning should be visible"); + "Because we did not record allocations, " + + "the no-allocation-stack warning should be visible"); }); diff --git a/devtools/client/memory/test/browser/browser_memory_no_auto_expand.js b/devtools/client/memory/test/browser/browser_memory_no_auto_expand.js index ffd481c744d5..d0c80153b2a5 100644 --- a/devtools/client/memory/test/browser/browser_memory_no_auto_expand.js +++ b/devtools/client/memory/test/browser/browser_memory_no_auto_expand.js @@ -27,7 +27,9 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { EventUtils.synthesizeMouseAtCenter(recordingCheckbox, {}, panel.panelWin); is(getState().allocations.recording, true); - const nameElems = [...doc.querySelectorAll(".heap-tree-item-field.heap-tree-item-name")]; + const nameElems = [ + ...doc.querySelectorAll(".heap-tree-item-field.heap-tree-item-name") + ]; for (let el of nameElems) { dumpn(`Found ${el.textContent.trim()}`); diff --git a/devtools/client/memory/test/browser/browser_memory_refresh_does_not_leak.js b/devtools/client/memory/test/browser/browser_memory_refresh_does_not_leak.js index 7ab768b01ceb..2f5ce8547f04 100644 --- a/devtools/client/memory/test/browser/browser_memory_refresh_does_not_leak.js +++ b/devtools/client/memory/test/browser/browser_memory_refresh_does_not_leak.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* global ChromeUtils */ + // Test that refreshing the page with devtools open does not leak the old // windows from previous navigations. // @@ -9,7 +11,6 @@ "use strict"; -const HeapSnapshotFileUtils = require("devtools/shared/heapsnapshot/HeapSnapshotFileUtils"); const { getLabelAndShallowSize } = require("devtools/shared/heapsnapshot/DominatorTreeNode"); const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_empty.html"; @@ -50,14 +51,11 @@ const DESCRIPTION = { }; this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { - const heapWorker = panel.panelWin.gHeapAnalysesClient; const front = panel.panelWin.gFront; - const store = panel.panelWin.gStore; - const { getState, dispatch } = store; - const doc = panel.panelWin.document; const startWindows = yield getWindowsInSnapshot(front); - dumpn("Initial windows found = " + startWindows.map(w => "0x" + w.toString(16)).join(", ")); + dumpn("Initial windows found = " + startWindows.map(w => "0x" + + w.toString(16)).join(", ")); is(startWindows.length, 1); yield refreshTab(tab); @@ -84,7 +82,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { const paths = snapshot.computeShortestPaths(dominatorTree.root, startWindows, 50); for (let i = 0; i < startWindows.length; i++) { - dumpn("Shortest retaining paths for leaking Window 0x" + startWindows[i].toString(16) + " ========================="); + dumpn("Shortest retaining paths for leaking Window 0x" + + startWindows[i].toString(16) + " ========================="); let j = 0; for (let retainingPath of paths.get(startWindows[i])) { if (retainingPath.find(part => part.predecessor === startWindows[i])) { @@ -92,7 +91,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { continue; } - dumpn(" Path #" + (++j) + ": --------------------------------------------------------------------"); + dumpn(" Path #" + (++j) + + ": --------------------------------------------------------------------"); for (let part of retainingPath) { const { label } = getLabelAndShallowSize(part.predecessor, snapshot, DESCRIPTION); dumpn(" 0x" + part.predecessor.toString(16) + diff --git a/devtools/client/memory/test/browser/browser_memory_simple_01.js b/devtools/client/memory/test/browser/browser_memory_simple_01.js index 9eaea2ad22b8..c4b78150a32e 100644 --- a/devtools/client/memory/test/browser/browser_memory_simple_01.js +++ b/devtools/client/memory/test/browser/browser_memory_simple_01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Tests taking snapshots and default states. */ @@ -23,17 +25,20 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); is(getState().snapshots.length, 1, "One snapshot was created in store"); is(snapshotEls.length, 1, "One snapshot was rendered"); - ok(snapshotEls[0].classList.contains("selected"), "Only snapshot has `selected` class"); + ok(snapshotEls[0].classList.contains("selected"), + "Only snapshot has `selected` class"); yield takeSnapshot(panel.panelWin); snapshotEls = document.querySelectorAll("#memory-tool-container .list li"); is(getState().snapshots.length, 2, "Two snapshots created in store"); is(snapshotEls.length, 2, "Two snapshots rendered"); - ok(!snapshotEls[0].classList.contains("selected"), "First snapshot no longer has `selected` class"); - ok(snapshotEls[1].classList.contains("selected"), "Second snapshot has `selected` class"); + ok(!snapshotEls[0].classList.contains("selected"), + "First snapshot no longer has `selected` class"); + ok(snapshotEls[1].classList.contains("selected"), + "Second snapshot has `selected` class"); - yield waitUntilCensusState(gStore, s => s.census, [censusState.SAVED, - censusState.SAVED]); + yield waitUntilCensusState(gStore, s => s.census, + [censusState.SAVED, censusState.SAVED]); ok(document.querySelector(".heap-tree-item-name"), "Should have rendered some tree items"); diff --git a/devtools/client/memory/test/browser/browser_memory_transferHeapSnapshot_e10s_01.js b/devtools/client/memory/test/browser/browser_memory_transferHeapSnapshot_e10s_01.js index 8ebb7622afc3..5d5a2cabec44 100644 --- a/devtools/client/memory/test/browser/browser_memory_transferHeapSnapshot_e10s_01.js +++ b/devtools/client/memory/test/browser/browser_memory_transferHeapSnapshot_e10s_01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/* global ChromeUtils, HeapSnapshot */ + // Test that we can save a heap snapshot and transfer it over the RDP in e10s // where the child process is sandboxed and so we have to use // HeapSnapshotFileActor to get the heap snapshot file. diff --git a/devtools/client/memory/test/browser/browser_memory_tree_map-02.js b/devtools/client/memory/test/browser/browser_memory_tree_map-02.js index 15f8b0457176..db549c8ca3f8 100644 --- a/devtools/client/memory/test/browser/browser_memory_tree_map-02.js +++ b/devtools/client/memory/test/browser/browser_memory_tree_map-02.js @@ -23,8 +23,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { width: "100px", height: "200px", position: "absolute", - left:0, - top:0 + left: 0, + top: 0 }); let rafMock = createRAFMock(); @@ -78,8 +78,6 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) { info("Dragging correctly translates the div"); { - let initialX = dragZoom.translateX; - let initialY = dragZoom.translateY; div.dispatchEvent(new MouseEvent("mousemove", { clientX: 10, clientY: 10, diff --git a/devtools/client/memory/test/browser/doc_big_tree.html b/devtools/client/memory/test/browser/doc_big_tree.html index 4ad60402a682..57dfdbe5335d 100644 --- a/devtools/client/memory/test/browser/doc_big_tree.html +++ b/devtools/client/memory/test/browser/doc_big_tree.html @@ -1,15 +1,17 @@ - - - + + + diff --git a/devtools/client/memory/test/browser/doc_steady_allocation.html b/devtools/client/memory/test/browser/doc_steady_allocation.html index 65703c878f87..aa34c4dcc96b 100644 --- a/devtools/client/memory/test/browser/doc_steady_allocation.html +++ b/devtools/client/memory/test/browser/doc_steady_allocation.html @@ -1,16 +1,18 @@ - - - + allocate(); + + diff --git a/devtools/client/memory/test/browser/head.js b/devtools/client/memory/test/browser/head.js index cb9b470ff75c..d47b37682ac3 100644 --- a/devtools/client/memory/test/browser/head.js +++ b/devtools/client/memory/test/browser/head.js @@ -109,7 +109,8 @@ function takeSnapshot(window) { let snapshotCount = gStore.getState().snapshots.length; info("Taking snapshot..."); document.querySelector(".devtools-toolbar .take-snapshot").click(); - return waitUntilState(gStore, () => gStore.getState().snapshots.length === snapshotCount + 1); + return waitUntilState(gStore, + () => gStore.getState().snapshots.length === snapshotCount + 1); } function clearSnapshots(window) { @@ -176,7 +177,6 @@ function waitUntilSnapshotSelected(store, snapshotIndex) { state.snapshots[snapshotIndex].selected === true); } - /** * Wait until the state has censuses in a certain state. * @@ -219,7 +219,7 @@ function createRAFMock() { mock.nextFrame = function () { let thisQueue = queuedFns; queuedFns = []; - for (var i = 0; i < thisQueue.length; i++) { + for (let i = 0; i < thisQueue.length; i++) { thisQueue[i](); } }; diff --git a/devtools/client/memory/test/chrome/.eslintrc.js b/devtools/client/memory/test/chrome/.eslintrc.js new file mode 100644 index 000000000000..fceb1d005eb8 --- /dev/null +++ b/devtools/client/memory/test/chrome/.eslintrc.js @@ -0,0 +1,14 @@ +"use strict"; + +module.exports = { + // Extend from the shared list of defined globals for mochitests. + "extends": "../../../../.eslintrc.mochitests.js", + "globals": { + "SimpleTest": true, + "ok": true, + "requestAnimationFrame": true + }, + "rules": { + "no-unused-vars": ["error", { "vars": "local", "args": "none" }], + } +}; diff --git a/devtools/client/memory/test/chrome/head.js b/devtools/client/memory/test/chrome/head.js index 39a6e583a8fe..00fb4c4823b0 100644 --- a/devtools/client/memory/test/chrome/head.js +++ b/devtools/client/memory/test/chrome/head.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; @@ -17,8 +18,9 @@ var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0; SimpleTest.registerCleanupFunction(function () { if (DevToolsUtils.assertionFailureCount !== EXPECTED_DTU_ASSERT_FAILURE_COUNT) { - ok(false, "Should have had the expected number of DevToolsUtils.assert() failures. Expected " + - EXPECTED_DTU_ASSERT_FAILURE_COUNT + ", got " + DevToolsUtils.assertionFailureCount); + ok(false, "Should have had the expected number of DevToolsUtils.assert() failures." + + "Expected " + EXPECTED_DTU_ASSERT_FAILURE_COUNT + + ", got " + DevToolsUtils.assertionFailureCount); } }); @@ -115,7 +117,9 @@ function makeTestDominatorTreeNode(opts, children) { }, opts); if (children && children.length) { - children.map(c => c.parentId = node.nodeId); + children.map(c => { + c.parentId = node.nodeId; + }); } return node; diff --git a/devtools/client/memory/test/unit/.eslintrc.js b/devtools/client/memory/test/unit/.eslintrc.js index aec096a0fc7d..5c4c68022e4d 100644 --- a/devtools/client/memory/test/unit/.eslintrc.js +++ b/devtools/client/memory/test/unit/.eslintrc.js @@ -2,5 +2,11 @@ module.exports = { // Extend from the shared list of defined globals for mochitests. - "extends": "../../../../.eslintrc.xpcshell.js" + "extends": "../../../../.eslintrc.xpcshell.js", + "rules": { + "no-unused-vars": ["error", { + "vars": "local", + "varsIgnorePattern": "^run_test$" + }] + } }; diff --git a/devtools/client/memory/test/unit/head.js b/devtools/client/memory/test/unit/head.js index f1335dc3da05..d68072301629 100644 --- a/devtools/client/memory/test/unit/head.js +++ b/devtools/client/memory/test/unit/head.js @@ -26,7 +26,8 @@ var HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClien var { addDebuggerToGlobal } = require("resource://gre/modules/jsdebugger.jsm"); var Store = require("devtools/client/memory/store"); var { L10N } = require("devtools/client/memory/utils"); -var SYSTEM_PRINCIPAL = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal); +var SYSTEM_PRINCIPAL = + Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal); var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0; @@ -59,17 +60,20 @@ StubbedMemoryFront.prototype.detach = Task.async(function* () { this.state = "detached"; }); -StubbedMemoryFront.prototype.saveHeapSnapshot = expectState("attached", Task.async(function* () { - return ThreadSafeChromeUtils.saveHeapSnapshot({ runtime: true }); -}), "saveHeapSnapshot"); +StubbedMemoryFront.prototype.saveHeapSnapshot = expectState("attached", + Task.async(function* () { + return ThreadSafeChromeUtils.saveHeapSnapshot({ runtime: true }); + }), "saveHeapSnapshot"); -StubbedMemoryFront.prototype.startRecordingAllocations = expectState("attached", Task.async(function* () { - this.recordingAllocations = true; -})); +StubbedMemoryFront.prototype.startRecordingAllocations = expectState("attached", + Task.async(function* () { + this.recordingAllocations = true; + })); -StubbedMemoryFront.prototype.stopRecordingAllocations = expectState("attached", Task.async(function* () { - this.recordingAllocations = false; -})); +StubbedMemoryFront.prototype.stopRecordingAllocations = expectState("attached", + Task.async(function* () { + this.recordingAllocations = false; + })); function waitUntilSnapshotState(store, expected) { let predicate = () => { diff --git a/devtools/client/memory/test/unit/test_action-clear-snapshots_01.js b/devtools/client/memory/test/unit/test_action-clear-snapshots_01.js index a4e611e84d5e..09bbeef8a14a 100644 --- a/devtools/client/memory/test/unit/test_action-clear-snapshots_01.js +++ b/devtools/client/memory/test/unit/test_action-clear-snapshots_01.js @@ -1,10 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test clearSnapshots deletes snapshots with READ censuses let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot"); -let { snapshotState: states, actions } = require("devtools/client/memory/constants"); +let { actions } = require("devtools/client/memory/constants"); const { treeMapState } = require("devtools/client/memory/constants"); function run_test() { diff --git a/devtools/client/memory/test/unit/test_action-clear-snapshots_02.js b/devtools/client/memory/test/unit/test_action-clear-snapshots_02.js index bb8c118cd3bb..d368b622d1a6 100644 --- a/devtools/client/memory/test/unit/test_action-clear-snapshots_02.js +++ b/devtools/client/memory/test/unit/test_action-clear-snapshots_02.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test clearSnapshots preserves snapshots with state != READ or ERROR let { takeSnapshotAndCensus, clearSnapshots, takeSnapshot } = require("devtools/client/memory/actions/snapshot"); diff --git a/devtools/client/memory/test/unit/test_action-clear-snapshots_03.js b/devtools/client/memory/test/unit/test_action-clear-snapshots_03.js index ae888f85835a..bc55799dc0cf 100644 --- a/devtools/client/memory/test/unit/test_action-clear-snapshots_03.js +++ b/devtools/client/memory/test/unit/test_action-clear-snapshots_03.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test clearSnapshots deletes snapshots with state ERROR let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot"); diff --git a/devtools/client/memory/test/unit/test_action-clear-snapshots_04.js b/devtools/client/memory/test/unit/test_action-clear-snapshots_04.js index f5b316b1a7c4..be1df341a656 100644 --- a/devtools/client/memory/test/unit/test_action-clear-snapshots_04.js +++ b/devtools/client/memory/test/unit/test_action-clear-snapshots_04.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test clearSnapshots deletes several snapshots let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot"); @@ -22,8 +24,7 @@ add_task(function* () { dispatch(takeSnapshotAndCensus(front, heapWorker)); dispatch(takeSnapshotAndCensus(front, heapWorker)); yield waitUntilCensusState(store, snapshot => snapshot.treeMap, - [treeMapState.SAVED, treeMapState.SAVED, - treeMapState.SAVED]); + [treeMapState.SAVED, treeMapState.SAVED, treeMapState.SAVED]); ok(true, "snapshots created with a saved census"); ok(true, "set first snapshot state to error"); diff --git a/devtools/client/memory/test/unit/test_action-clear-snapshots_05.js b/devtools/client/memory/test/unit/test_action-clear-snapshots_05.js index 9b889b3a4f33..463267d21c8a 100644 --- a/devtools/client/memory/test/unit/test_action-clear-snapshots_05.js +++ b/devtools/client/memory/test/unit/test_action-clear-snapshots_05.js @@ -1,10 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test clearSnapshots deletes several snapshots let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot"); -let { snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants"); +let { actions, treeMapState } = require("devtools/client/memory/constants"); function run_test() { run_next_test(); diff --git a/devtools/client/memory/test/unit/test_action-clear-snapshots_06.js b/devtools/client/memory/test/unit/test_action-clear-snapshots_06.js index 1ee32bb12902..0b20d8c48919 100644 --- a/devtools/client/memory/test/unit/test_action-clear-snapshots_06.js +++ b/devtools/client/memory/test/unit/test_action-clear-snapshots_06.js @@ -10,7 +10,6 @@ const { clearSnapshots } = require("devtools/client/memory/actions/snapshot"); const { - snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants"); diff --git a/devtools/client/memory/test/unit/test_action-export-snapshot.js b/devtools/client/memory/test/unit/test_action-export-snapshot.js index 0582abbf09dd..b576c17aa690 100644 --- a/devtools/client/memory/test/unit/test_action-export-snapshot.js +++ b/devtools/client/memory/test/unit/test_action-export-snapshot.js @@ -1,11 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test exporting a snapshot to a user specified location on disk. let { exportSnapshot } = require("devtools/client/memory/actions/io"); let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); -let { snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants"); +let { actions, treeMapState } = require("devtools/client/memory/constants"); function run_test() { run_next_test(); diff --git a/devtools/client/memory/test/unit/test_action-filter-01.js b/devtools/client/memory/test/unit/test_action-filter-01.js index e0894606d5b7..ca79caab1006 100644 --- a/devtools/client/memory/test/unit/test_action-filter-01.js +++ b/devtools/client/memory/test/unit/test_action-filter-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test setting the filter string. let { setFilterString } = require("devtools/client/memory/actions/filter"); diff --git a/devtools/client/memory/test/unit/test_action-filter-02.js b/devtools/client/memory/test/unit/test_action-filter-02.js index 31d777704dc7..4309a9e6a65a 100644 --- a/devtools/client/memory/test/unit/test_action-filter-02.js +++ b/devtools/client/memory/test/unit/test_action-filter-02.js @@ -1,13 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test that changing filter state properly refreshes the selected census. -let { snapshotState: states, viewState, censusState } = require("devtools/client/memory/constants"); +let { viewState, censusState } = require("devtools/client/memory/constants"); let { setFilterStringAndRefresh } = require("devtools/client/memory/actions/filter"); let { takeSnapshotAndCensus, selectSnapshotAndRefresh } = require("devtools/client/memory/actions/snapshot"); -let { setCensusDisplay } = require("devtools/client/memory/actions/census-display"); let { changeView } = require("devtools/client/memory/actions/view"); function run_test() { @@ -30,24 +30,18 @@ add_task(function* () { dispatch(takeSnapshotAndCensus(front, heapWorker)); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); ok(true, "saved 3 snapshots and took a census of each of them"); dispatch(setFilterStringAndRefresh("str", heapWorker)); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVED, - censusState.SAVING]); + [censusState.SAVED, censusState.SAVED, censusState.SAVING]); ok(true, "setting filter string should recompute the selected snapshot's census"); equal(getState().filter, "str", "now inverted"); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); equal(getState().snapshots[0].census.filter, null); equal(getState().snapshots[1].census.filter, null); @@ -55,15 +49,11 @@ add_task(function* () { dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id)); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVING, - censusState.SAVED]); + [censusState.SAVED, censusState.SAVING, censusState.SAVED]); ok(true, "selecting non-inverted census should trigger a recompute"); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); equal(getState().snapshots[0].census.filter, null); equal(getState().snapshots[1].census.filter, "str"); diff --git a/devtools/client/memory/test/unit/test_action-filter-03.js b/devtools/client/memory/test/unit/test_action-filter-03.js index 4d46d53611b3..30da94ff2152 100644 --- a/devtools/client/memory/test/unit/test_action-filter-03.js +++ b/devtools/client/memory/test/unit/test_action-filter-03.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that changing filter state in the middle of taking a snapshot results in // the properly fitered census. diff --git a/devtools/client/memory/test/unit/test_action-import-snapshot-and-census.js b/devtools/client/memory/test/unit/test_action-import-snapshot-and-census.js index a7e1d366ad29..be4ebdc1cd1e 100644 --- a/devtools/client/memory/test/unit/test_action-import-snapshot-and-census.js +++ b/devtools/client/memory/test/unit/test_action-import-snapshot-and-census.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** @@ -61,13 +62,19 @@ add_task(function* () { let unsubscribe = subscribe(expectStates); dispatch(importSnapshotAndCensus(heapWorker, destPath)); - yield waitUntilState(store, () => { return snapshotI === snapshotStates.length && - censusI === censusStates.length; }); + yield waitUntilState(store, () => { + return snapshotI === snapshotStates.length && + censusI === censusStates.length; + }); unsubscribe(); - equal(snapshotI, snapshotStates.length, "importSnapshotAndCensus() produces the correct sequence of states in a snapshot"); - equal(getState().snapshots[1].state, states.READ, "imported snapshot is in READ state"); - equal(censusI, censusStates.length, "importSnapshotAndCensus() produces the correct sequence of states in a census"); - equal(getState().snapshots[1].treeMap.state, treeMapState.SAVED, "imported snapshot is in READ state"); + equal(snapshotI, snapshotStates.length, + "importSnapshotAndCensus() produces the correct sequence of states in a snapshot"); + equal(getState().snapshots[1].state, states.READ, + "imported snapshot is in READ state"); + equal(censusI, censusStates.length, + "importSnapshotAndCensus() produces the correct sequence of states in a census"); + equal(getState().snapshots[1].treeMap.state, treeMapState.SAVED, + "imported snapshot is in READ state"); ok(getState().snapshots[1].selected, "imported snapshot is selected"); // Check snapshot data @@ -82,7 +89,8 @@ add_task(function* () { let census1 = stripUnique(JSON.parse(JSON.stringify(snapshot1.treeMap.report))); let census2 = stripUnique(JSON.parse(JSON.stringify(snapshot2.treeMap.report))); - equal(JSON.stringify(census1), JSON.stringify(census2), "Imported snapshot has correct census"); + equal(JSON.stringify(census1), JSON.stringify(census2), + "Imported snapshot has correct census"); function stripUnique(obj) { let children = obj.children || []; diff --git a/devtools/client/memory/test/unit/test_action-import-snapshot-dominator-tree.js b/devtools/client/memory/test/unit/test_action-import-snapshot-dominator-tree.js index 868f22ccfdc9..3aa9c56a05c9 100644 --- a/devtools/client/memory/test/unit/test_action-import-snapshot-dominator-tree.js +++ b/devtools/client/memory/test/unit/test_action-import-snapshot-dominator-tree.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** diff --git a/devtools/client/memory/test/unit/test_action-select-snapshot.js b/devtools/client/memory/test/unit/test_action-select-snapshot.js index 2329ab2fa52f..0e547fcfdec9 100644 --- a/devtools/client/memory/test/unit/test_action-select-snapshot.js +++ b/devtools/client/memory/test/unit/test_action-select-snapshot.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Tests the reducer responding to the action `selectSnapshot(snapshot)` */ @@ -21,7 +23,8 @@ add_task(function* () { store.dispatch(actions.takeSnapshot(front)); } - yield waitUntilState(store, ({ snapshots }) => snapshots.length === 5 && snapshots.every(isDone)); + yield waitUntilState(store, + ({ snapshots }) => snapshots.length === 5 && snapshots.every(isDone)); for (let i = 0; i < 5; i++) { do_print(`Selecting snapshot[${i}]`); @@ -30,8 +33,11 @@ add_task(function* () { let { snapshots } = store.getState(); ok(snapshots[i].selected, `snapshot[${i}] selected`); - equal(snapshots.filter(s => !s.selected).length, 4, "All other snapshots are unselected"); + equal(snapshots.filter(s => !s.selected).length, 4, + "All other snapshots are unselected"); } }); -function isDone(s) { return s.state === states.SAVED; } +function isDone(s) { + return s.state === states.SAVED; +} diff --git a/devtools/client/memory/test/unit/test_action-set-display-and-refresh-01.js b/devtools/client/memory/test/unit/test_action-set-display-and-refresh-01.js index 570ffdf059fd..a4ad1a91aefc 100644 --- a/devtools/client/memory/test/unit/test_action-set-display-and-refresh-01.js +++ b/devtools/client/memory/test/unit/test_action-set-display-and-refresh-01.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** @@ -9,7 +10,7 @@ * `setCensusDisplayAndRefresh`. */ -let { censusDisplays, snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants"); +let { censusDisplays, censusState, viewState } = require("devtools/client/memory/constants"); let { setCensusDisplayAndRefresh } = require("devtools/client/memory/actions/census-display"); let { takeSnapshotAndCensus, selectSnapshotAndRefresh } = require("devtools/client/memory/actions/snapshot"); const { changeView } = require("devtools/client/memory/actions/view"); @@ -63,51 +64,49 @@ add_task(function* () { yield waitUntilCensusState(store, snapshot => snapshot.census, [censusState.SAVED, censusState.SAVED]); equal(getState().snapshots[1].census.display, censusDisplays.coarseType, - "Changing display while saving a snapshot results in a census using the new display"); - + "Changing display while saving a snapshot results " + + "in a census using the new display"); // Updates when changing display during `SAVING_CENSUS` dispatch(takeSnapshotAndCensus(front, heapWorker)); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVED, - censusState.SAVING]); + [censusState.SAVED, censusState.SAVED, censusState.SAVING]); dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack)); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); equal(getState().snapshots[2].census.display, censusDisplays.allocationStack, "Display can be changed while saving census, stores updated display in snapshot"); // Updates census on currently selected snapshot when changing display ok(getState().snapshots[2].selected, "Third snapshot currently selected"); dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.coarseType)); - yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVING); - yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVED); + yield waitUntilState(store, + state => state.snapshots[2].census.state === censusState.SAVING); + yield waitUntilState(store, + state => state.snapshots[2].census.state === censusState.SAVED); equal(getState().snapshots[2].census.display, censusDisplays.coarseType, - "Snapshot census updated when changing displays after already generating one census"); + "Snapshot census updated when changing displays " + + "after already generating one census"); dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack)); - yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVED); + yield waitUntilState(store, + state => state.snapshots[2].census.state === censusState.SAVED); equal(getState().snapshots[2].census.display, censusDisplays.allocationStack, - "Snapshot census updated when changing displays after already generating one census"); + "Snapshot census updated when changing displays " + + "after already generating one census"); // Does not update unselected censuses. ok(!getState().snapshots[1].selected, "Second snapshot selected currently"); equal(getState().snapshots[1].census.display, censusDisplays.coarseType, - "Second snapshot using `coarseType` display still and not yet updated to correct display"); + "Second snapshot using `coarseType` display still and " + + "not yet updated to correct display"); // Updates to current display when switching to stale snapshot. dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id)); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVING, - censusState.SAVED]); + [censusState.SAVED, censusState.SAVING, censusState.SAVED]); yield waitUntilCensusState(store, snapshot => snapshot.census, - [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); ok(getState().snapshots[1].selected, "Second snapshot selected currently"); equal(getState().snapshots[1].census.display, censusDisplays.allocationStack, diff --git a/devtools/client/memory/test/unit/test_action-set-display-and-refresh-02.js b/devtools/client/memory/test/unit/test_action-set-display-and-refresh-02.js index 5be5444d4e92..c9571bbc32e4 100644 --- a/devtools/client/memory/test/unit/test_action-set-display-and-refresh-02.js +++ b/devtools/client/memory/test/unit/test_action-set-display-and-refresh-02.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** @@ -7,7 +8,7 @@ * displays. */ -let { snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants"); +let { censusState, viewState } = require("devtools/client/memory/constants"); let { setCensusDisplayAndRefresh } = require("devtools/client/memory/actions/census-display"); let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); let { changeView } = require("devtools/client/memory/actions/view"); @@ -48,6 +49,7 @@ add_task(function* () { ok(getState().snapshots[0].census.report.children.every(c => !c.count), "Census used CUSTOM display without counts"); // Ensure we do have `bytes` in the results - ok(getState().snapshots[0].census.report.children.every(c => typeof c.bytes === "number"), + ok(getState().snapshots[0].census.report.children + .every(c => typeof c.bytes === "number"), "Census used CUSTOM display with bytes"); }); diff --git a/devtools/client/memory/test/unit/test_action-set-display.js b/devtools/client/memory/test/unit/test_action-set-display.js index 43ea975da894..36e7e429f3c5 100644 --- a/devtools/client/memory/test/unit/test_action-set-display.js +++ b/devtools/client/memory/test/unit/test_action-set-display.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** @@ -8,7 +9,7 @@ * action for that. */ -let { censusDisplays, snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants"); +let { censusDisplays, censusState, viewState } = require("devtools/client/memory/constants"); let { setCensusDisplay } = require("devtools/client/memory/actions/census-display"); let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); const { changeView } = require("devtools/client/memory/actions/view"); diff --git a/devtools/client/memory/test/unit/test_action-take-census.js b/devtools/client/memory/test/unit/test_action-take-census.js index 3e3d30e8e449..e85a4feed62f 100644 --- a/devtools/client/memory/test/unit/test_action-take-census.js +++ b/devtools/client/memory/test/unit/test_action-take-census.js @@ -1,15 +1,16 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Tests the async reducer responding to the action `takeCensus(heapWorker, snapshot)` */ -var { snapshotState: states, censusDisplays, censusState, censusState, viewState } = require("devtools/client/memory/constants"); +var { snapshotState: states, censusDisplays, censusState, viewState } = require("devtools/client/memory/constants"); var actions = require("devtools/client/memory/actions/snapshot"); var { changeView } = require("devtools/client/memory/actions/view"); - function run_test() { run_next_test(); } @@ -55,5 +56,4 @@ add_task(function* () { ok(snapshot.census.report.children.length, "Census is in tree node form"); equal(snapshot.census.display, censusDisplays.coarseType, "Snapshot stored correct display used for the census"); - }); diff --git a/devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js b/devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js index 77c3b8e3842c..c9a0e71bdcb7 100644 --- a/devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js +++ b/devtools/client/memory/test/unit/test_action-take-snapshot-and-census.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Tests the task creator `takeSnapshotAndCensus()` for the whole flow of * taking a snapshot, and its sub-actions. @@ -43,15 +45,17 @@ add_task(function* () { } }; - let unsubscribe = store.subscribe(expectStates); store.dispatch(actions.takeSnapshotAndCensus(front, heapWorker)); - yield waitUntilState(store, () => { return snapshotI === snapshotStates.length && - censusI === censusStates.length; }); + yield waitUntilState(store, () => { + return snapshotI === snapshotStates.length && + censusI === censusStates.length; + }); unsubscribe(); - ok(true, "takeSnapshotAndCensus() produces the correct sequence of states in a snapshot"); + ok(true, + "takeSnapshotAndCensus() produces the correct sequence of states in a snapshot"); let snapshot = store.getState().snapshots[0]; ok(snapshot.treeMap, "snapshot has tree map census data"); ok(snapshot.selected, "snapshot is selected"); diff --git a/devtools/client/memory/test/unit/test_action-take-snapshot.js b/devtools/client/memory/test/unit/test_action-take-snapshot.js index c05583b22709..fac02e9b0f96 100644 --- a/devtools/client/memory/test/unit/test_action-take-snapshot.js +++ b/devtools/client/memory/test/unit/test_action-take-snapshot.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Tests the async reducer responding to the action `takeSnapshot(front)` */ @@ -31,8 +33,7 @@ add_task(function* () { ok(foundPendingState, "Got state change for pending heap snapshot request"); ok(!lastSnapshot.path, "Snapshot does not yet have a path"); ok(!lastSnapshot.census, "Has no census data when loading"); - } - else if (lastSnapshot.state === states.SAVED) { + } else if (lastSnapshot.state === states.SAVED) { foundDoneState = true; ok(foundDoneState, "Got state change for completed heap snapshot request"); ok(foundPendingState, "SAVED state occurs after SAVING state"); diff --git a/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-01.js b/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-01.js index cd015557d418..c1c5f3bd2a54 100644 --- a/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-01.js +++ b/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-01.js @@ -1,12 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that changing displays with different inverted state properly // refreshes the selected census. const { censusDisplays, - snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants"); @@ -40,38 +41,34 @@ add_task(function* () { dispatch(takeSnapshotAndCensus(front, heapWorker)); dispatch(takeSnapshotAndCensus(front, heapWorker)); - yield waitUntilCensusState(store, s => s.census, [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + yield waitUntilCensusState(store, s => s.census, + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); ok(true, "saved 3 snapshots and took a census of each of them"); // Select an inverted display. - dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.invertedAllocationStack)); + dispatch(setCensusDisplayAndRefresh(heapWorker, + censusDisplays.invertedAllocationStack)); - yield waitUntilCensusState(store, s => s.census, [censusState.SAVED, - censusState.SAVED, - censusState.SAVING]); + yield waitUntilCensusState(store, s => s.census, + [censusState.SAVED, censusState.SAVED, censusState.SAVING]); ok(true, "toggling inverted should recompute the selected snapshot's census"); equal(getState().censusDisplay.inverted, true, "now inverted"); - yield waitUntilCensusState(store, s => s.census, [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + yield waitUntilCensusState(store, s => s.census, + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); equal(getState().snapshots[0].census.display.inverted, false); equal(getState().snapshots[1].census.display.inverted, false); equal(getState().snapshots[2].census.display.inverted, true); dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id)); - yield waitUntilCensusState(store, s => s.census, [censusState.SAVED, - censusState.SAVING, - censusState.SAVED]); + yield waitUntilCensusState(store, s => s.census, + [censusState.SAVED, censusState.SAVING, censusState.SAVED]); ok(true, "selecting non-inverted census should trigger a recompute"); - yield waitUntilCensusState(store, s => s.census, [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + yield waitUntilCensusState(store, s => s.census, + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); equal(getState().snapshots[0].census.display.inverted, false); equal(getState().snapshots[1].census.display.inverted, true); diff --git a/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-02.js b/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-02.js index f0cdba264ecf..6d87d9da68b8 100644 --- a/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-02.js +++ b/devtools/client/memory/test/unit/test_action-toggle-inverted-and-refresh-02.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test that changing inverted state in the middle of taking a snapshot results @@ -33,7 +34,8 @@ add_task(function* () { dispatch(takeSnapshotAndCensus(front, heapWorker)); yield waitUntilSnapshotState(store, [states.SAVING]); - dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.invertedAllocationStack)); + dispatch(setCensusDisplayAndRefresh(heapWorker, + censusDisplays.invertedAllocationStack)); yield waitUntilCensusState(store, s => s.census, [censusState.SAVED]); @@ -47,7 +49,8 @@ add_task(function* () { ok(true, "toggling inverted retriggers census"); ok(!getState().censusDisplay.inverted, "no longer inverted"); - dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.invertedAllocationStack)); + dispatch(setCensusDisplayAndRefresh(heapWorker, + censusDisplays.invertedAllocationStack)); yield waitUntilCensusState(store, s => s.census, [censusState.SAVED]); ok(getState().censusDisplay.inverted, "inverted again"); ok(getState().snapshots[0].census.display.inverted, diff --git a/devtools/client/memory/test/unit/test_action-toggle-inverted.js b/devtools/client/memory/test/unit/test_action-toggle-inverted.js index 665e5d822aaa..abdc46323806 100644 --- a/devtools/client/memory/test/unit/test_action-toggle-inverted.js +++ b/devtools/client/memory/test/unit/test_action-toggle-inverted.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test toggling the top level inversion state of the tree. diff --git a/devtools/client/memory/test/unit/test_action-toggle-recording-allocations.js b/devtools/client/memory/test/unit/test_action-toggle-recording-allocations.js index ebbc17173615..8bff3c42d37d 100644 --- a/devtools/client/memory/test/unit/test_action-toggle-recording-allocations.js +++ b/devtools/client/memory/test/unit/test_action-toggle-recording-allocations.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** diff --git a/devtools/client/memory/test/unit/test_action_diffing_01.js b/devtools/client/memory/test/unit/test_action_diffing_01.js index 24893581ea45..5a9d69aa837c 100644 --- a/devtools/client/memory/test/unit/test_action_diffing_01.js +++ b/devtools/client/memory/test/unit/test_action_diffing_01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test toggling of diffing. const { toggleDiffing } = require("devtools/client/memory/actions/diffing"); diff --git a/devtools/client/memory/test/unit/test_action_diffing_02.js b/devtools/client/memory/test/unit/test_action_diffing_02.js index fc68cee65ea2..a24267eab632 100644 --- a/devtools/client/memory/test/unit/test_action_diffing_02.js +++ b/devtools/client/memory/test/unit/test_action_diffing_02.js @@ -1,9 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that toggling diffing unselects all snapshots. -const { snapshotState, censusState, viewState } = require("devtools/client/memory/constants"); +const { censusState, viewState } = require("devtools/client/memory/constants"); const { toggleDiffing } = require("devtools/client/memory/actions/diffing"); const { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); const { changeView } = require("devtools/client/memory/actions/view"); @@ -26,9 +28,8 @@ add_task(function* () { dispatch(takeSnapshotAndCensus(front, heapWorker)); dispatch(takeSnapshotAndCensus(front, heapWorker)); dispatch(takeSnapshotAndCensus(front, heapWorker)); - yield waitUntilCensusState(store, s => s.census, [censusState.SAVED, - censusState.SAVED, - censusState.SAVED]); + yield waitUntilCensusState(store, s => s.census, + [censusState.SAVED, censusState.SAVED, censusState.SAVED]); ok(getState().snapshots.some(s => s.selected), "One of the new snapshots is selected"); diff --git a/devtools/client/memory/test/unit/test_action_diffing_03.js b/devtools/client/memory/test/unit/test_action_diffing_03.js index 3dd901724185..ef46b1308cf0 100644 --- a/devtools/client/memory/test/unit/test_action_diffing_03.js +++ b/devtools/client/memory/test/unit/test_action_diffing_03.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test selecting snapshots for diffing. const { diffingState, snapshotState, viewState } = require("devtools/client/memory/constants"); @@ -34,9 +36,8 @@ add_task(function* () { dispatch(takeSnapshot(front, heapWorker)); dispatch(takeSnapshot(front, heapWorker)); - yield waitUntilSnapshotState(store, [snapshotState.SAVED, - snapshotState.SAVED, - snapshotState.SAVED]); + yield waitUntilSnapshotState(store, + [snapshotState.SAVED, snapshotState.SAVED, snapshotState.SAVED]); dispatch(takeSnapshot(front)); // Start diffing. diff --git a/devtools/client/memory/test/unit/test_action_diffing_04.js b/devtools/client/memory/test/unit/test_action_diffing_04.js index 2c3cd098b114..4095f4459215 100644 --- a/devtools/client/memory/test/unit/test_action_diffing_04.js +++ b/devtools/client/memory/test/unit/test_action_diffing_04.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we compute census diffs. const { @@ -38,9 +40,8 @@ add_task(function* () { dispatch(readSnapshot(heapWorker, s1)); dispatch(readSnapshot(heapWorker, s2)); dispatch(readSnapshot(heapWorker, s3)); - yield waitUntilSnapshotState(store, [snapshotState.READ, - snapshotState.READ, - snapshotState.READ]); + yield waitUntilSnapshotState(store, + [snapshotState.READ, snapshotState.READ, snapshotState.READ]); dispatch(toggleDiffing()); dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, diff --git a/devtools/client/memory/test/unit/test_action_diffing_05.js b/devtools/client/memory/test/unit/test_action_diffing_05.js index e4a1491ac90d..d15e6a6582fb 100644 --- a/devtools/client/memory/test/unit/test_action_diffing_05.js +++ b/devtools/client/memory/test/unit/test_action_diffing_05.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we recompute census diffs at the appropriate times. const { @@ -50,9 +52,8 @@ add_task(function* () { dispatch(readSnapshot(heapWorker, s1)); dispatch(readSnapshot(heapWorker, s2)); dispatch(readSnapshot(heapWorker, s3)); - yield waitUntilSnapshotState(store, [snapshotState.READ, - snapshotState.READ, - snapshotState.READ]); + yield waitUntilSnapshotState(store, + [snapshotState.READ, snapshotState.READ, snapshotState.READ]); yield dispatch(toggleDiffing()); dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, diff --git a/devtools/client/memory/test/unit/test_dominator_trees_01.js b/devtools/client/memory/test/unit/test_dominator_trees_01.js index 5fcf441d40d4..444a30293ee7 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_01.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_01.js @@ -1,10 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we can compute and fetch the dominator tree for a snapshot. let { - snapshotState: states, dominatorTreeState, treeMapState, } = require("devtools/client/memory/constants"); diff --git a/devtools/client/memory/test/unit/test_dominator_trees_02.js b/devtools/client/memory/test/unit/test_dominator_trees_02.js index b35961004fa3..586dda9405a7 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_02.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_02.js @@ -1,11 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that selecting the dominator tree view automatically kicks off fetching // and computing dominator trees. const { - snapshotState: states, dominatorTreeState, viewState, treeMapState, diff --git a/devtools/client/memory/test/unit/test_dominator_trees_03.js b/devtools/client/memory/test/unit/test_dominator_trees_03.js index 09e6477f4f8a..7c88124141e4 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_03.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_03.js @@ -1,11 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that selecting the dominator tree view and then taking a snapshot // properly kicks off fetching and computing dominator trees. const { - snapshotState: states, dominatorTreeState, viewState, } = require("devtools/client/memory/constants"); diff --git a/devtools/client/memory/test/unit/test_dominator_trees_04.js b/devtools/client/memory/test/unit/test_dominator_trees_04.js index ba375c35429f..a588ddeb4030 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_04.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_04.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that selecting the dominator tree view while in the middle of taking a // snapshot properly kicks off fetching and computing dominator trees. @@ -25,10 +27,9 @@ add_task(function* () { let heapWorker = new HeapAnalysesClient(); yield front.attach(); - for (let intermediateSnapshotState of [states.SAVING, - states.READING, - states.READ]) { - dumpn(`Testing switching to the DOMINATOR_TREE view in the middle of the ${intermediateSnapshotState} snapshot state`); + for (let intermediateSnapshotState of [states.SAVING, states.READING, states.READ]) { + dumpn("Testing switching to the DOMINATOR_TREE view in the middle of the " + + `${intermediateSnapshotState} snapshot state`); let store = Store(); let { getState, dispatch } = store; diff --git a/devtools/client/memory/test/unit/test_dominator_trees_05.js b/devtools/client/memory/test/unit/test_dominator_trees_05.js index 42ea13e188c6..1d151d906aed 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_05.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_05.js @@ -1,11 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that changing the currently selected snapshot to a snapshot that does // not have a dominator tree will automatically compute and fetch one for it. let { - snapshotState: states, dominatorTreeState, viewState, treeMapState, @@ -30,8 +31,8 @@ add_task(function* () { dispatch(takeSnapshotAndCensus(front, heapWorker)); dispatch(takeSnapshotAndCensus(front, heapWorker)); - yield waitUntilCensusState(store, s => s.treeMap, [treeMapState.SAVED, - treeMapState.SAVED]); + yield waitUntilCensusState(store, s => s.treeMap, + [treeMapState.SAVED, treeMapState.SAVED]); ok(getState().snapshots[1].selected, "The second snapshot is selected"); diff --git a/devtools/client/memory/test/unit/test_dominator_trees_06.js b/devtools/client/memory/test/unit/test_dominator_trees_06.js index 78f869102f80..ff92d7088afe 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_06.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_06.js @@ -1,16 +1,16 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we can incrementally fetch a subtree of a dominator tree. const { - snapshotState: states, dominatorTreeState, viewState, } = require("devtools/client/memory/constants"); const { takeSnapshotAndCensus, - selectSnapshotAndRefresh, fetchImmediatelyDominated, } = require("devtools/client/memory/actions/snapshot"); const DominatorTreeLazyChildren @@ -68,7 +68,8 @@ add_task(function* () { ok(oldNode !== oldRoot, "But the node should not be the root"); const lazyChildren = new DominatorTreeLazyChildren(oldNode.nodeId, 0); - dispatch(fetchImmediatelyDominated(heapWorker, getState().snapshots[0].id, lazyChildren)); + dispatch(fetchImmediatelyDominated(heapWorker, getState().snapshots[0].id, + lazyChildren)); equal(getState().snapshots[0].dominatorTree.state, dominatorTreeState.INCREMENTAL_FETCHING, @@ -119,7 +120,8 @@ add_task(function* () { const newNode = findNewNode(newRoot); ok(newNode, "Should find the node in the new tree again"); - ok(newNode !== oldNode, "We did not mutate the old node in place, instead created a new node"); + ok(newNode !== oldNode, + "We did not mutate the old node in place, instead created a new node"); ok(newNode.children, "And the new node should have the children attached"); heapWorker.destroy(); diff --git a/devtools/client/memory/test/unit/test_dominator_trees_07.js b/devtools/client/memory/test/unit/test_dominator_trees_07.js index 9121fc878a8b..0470a9a723d0 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_07.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_07.js @@ -1,17 +1,17 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we can incrementally fetch two subtrees in the same dominator tree // concurrently. This exercises the activeFetchRequestCount machinery. const { - snapshotState: states, dominatorTreeState, viewState, } = require("devtools/client/memory/constants"); const { takeSnapshotAndCensus, - selectSnapshotAndRefresh, fetchImmediatelyDominated, } = require("devtools/client/memory/actions/snapshot"); const DominatorTreeLazyChildren diff --git a/devtools/client/memory/test/unit/test_dominator_trees_08.js b/devtools/client/memory/test/unit/test_dominator_trees_08.js index 27f35180c733..236bb1203cd1 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_08.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_08.js @@ -1,11 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we can change the display with which we describe a dominator tree // and that the dominator tree is re-fetched. const { - snapshotState: states, dominatorTreeState, viewState, labelDisplays, @@ -19,7 +20,6 @@ const { } = require("devtools/client/memory/actions/view"); const { takeSnapshotAndCensus, - computeAndFetchDominatorTree, } = require("devtools/client/memory/actions/snapshot"); function run_test() { diff --git a/devtools/client/memory/test/unit/test_dominator_trees_09.js b/devtools/client/memory/test/unit/test_dominator_trees_09.js index c1d1f749593d..5658dc98d44a 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_09.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_09.js @@ -1,11 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we can change the display with which we describe a dominator tree // while the dominator tree is in the middle of being fetched. const { - snapshotState: states, dominatorTreeState, viewState, labelDisplays, @@ -19,7 +20,6 @@ const { } = require("devtools/client/memory/actions/view"); const { takeSnapshotAndCensus, - computeAndFetchDominatorTree, } = require("devtools/client/memory/actions/snapshot"); function run_test() { diff --git a/devtools/client/memory/test/unit/test_dominator_trees_10.js b/devtools/client/memory/test/unit/test_dominator_trees_10.js index f7cf86a10803..b0759fb24590 100644 --- a/devtools/client/memory/test/unit/test_dominator_trees_10.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_10.js @@ -1,11 +1,12 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we maintain focus of the selected dominator tree node across // changing breakdowns for labeling them. let { - snapshotState: states, dominatorTreeState, labelDisplays, viewState, diff --git a/devtools/client/memory/test/unit/test_individuals_01.js b/devtools/client/memory/test/unit/test_individuals_01.js index 36971a7dc80c..1ad3958b387b 100644 --- a/devtools/client/memory/test/unit/test_individuals_01.js +++ b/devtools/client/memory/test/unit/test_individuals_01.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Basic test for switching to the individuals view. diff --git a/devtools/client/memory/test/unit/test_individuals_02.js b/devtools/client/memory/test/unit/test_individuals_02.js index 9e23e2c4f2f0..176d79d06a1c 100644 --- a/devtools/client/memory/test/unit/test_individuals_02.js +++ b/devtools/client/memory/test/unit/test_individuals_02.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test switching to the individuals view when we are in the middle of computing diff --git a/devtools/client/memory/test/unit/test_individuals_03.js b/devtools/client/memory/test/unit/test_individuals_03.js index 54460b7379c5..344cae4ef43c 100644 --- a/devtools/client/memory/test/unit/test_individuals_03.js +++ b/devtools/client/memory/test/unit/test_individuals_03.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test switching to the individuals view when we are in the diffing view. @@ -45,8 +46,8 @@ add_task(function* () { dispatch(takeSnapshotAndCensus(front, heapWorker)); dispatch(takeSnapshotAndCensus(front, heapWorker)); - yield waitUntilCensusState(store, s => s.census, [censusState.SAVED, - censusState.SAVED]); + yield waitUntilCensusState(store, s => s.census, + [censusState.SAVED, censusState.SAVED]); dispatch(changeView(viewState.DIFFING)); dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, getState().snapshots[0])); diff --git a/devtools/client/memory/test/unit/test_individuals_04.js b/devtools/client/memory/test/unit/test_individuals_04.js index c160d555fd02..8369a08b6111 100644 --- a/devtools/client/memory/test/unit/test_individuals_04.js +++ b/devtools/client/memory/test/unit/test_individuals_04.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test showing individual Array objects. diff --git a/devtools/client/memory/test/unit/test_individuals_05.js b/devtools/client/memory/test/unit/test_individuals_05.js index 1f8873826bb4..3d432ace88a1 100644 --- a/devtools/client/memory/test/unit/test_individuals_05.js +++ b/devtools/client/memory/test/unit/test_individuals_05.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test showing individual objects that do not have allocation stacks. diff --git a/devtools/client/memory/test/unit/test_individuals_06.js b/devtools/client/memory/test/unit/test_individuals_06.js index 6147b8181784..d9dc331bc285 100644 --- a/devtools/client/memory/test/unit/test_individuals_06.js +++ b/devtools/client/memory/test/unit/test_individuals_06.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test that clearing the current individuals' snapshot leaves the individuals diff --git a/devtools/client/memory/test/unit/test_pop_view_01.js b/devtools/client/memory/test/unit/test_pop_view_01.js index 9e6a1709539a..09d013bd91c4 100644 --- a/devtools/client/memory/test/unit/test_pop_view_01.js +++ b/devtools/client/memory/test/unit/test_pop_view_01.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test popping views from each intermediate individuals model state. diff --git a/devtools/client/memory/test/unit/test_tree-map-01.js b/devtools/client/memory/test/unit/test_tree-map-01.js index 15d9a765acb6..776991504ed9 100644 --- a/devtools/client/memory/test/unit/test_tree-map-01.js +++ b/devtools/client/memory/test/unit/test_tree-map-01.js @@ -1,6 +1,8 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + const { drawBox } = require("devtools/client/memory/components/tree-map/draw"); function run_test() { @@ -10,8 +12,12 @@ function run_test() { add_task(function* () { let fillRectValues, strokeRectValues; let ctx = { - fillRect: (...args) => fillRectValues = args, - strokeRect: (...args) => strokeRectValues = args + fillRect: (...args) => { + fillRectValues = args; + }, + strokeRect: (...args) => { + strokeRectValues = args; + } }; let node = { x: 20, @@ -36,7 +42,6 @@ add_task(function* () { deepEqual(fillRectValues, [10.5, 20.5, 49, 69], "Draws a filled rectangle"); deepEqual(strokeRectValues, [10.5, 20.5, 49, 69], "Draws a stroked rectangle"); - dragZoom.zoom = 0.5; drawBox(ctx, node, borderWidth, dragZoom, padding); diff --git a/devtools/client/memory/test/unit/test_utils-get-snapshot-totals.js b/devtools/client/memory/test/unit/test_utils-get-snapshot-totals.js index c4560fb074cc..1b00c1a53a58 100644 --- a/devtools/client/memory/test/unit/test_utils-get-snapshot-totals.js +++ b/devtools/client/memory/test/unit/test_utils-get-snapshot-totals.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** @@ -7,7 +8,7 @@ * in `utils.getSnapshotTotals(snapshot)` */ -const { censusDisplays, snapshotState: states, viewState, censusState } = require("devtools/client/memory/constants"); +const { censusDisplays, viewState, censusState } = require("devtools/client/memory/constants"); const { getSnapshotTotals } = require("devtools/client/memory/utils"); const { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); const { setCensusDisplayAndRefresh } = require("devtools/client/memory/actions/census-display"); diff --git a/devtools/client/memory/test/unit/test_utils.js b/devtools/client/memory/test/unit/test_utils.js index f6deddfc9078..3f8ccf694c4a 100644 --- a/devtools/client/memory/test/unit/test_utils.js +++ b/devtools/client/memory/test/unit/test_utils.js @@ -1,5 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** @@ -19,11 +20,13 @@ function run_test() { add_task(function* () { let s1 = utils.createSnapshot({ view: { state: viewState.CENSUS } }); let s2 = utils.createSnapshot({ view: { state: viewState.CENSUS } }); - equal(s1.state, states.SAVING, "utils.createSnapshot() creates snapshot in saving state"); + equal(s1.state, states.SAVING, + "utils.createSnapshot() creates snapshot in saving state"); ok(s1.id !== s2.id, "utils.createSnapshot() creates snapshot with unique ids"); let custom = { by: "internalType", then: { by: "count", bytes: true }}; - Preferences.set("devtools.memory.custom-census-displays", JSON.stringify({ "My Display": custom })); + Preferences.set("devtools.memory.custom-census-displays", + JSON.stringify({ "My Display": custom })); equal(utils.getCustomCensusDisplays()["My Display"].by, custom.by, "utils.getCustomCensusDisplays() returns custom displays"); diff --git a/devtools/client/memory/utils.js b/devtools/client/memory/utils.js index d36c9251cea6..82511dc82195 100644 --- a/devtools/client/memory/utils.js +++ b/devtools/client/memory/utils.js @@ -2,7 +2,9 @@ * 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/. */ -const { Cu, Cc, Ci } = require("chrome"); +"use strict"; + +const { Cc, Ci } = require("chrome"); const { LocalizationHelper } = require("devtools/shared/l10n"); const STRINGS_URI = "devtools/client/locales/memory.properties"; @@ -330,7 +332,6 @@ exports.censusIsUpToDate = function (filter, display, census) { && display === census.display; }; - /** * Check to see if the snapshot is in a state that it can take a census. * @@ -413,8 +414,8 @@ exports.getSnapshotTotals = function (census) { * The file selected by the user, or null, if cancelled. */ exports.openFilePicker = function ({ title, filters, defaultName, mode }) { - mode = mode === "save" ? Ci.nsIFilePicker.modeSave : - mode === "open" ? Ci.nsIFilePicker.modeOpen : null; + mode = mode === "save" ? Ci.nsIFilePicker.modeSave : null; + mode = mode === "open" ? Ci.nsIFilePicker.modeOpen : null; if (mode == void 0) { throw new Error("No valid mode specified for nsIFilePicker.");