author | tdraebing <thomas.draebing@gmail.com> |
Wed, 21 Dec 2016 15:21:24 +0100 | |
changeset 326833 | f9ad068aeaafcc595c153998ffa144b5f7ef017a |
parent 326832 | bd4a0d0bc458174c58316983df64e49aae688337 |
child 326834 | 36ab9273387b3ec5573c7ab6585548f3e900b3ab |
push id | 85039 |
push user | ntim.bugs@gmail.com |
push date | Wed, 21 Dec 2016 18:41:07 +0000 |
treeherder | mozilla-inbound@f9ad068aeaaf [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ntim |
bugs | 1251728 |
milestone | 53.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/.eslintignore +++ b/.eslintignore @@ -81,17 +81,16 @@ browser/extensions/mortar/** # devtools/ exclusions devtools/client/canvasdebugger/** devtools/client/commandline/** devtools/client/debugger/** 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/** devtools/client/promisedebugger/** devtools/client/responsivedesign/** devtools/client/scratchpad/** devtools/client/shadereditor/** devtools/client/shared/*.jsm
new file mode 100644 --- /dev/null +++ b/devtools/client/memory/.eslintrc.js @@ -0,0 +1,11 @@ +"use strict"; + +module.exports = { + "env": { + "browser": true, + }, + "globals": { + "d3": true, + "dagreD3": true, + } +};
--- a/devtools/client/memory/actions/census-display.js +++ b/devtools/client/memory/actions/census-display.js @@ -20,15 +20,16 @@ exports.setCensusDisplayAndRefresh = fun * * @param {censusDisplayModel} display */ const setCensusDisplay = exports.setCensusDisplay = function (display) { assert(typeof display === "object" && 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, display, }; };
--- a/devtools/client/memory/actions/diffing.js +++ b/devtools/client/memory/actions/diffing.js @@ -1,29 +1,28 @@ /* 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"); const { actions, diffingState, viewState } = require("../constants"); const telemetry = require("../telemetry"); const { getSnapshot, censusIsUpToDate, 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, newViewState: getState().diffing ? viewState.CENSUS : viewState.DIFFING, oldDiffing: getState().diffing, oldSelected: findSelectedSnapshot(getState()), }); }; @@ -150,52 +149,52 @@ const refreshDiffing = exports.refreshDi /** * Select the given snapshot for diffing and refresh the diffing data if * necessary (for example, if two snapshots are now selected for diffing). * * @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"); dispatch(selectSnapshotForDiffing(snapshot)); yield dispatch(refreshDiffing(heapWorker)); }; }; /** * Expand the given node in the diffing's census's delta-report. * * @param {CensusTreeNode} node */ -const expandDiffingCensusNode = exports.expandDiffingCensusNode = function (node) { +exports.expandDiffingCensusNode = function (node) { return { type: actions.EXPAND_DIFFING_CENSUS_NODE, node, }; }; /** * Collapse the given node in the diffing's census's delta-report. * * @param {CensusTreeNode} node */ -const collapseDiffingCensusNode = exports.collapseDiffingCensusNode = function (node) { +exports.collapseDiffingCensusNode = function (node) { return { type: actions.COLLAPSE_DIFFING_CENSUS_NODE, node, }; }; /** * Focus the given node in the snapshot's census's report. * * @param {DominatorTreeNode} node */ -const focusDiffingCensusNode = exports.focusDiffingCensusNode = function (node) { +exports.focusDiffingCensusNode = function (node) { return { type: actions.FOCUS_DIFFING_CENSUS_NODE, node, }; };
--- a/devtools/client/memory/actions/io.js +++ b/devtools/client/memory/actions/io.js @@ -1,24 +1,22 @@ /* 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 { 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]; exports.pickFileAndExportSnapshot = function (snapshot) { return function* (dispatch, getState) { let outputFile = yield openFilePicker({ title: L10N.getFormatStr("snapshot.io.save.window"), defaultName: OS.Path.basename(snapshot.path), @@ -49,33 +47,33 @@ const exportSnapshot = exports.exportSna reportException("exportSnapshot", error); dispatch({ type: actions.EXPORT_SNAPSHOT_ERROR, snapshot, error }); } dispatch({ type: actions.EXPORT_SNAPSHOT_END, snapshot }); }; }; -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"), filters: [[L10N.getFormatStr("snapshot.io.filter"), "*.fxsnapshot"]], mode: "open", }); if (!input) { return; } yield dispatch(importSnapshotAndCensus(heapWorker, input.path)); }; }; -const importSnapshotAndCensus = exports.importSnapshotAndCensus = function (heapWorker, path) { +const importSnapshotAndCensus = function (heapWorker, path) { return function* (dispatch, getState) { telemetry.countImportSnapshot(); const snapshot = immutableUpdate(createSnapshot(getState()), { path, state: states.IMPORTING, imported: true, }); @@ -90,8 +88,9 @@ const importSnapshotAndCensus = exports. } catch (error) { reportException("importSnapshot", error); dispatch({ type: actions.IMPORT_SNAPSHOT_ERROR, error, id }); } dispatch({ type: actions.IMPORT_SNAPSHOT_END, id }); }; }; +exports.importSnapshotAndCensus = importSnapshotAndCensus;
--- a/devtools/client/memory/actions/label-display.js +++ b/devtools/client/memory/actions/label-display.js @@ -24,15 +24,16 @@ exports.setLabelDisplayAndRefresh = func * * @param {labelDisplayModel} display */ const setLabelDisplay = exports.setLabelDisplay = function (display) { assert(typeof display === "object" && 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, display, }; };
--- a/devtools/client/memory/actions/snapshot.js +++ b/devtools/client/memory/actions/snapshot.js @@ -29,17 +29,17 @@ const TaskCache = require("./task-cache" /** * A series of actions are fired from this task to save, read and generate the * initial census from a snapshot. * * @param {MemoryFront} * @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) { return; } yield dispatch(readSnapshot(heapWorker, id)); if (getSnapshot(getState(), id).state !== states.READ) { @@ -77,17 +77,17 @@ const computeSnapshotData = exports.comp /** * Selects a snapshot and if the snapshot's census is using a different * display, take a new census. * * @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)); } dispatch(selectSnapshot(id)); yield dispatch(refresh.refresh(heapWorker)); }; @@ -195,17 +195,19 @@ function makeTakeCensusTask({ getDisplay const snapshot = getSnapshot(getState(), id); if (!snapshot) { removeFromCache(); return; } // 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()); let filter = getFilter(getState()); // If display, filter and inversion haven't changed, don't do anything. if (censusIsUpToDate(filter, display, getCensus(snapshot))) { removeFromCache(); @@ -317,17 +319,17 @@ const getCurrentCensusTaker = exports.ge } }; /** * Focus the given node in the individuals view. * * @param {DominatorTreeNode} node. */ -const focusIndividual = exports.focusIndividual = function (node) { +exports.focusIndividual = function (node) { return { type: actions.FOCUS_INDIVIDUAL, node, }; }; /** * Fetch the individual `DominatorTreeNodes` for the census group specified by @@ -407,17 +409,17 @@ function (heapWorker, id, censusBreakdow }; }; /** * Refresh the current individuals view. * * @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."); const { individuals } = getState(); switch (individuals.state) { case individualsState.COMPUTING_DOMINATOR_TREE: @@ -448,17 +450,17 @@ const refreshIndividuals = exports.refre }; /** * Refresh the selected snapshot's census data, if need be (for example, * display configuration changed). * * @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) { return; } // Intermediate snapshot states will get handled by the task action that is // orchestrating them. For example, if the snapshot census's state is @@ -474,17 +476,17 @@ const refreshSelectedCensus = exports.re }; /** * Refresh the selected snapshot's tree map data, if need be (for example, * display configuration changed). * * @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) { return; } // Intermediate snapshot states will get handled by the task action that is // orchestrating them. For example, if the snapshot census's state is @@ -591,18 +593,17 @@ TaskCache.declareCacheableTask({ /** * Fetch the immediately dominated children represented by the placeholder * `lazyChildren` from snapshot-with-the-given-id's dominator tree. * * @param {HeapAnalysesClient} heapWorker * @param {SnapshotId} id * @param {DominatorTreeLazyChildren} lazyChildren */ -const fetchImmediatelyDominated = exports.fetchImmediatelyDominated = -TaskCache.declareCacheableTask({ +exports.fetchImmediatelyDominated = TaskCache.declareCacheableTask({ getCacheKey(_, id, lazyChildren) { return `${id}-${lazyChildren.key()}`; }, task: function* (heapWorker, id, lazyChildren, removeFromCache, dispatch, getState) { const snapshot = getSnapshot(getState(), id); assert(snapshot.dominatorTree, "Should have dominator tree model"); assert(snapshot.dominatorTree.state === dominatorTreeState.LOADED || @@ -625,29 +626,30 @@ TaskCache.declareCacheableTask({ nodeId: lazyChildren.parentNodeId(), startIndex: lazyChildren.siblingIndex(), maxRetainingPaths: Preferences.get("devtools.memory.max-retaining-paths"), }); } catch (error) { removeFromCache(); reportException("actions/snapshot/fetchImmediatelyDominated", error); dispatch({ type: actions.DOMINATOR_TREE_ERROR, id, error }); - return null; + return; } } while (display !== getState().labelDisplay); removeFromCache(); dispatch({ type: actions.FETCH_IMMEDIATELY_DOMINATED_END, id, path: response.path, nodes: response.nodes, moreChildrenAvailable: response.moreChildrenAvailable, }); + return; } }); /** * Compute and then fetch the dominator tree of the snapshot with the given * `id`. * * @param {HeapAnalysesClient} heapWorker @@ -679,17 +681,17 @@ TaskCache.declareCacheableTask({ } }); /** * Update the currently selected snapshot's dominator tree. * * @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) { return; } if (snapshot.dominatorTree && !(snapshot.dominatorTree.state === dominatorTreeState.COMPUTED || @@ -726,17 +728,17 @@ const selectSnapshot = exports.selectSna }; }; /** * Delete all snapshots that are in the READ or ERROR state * * @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; let censusReady = (s.treeMap && s.treeMap.state === treeMapState.SAVED) || (s.census && s.census.state === censusState.SAVED); return snapshotReady && censusReady; }); @@ -764,17 +766,17 @@ const clearSnapshots = exports.clearSnap }; /** * Delete a snapshot * * @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] }); try { yield heapWorker.deleteHeapSnapshot(snapshot.path); } catch (error) { reportException("deleteSnapshot", error); dispatch({ type: actions.SNAPSHOT_ERROR, id: snapshot.id, error }); @@ -784,82 +786,82 @@ const deleteSnapshot = exports.deleteSna }; }; /** * Expand the given node in the snapshot's census report. * * @param {CensusTreeNode} node */ -const expandCensusNode = exports.expandCensusNode = function (id, node) { +exports.expandCensusNode = function (id, node) { return { type: actions.EXPAND_CENSUS_NODE, id, node, }; }; /** * Collapse the given node in the snapshot's census report. * * @param {CensusTreeNode} node */ -const collapseCensusNode = exports.collapseCensusNode = function (id, node) { +exports.collapseCensusNode = function (id, node) { return { type: actions.COLLAPSE_CENSUS_NODE, id, node, }; }; /** * Focus the given node in the snapshot's census's report. * * @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, node, }; }; /** * Expand the given node in the snapshot's dominator tree. * * @param {DominatorTreeTreeNode} node */ -const expandDominatorTreeNode = exports.expandDominatorTreeNode = function (id, node) { +exports.expandDominatorTreeNode = function (id, node) { return { type: actions.EXPAND_DOMINATOR_TREE_NODE, id, node, }; }; /** * Collapse the given node in the snapshot's dominator tree. * * @param {DominatorTreeTreeNode} node */ -const collapseDominatorTreeNode = exports.collapseDominatorTreeNode = function (id, node) { +exports.collapseDominatorTreeNode = function (id, node) { return { type: actions.COLLAPSE_DOMINATOR_TREE_NODE, id, node, }; }; /** * Focus the given node in the snapshot's dominator tree. * * @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, node, }; };
--- a/devtools/client/memory/actions/tree-map-display.js +++ b/devtools/client/memory/actions/tree-map-display.js @@ -23,15 +23,16 @@ exports.setTreeMapAndRefresh = function * * @param {treeMapModel} display */ const setTreeMap = exports.setTreeMap = function (display) { assert(typeof display === "object" && 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, display, }; };
--- a/devtools/client/memory/app.js +++ b/devtools/client/memory/app.js @@ -1,12 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + const { assert } = require("devtools/shared/DevToolsUtils"); const { appinfo } = require("Services"); const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react"); const { connect } = require("devtools/client/shared/vendor/react-redux"); const { censusDisplays, labelDisplays, treeMapDisplays, diffingState, viewState } = require("./constants"); const { toggleRecordingAllocationStacks } = require("./actions/allocations"); const { setCensusDisplayAndRefresh } = require("./actions/census-display"); const { setLabelDisplayAndRefresh } = require("./actions/label-display"); @@ -49,45 +51,45 @@ const SnapshotListItem = createFactory(r const Heap = createFactory(require("./components/heap")); const { app: appModel } = require("./models"); const MemoryApp = createClass({ displayName: "MemoryApp", 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 // falls back to the body. window.addEventListener("keydown", this.onKeyDown); }, componentWillUnmount() { 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); const selectedIndex = snapshots.indexOf(selectedSnapshot); let isOSX = appinfo.OS == "Darwin"; let isAccelKey = (isOSX && e.metaKey) || (!isOSX && e.ctrlKey); @@ -214,17 +216,18 @@ const MemoryApp = createClass({ onDelete: snapshot => dispatch(deleteSnapshot(heapWorker, snapshot)), onClick: onClickSnapshotListItem, diffing, }), 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 => dispatch(fetchImmediatelyDominated(heapWorker, selectedSnapshot.id, lazyChildren)), onPopView: () => dispatch(popViewAndRefresh(heapWorker)), individuals, @@ -244,61 +247,67 @@ const MemoryApp = createClass({ }, onCensusExpand: (census, node) => { if (diffing) { assert(diffing.census === census, "Should only expand active census"); 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)); } }, onCensusCollapse: (census, node) => { if (diffing) { assert(diffing.census === census, "Should only collapse active census"); 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)); } }, onCensusFocus: (census, node) => { if (diffing) { assert(diffing.census === census, "Should only focus nodes in active census"); 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"); dispatch(expandDominatorTreeNode(selectedSnapshot.id, node)); }, 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"); dispatch(collapseDominatorTreeNode(selectedSnapshot.id, node)); }, 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"); dispatch(focusDominatorTreeNode(selectedSnapshot.id, node)); }, onShortestPathsResize: newSize => { dispatch(resizeShortestPaths(newSize)); },
--- a/devtools/client/memory/components/census-header.js +++ b/devtools/client/memory/components/census-header.js @@ -1,17 +1,19 @@ /* 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 { 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: { diffing: models.diffingModel, }, render() { let individualsCell;
--- a/devtools/client/memory/components/census-tree-item.js +++ b/devtools/client/memory/components/census-tree-item.js @@ -4,27 +4,52 @@ "use strict"; const { isSavedFrame } = require("devtools/shared/DevToolsUtils"); const { DOM: dom, createClass, createFactory } = require("devtools/client/shared/vendor/react"); 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) { return this.props.item != nextProps.item || this.props.depth != nextProps.depth || this.props.expanded != nextProps.expanded || this.props.focused != nextProps.focused || 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, depth, arrow, focused, getPercentBytes, getPercentCount, @@ -101,34 +126,9 @@ const CensusTreeItem = module.exports = style: { marginInlineStart: depth * TREE_ROW_HEIGHT } }, arrow, pointer, this.toLabel(item.name, onViewSourceInDebugger) ) ); }, - - 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); - }, });
--- a/devtools/client/memory/components/census.js +++ b/devtools/client/memory/components/census.js @@ -1,20 +1,21 @@ /* 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/. */ -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: { census: censusModel, onExpand: PropTypes.func.isRequired, onCollapse: PropTypes.func.isRequired, onFocus: PropTypes.func.isRequired, onViewSourceInDebugger: PropTypes.func.isRequired,
--- a/devtools/client/memory/components/dominator-tree-header.js +++ b/devtools/client/memory/components/dominator-tree-header.js @@ -1,16 +1,18 @@ /* 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/. */ -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: { }, render() { return dom.div( { className: "header"
--- a/devtools/client/memory/components/dominator-tree-item.js +++ b/devtools/client/memory/components/dominator-tree-item.js @@ -1,27 +1,29 @@ /* 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, isSavedFrame } = require("devtools/shared/DevToolsUtils"); const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react"); const { L10N, formatNumber, formatPercent } = require("../utils"); const Frame = createFactory(require("devtools/client/shared/components/frame")); const { TREE_ROW_HEIGHT } = require("../constants"); const Separator = createFactory(createClass({ displayName: "Separator", render() { return dom.span({ className: "separator" }, "›"); } })); -const DominatorTreeItem = module.exports = createClass({ +module.exports = createClass({ displayName: "DominatorTreeItem", propTypes: { item: PropTypes.object.isRequired, depth: PropTypes.number.isRequired, arrow: PropTypes.object, focused: PropTypes.bool.isRequired, getPercentSize: PropTypes.func.isRequired,
--- a/devtools/client/memory/components/dominator-tree.js +++ b/devtools/client/memory/components/dominator-tree.js @@ -1,14 +1,16 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + 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")); const { L10N } = require("../utils"); const { TREE_ROW_HEIGHT, dominatorTreeState } = require("../constants"); const { dominatorTreeModel } = require("../models"); const DominatorTreeLazyChildren = require("../dominator-tree-lazy-children"); @@ -16,26 +18,26 @@ const DOMINATOR_TREE_AUTO_EXPAND_DEPTH = /** * A throbber that represents a subtree in the dominator tree that is actively * being incrementally loaded and fetched from the `HeapAnalysesWorker`. */ const DominatorTreeSubtreeFetching = createFactory(createClass({ displayName: "DominatorTreeSubtreeFetching", + propTypes: { + depth: PropTypes.number.isRequired, + focused: PropTypes.bool.isRequired, + }, + shouldComponentUpdate(nextProps, nextState) { return this.props.depth !== nextProps.depth || this.props.focused !== nextProps.focused; }, - propTypes: { - depth: PropTypes.number.isRequired, - focused: PropTypes.bool.isRequired, - }, - render() { let { depth, focused, } = this.props; return dom.div( { @@ -98,17 +100,17 @@ const DominatorTreeSiblingLink = createF ) ); } })); /** * The actual dominator tree rendered as an expandable and collapsible tree. */ -const DominatorTree = module.exports = createClass({ +module.exports = createClass({ displayName: "DominatorTree", propTypes: { dominatorTree: dominatorTreeModel.isRequired, onLoadMoreSiblings: PropTypes.func.isRequired, onViewSourceInDebugger: PropTypes.func.isRequired, onExpand: PropTypes.func.isRequired, onCollapse: PropTypes.func.isRequired,
--- a/devtools/client/memory/components/heap.js +++ b/devtools/client/memory/components/heap.js @@ -1,12 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react"); const { assert, safeErrorString } = require("devtools/shared/DevToolsUtils"); const Census = createFactory(require("./census")); const CensusHeader = createFactory(require("./census-header")); const DominatorTree = createFactory(require("./dominator-tree")); const DominatorTreeHeader = createFactory(require("./dominator-tree-header")); const TreeMap = createFactory(require("./tree-map")); const HSplitBox = createFactory(require("devtools/client/shared/components/h-split-box")); @@ -173,17 +175,17 @@ function getError(snapshot, diffing, ind /** * Main view for the memory tool. * * The Heap component contains several panels for different states; an initial * 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: { onSnapshotClick: PropTypes.func.isRequired, onLoadMoreSiblings: PropTypes.func.isRequired, onCensusExpand: PropTypes.func.isRequired, onCensusCollapse: PropTypes.func.isRequired, onDominatorTreeExpand: PropTypes.func.isRequired, @@ -197,78 +199,16 @@ const Heap = module.exports = createClas individuals: models.individuals, onViewIndividuals: PropTypes.func.isRequired, onFocusIndividual: PropTypes.func.isRequired, diffing: diffingModel, view: models.view.isRequired, 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. * * @param {snapshotState|diffingState|dominatorTreeState} state * @param {...Any} contents */ _renderHeapView(state, ...contents) { @@ -320,19 +260,20 @@ const Heap = module.exports = createClas dom.pre({}, safeErrorString(error)) ); }, _renderCensus(state, census, diffing, onViewSourceInDebugger, onViewIndividuals) { 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)); } const contents = []; if (census.display.breakdown.by === "allocationStack" && census.report.children && census.report.children.length === 1 @@ -447,9 +388,72 @@ const Heap = module.exports = createClas HSplitBox({ start: tree, end: shortestPaths, startWidth: this.props.sizes.shortestPathsSize, onResize: this.props.onShortestPathsResize, }) ); }, + + 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); + }, });
--- a/devtools/client/memory/components/individuals-header.js +++ b/devtools/client/memory/components/individuals-header.js @@ -1,16 +1,18 @@ /* 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/. */ -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: { }, render() { return dom.div( { className: "header"
--- a/devtools/client/memory/components/individuals.js +++ b/devtools/client/memory/components/individuals.js @@ -1,25 +1,24 @@ /* 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/. */ -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: { onViewSourceInDebugger: PropTypes.func.isRequired, onFocus: PropTypes.func.isRequired, individuals: models.individuals, dominatorTree: models.dominatorTreeModel, },
--- a/devtools/client/memory/components/list.js +++ b/devtools/client/memory/components/list.js @@ -1,20 +1,22 @@ /* 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 { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react"); /** * Generic list component that takes another react component to represent * 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: { itemComponent: PropTypes.any.isRequired, onClick: PropTypes.func, items: PropTypes.array.isRequired, },
--- a/devtools/client/memory/components/shortest-paths.js +++ b/devtools/client/memory/components/shortest-paths.js @@ -1,11 +1,12 @@ /* 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 { DOM: dom, createClass, PropTypes, } = require("devtools/client/shared/vendor/react"); const { isSavedFrame } = require("devtools/shared/DevToolsUtils"); @@ -24,17 +25,18 @@ const ROOT_LIST = "JS::ubi::RootList"; function stringifyLabel(label, id) { const sanitized = []; for (let i = 0, length = label.length; i < length; i++) { const piece = label[i]; 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) { sanitized[i] = L10N.getStr("tree-item.nofilename"); } else if (piece === ROOT_LIST) { // Don't use the usual labeling machinery for root lists: replace it // with the "GC Roots" string. sanitized.splice(0, label.length); @@ -57,76 +59,38 @@ module.exports = createClass({ edges: PropTypes.arrayOf(PropTypes.object), }), }, getInitialState() { 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); } }, componentWillUnmount() { if (this.state.zoom) { this.state.zoom.on("zoom", null); } }, - 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"); svg.setAttribute("id", "graph-svg"); svg.setAttribute("xlink", "http://www.w3.org/1999/xlink"); svg.style.width = "100%"; svg.style.height = "100%"; @@ -176,9 +140,47 @@ module.exports = createClass({ const { translate, scale } = GRAPH_DEFAULTS; zoom.scale(scale); zoom.translate(translate); target.attr("transform", `translate(${translate}) scale(${scale})`); 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 + ); + }, });
--- a/devtools/client/memory/components/snapshot-list-item.js +++ b/devtools/client/memory/components/snapshot-list-item.js @@ -1,43 +1,39 @@ /* 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/. */ -const { assert } = require("devtools/shared/DevToolsUtils"); +"use strict"; + const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react"); const { L10N, getSnapshotTitle, getSnapshotTotals, getStatusText, 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: { onClick: PropTypes.func.isRequired, onSave: PropTypes.func.isRequired, onDelete: PropTypes.func.isRequired, item: snapshotModel.isRequired, index: PropTypes.number.isRequired, }, 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; let title = getSnapshotTitle(snapshot); const selectedForDiffing = diffing && (diffing.firstSnapshotId === snapshot.id || diffing.secondSnapshotId === snapshot.id); @@ -70,17 +66,18 @@ const SnapshotListItem = module.exports let details; if (!selectedForDiffing) { // See if a tree map or census is in the read state. let census = getSavedCensus(snapshot); // 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) ); } } if (!details) { details = dom.span({ className: "snapshot-state" }, statusText); @@ -94,17 +91,19 @@ const SnapshotListItem = module.exports let deleteButton = !snapshot.path ? void 0 : dom.button({ onClick: () => onDelete(snapshot), className: "devtools-button delete", title: L10N.getStr("snapshot.io.delete") }); return ( dom.li({ className, onClick }, - dom.span({ className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}` }, + dom.span({ + className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}` + }, checkbox, title, deleteButton ), dom.span({ className: "snapshot-info" }, details, saveLink )
--- a/devtools/client/memory/components/toolbar.js +++ b/devtools/client/memory/components/toolbar.js @@ -255,17 +255,18 @@ module.exports = createClass({ className: "take-snapshot devtools-button", onClick: onTakeSnapshotClick, title: L10N.getStr("take-snapshot") }), 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"), } ), dom.button( {
--- a/devtools/client/memory/components/tree-map.js +++ b/devtools/client/memory/components/tree-map.js @@ -4,22 +4,22 @@ "use strict"; const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react"); const { treeMapModel } = require("../models"); const startVisualization = require("./tree-map/start"); module.exports = createClass({ + displayName: "TreeMap", + propTypes: { treeMap: treeMapModel }, - displayName: "TreeMap", - getInitialState() { return {}; }, componentDidMount() { const { treeMap } = this.props; if (treeMap && treeMap.report) { this._startVisualization();
--- a/devtools/client/memory/components/tree-map/canvas-utils.js +++ b/devtools/client/memory/components/tree-map/canvas-utils.js @@ -46,17 +46,17 @@ function Canvases(parentEl, debounceRate Canvases.prototype = { /** * Remove the handlers and elements * * @return {type} description */ - destroy : function () { + destroy: function () { this.removeHandlers(); this.container.removeChild(this.main.canvas); this.container.removeChild(this.zoom.canvas); } }; module.exports = Canvases;
--- a/devtools/client/memory/components/tree-map/drag-zoom.js +++ b/devtools/client/memory/components/tree-map/drag-zoom.js @@ -233,17 +233,16 @@ function setScrollHandlers(container, dr if (dragZoom.isDragging) { return; } // Update the zoom level 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); let prevZoomedHeight = container.offsetHeight * (1 + prevZoom); dragZoom.zoomedWidth = container.offsetWidth * (1 + dragZoom.zoom); dragZoom.zoomedHeight = container.offsetHeight * (1 + dragZoom.zoom); let deltaWidth = dragZoom.zoomedWidth - prevZoomedWidth; let deltaHeight = dragZoom.zoomedHeight - prevZoomedHeight;
--- a/devtools/client/memory/constants.js +++ b/devtools/client/memory/constants.js @@ -117,17 +117,20 @@ actions.EXPAND_DOMINATOR_TREE_NODE = "ex actions.COLLAPSE_DOMINATOR_TREE_NODE = "collapse-dominator-tree-node"; actions.RESIZE_SHORTEST_PATHS = "resize-shortest-paths"; /** * Census Displays ***************************************************************/ 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", objects: OBJECT_CLASS, strings: COUNT, scripts: { by: "filename", then: INTERNAL_TYPE,
--- a/devtools/client/memory/dominator-tree-lazy-children.js +++ b/devtools/client/memory/dominator-tree-lazy-children.js @@ -1,12 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + /** * The `DominatorTreeLazyChildren` is a placeholder that represents a future * subtree in an existing `DominatorTreeNode` tree that is currently being * incrementally fetched from the `HeapAnalysesWorker`. * * @param {NodeId} parentNodeId * @param {Number} siblingIndex */
--- a/devtools/client/memory/initializer.js +++ b/devtools/client/memory/initializer.js @@ -1,55 +1,59 @@ /* 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/. */ +/* 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({ baseURI: "resource://devtools/client/memory/", window }); const { Task } = require("devtools/shared/task"); const { createFactory, createElement } = require("devtools/client/shared/vendor/react"); const ReactDOM = require("devtools/client/shared/vendor/react-dom"); const { Provider } = require("devtools/client/shared/vendor/react-redux"); const App = createFactory(require("devtools/client/memory/app")); 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); }); var destroy = Task.async(function* () { const ok = ReactDOM.unmountComponentAtNode(gRoot); assert(ok, "Should successfully unmount the memory tool's top level React component"); unsubscribe(); - gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted; + gStore = gRoot = gApp = gProvider = unsubscribe = isHighlighted = null; }); /** * Fired on any state change, currently only handles toggling * the highlighting of the tool when recording allocations. */ function onStateChange() { let isRecording = gStore.getState().allocations.recording;
--- a/devtools/client/memory/models.js +++ b/devtools/client/memory/models.js @@ -1,12 +1,17 @@ /* 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/. */ +/* 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"); const { PropTypes } = require("devtools/client/shared/vendor/react"); const { snapshotState: states, diffingState, dominatorTreeState, @@ -34,17 +39,19 @@ const { * assert(someInvariant(model.someProperty), "Should blah blah"); * }) * }); */ function catchAndIgnore(fn) { return function (...args) { try { fn(...args); - } catch (err) { } + } catch (err) { + // continue regardless of error + } return null; }; } /** * The data describing the census report's shape, and its associated metadata. * @@ -98,16 +105,17 @@ const treeMapModel = exports.treeMapMode display: treeMapDisplayModel, // The current treeMapState this is in state: catchAndIgnore(function (treeMap) { switch (treeMap.state) { case treeMapState.SAVING: 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"); break; case treeMapState.ERROR: assert(treeMap.error, "Should have an error"); break; @@ -438,17 +446,17 @@ const individualsModel = exports.individ default: assert(false, `Unexpected individuals state: ${individuals.state}`); break; } }), }); -let appModel = exports.app = { +exports.app = { // {MemoryFront} Used to communicate with platform front: PropTypes.instanceOf(MemoryFront), // Allocations recording related data. allocations: allocationsModel.isRequired, // {HeapAnalysesClient} Used to interface with snapshots heapWorker: PropTypes.instanceOf(HeapAnalysesClient), @@ -489,17 +497,17 @@ let appModel = exports.app = { case viewState.INDIVIDUALS: case viewState.CENSUS: case viewState.DOMINATOR_TREE: case viewState.TREE_MAP: assert(!app.diffing, "Should not be diffing"); break; default: - assert(false, `Unexpected type of view: ${view.state}`); + assert(false, `Unexpected type of view: ${app.view.state}`); } })(app); catchAndIgnore(function (app) { switch (app.view.state) { case viewState.INDIVIDUALS: assert(app.individuals, "Should have individuals state"); break; @@ -507,13 +515,13 @@ let appModel = exports.app = { case viewState.DIFFING: case viewState.CENSUS: case viewState.DOMINATOR_TREE: case viewState.TREE_MAP: assert(!app.individuals, "Should not have individuals state"); break; default: - assert(false, `Unexpected type of view: ${view.state}`); + assert(false, `Unexpected type of view: ${app.view.state}`); } })(app); }, };
--- a/devtools/client/memory/panel.js +++ b/devtools/client/memory/panel.js @@ -1,20 +1,18 @@ /* 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 { 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; this._toolbox = toolbox; EventEmitter.decorate(this); }
--- a/devtools/client/memory/reducers/allocations.js +++ b/devtools/client/memory/reducers/allocations.js @@ -1,12 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + const { assert } = require("devtools/shared/DevToolsUtils"); const { actions } = require("../constants"); let handlers = Object.create(null); handlers[actions.TOGGLE_RECORD_ALLOCATION_STACKS_START] = function (state, action) { assert(!state.togglingInProgress, "Changing recording state must not be reentrant.");
--- a/devtools/client/memory/reducers/errors.js +++ b/devtools/client/memory/reducers/errors.js @@ -1,12 +1,14 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + const { ERROR_TYPE: TASK_ERROR_TYPE } = require("devtools/client/shared/redux/middleware/task"); /** * Handle errors dispatched from task middleware and * store them so we can check in tests or dump them out. */ module.exports = function (state = [], action) { switch (action.type) {
--- a/devtools/client/memory/reducers/filter.js +++ b/devtools/client/memory/reducers/filter.js @@ -3,12 +3,12 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; 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; };
--- a/devtools/client/memory/reducers/snapshots.js +++ b/devtools/client/memory/reducers/snapshots.js @@ -235,44 +235,46 @@ handlers[actions.COMPUTE_DOMINATOR_TREE_ } assert(!snapshot.dominatorTree, "Should not have a dominator tree model"); return immutableUpdate(snapshot, { dominatorTree }); }); }; -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 => { if (snapshot.id !== id) { return snapshot; } 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, root: undefined, display, }); return immutableUpdate(snapshot, { dominatorTree }); });
--- a/devtools/client/memory/store.js +++ b/devtools/client/memory/store.js @@ -1,16 +1,17 @@ /* 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 { 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 () { let shouldLog = false; let history; // If testing, store the action history in an array // we'll later attach to the store
--- a/devtools/client/memory/telemetry.js +++ b/devtools/client/memory/telemetry.js @@ -1,21 +1,23 @@ /* 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"; + // This module exports methods to record telemetry data for memory tool usage. // // NB: Ensure that *every* exported function is wrapped in `makeInfallible` so // that our probes don't accidentally break code that actually does productive // work for the user! 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"); histogram.add(1); }, "devtools/client/memory/telemetry#countTakeSnapshot"); exports.countImportSnapshot = makeInfallible(function () { const histogram = telemetry.getHistogramById("DEVTOOLS_MEMORY_IMPORT_SNAPSHOT_COUNT"); @@ -75,17 +77,18 @@ exports.countDiff = makeInfallible(funct /** * @param {Object} display * The display used to label nodes in the dominator tree. */ 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) { histogram.add(ALLOCATION_STACK); } else { histogram.add(CUSTOM); } }, "devtools/client/memory/telemetry#countDominatorTree");
--- a/devtools/client/memory/test/browser/.eslintrc.js +++ b/devtools/client/memory/test/browser/.eslintrc.js @@ -1,6 +1,17 @@ "use strict"; 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" }], + } };
--- 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"); +});
--- a/devtools/client/memory/test/browser/browser_memory_diff_01.js +++ b/devtools/client/memory/test/browser/browser_memory_diff_01.js @@ -1,28 +1,25 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ // Test diffing. "use strict"; const { - snapshotState, diffingState, 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 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."); // Take two snapshots. const takeSnapshotButton = doc.getElementById("take-snapshot"); EventUtils.synthesizeMouseAtCenter(takeSnapshotButton, {}, panel.panelWin); yield waitForTime(1000);
--- a/devtools/client/memory/test/browser/browser_memory_dominator_trees_01.js +++ b/devtools/client/memory/test/browser/browser_memory_dominator_trees_01.js @@ -106,17 +106,19 @@ this.test = makeMemoryTest(TEST_URL, fun state.snapshots[0].dominatorTree.state === dominatorTreeState.LOADED); ok(true, "And the incremental fetch completes."); ok(doc.querySelector(`.node-${deepest.nodeId}`).classList.contains("focused"), "The deepest node should still be focused after we have loaded its children"); // 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; } if (node.children) { for (let child of node.children) { const found = findNewDeepest(child); if (found) {
--- a/devtools/client/memory/test/browser/browser_memory_filter_01.js +++ b/devtools/client/memory/test/browser/browser_memory_filter_01.js @@ -2,29 +2,27 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ // Sanity test that we can show allocation stack displays in the tree. "use strict"; const { dominatorTreeState, - snapshotState, viewState, censusState, } = require("devtools/client/memory/constants"); const { changeViewAndRefresh, 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)); const takeSnapshotButton = doc.getElementById("take-snapshot"); EventUtils.synthesizeMouseAtCenter(takeSnapshotButton, {}, panel.panelWin); yield waitUntilState(store, state => @@ -44,17 +42,18 @@ this.test = makeMemoryTest(TEST_URL, fun yield waitUntilState(store, state => state.snapshots.length === 1 && state.snapshots[0].census && state.snapshots[0].census.state === censusState.SAVED); 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"); // Now switch the dominator view, then switch back to census view // and check that the filter word is still correctly applied dispatch(changeViewAndRefresh(viewState.DOMINATOR_TREE, heapWorker)); ok(true, "change view to dominator tree");
--- a/devtools/client/memory/test/browser/browser_memory_individuals_01.js +++ b/devtools/client/memory/test/browser/browser_memory_individuals_01.js @@ -6,25 +6,23 @@ "use strict"; const { individualsState, 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)); // Take a snapshot and wait for the census to finish. const takeSnapshotButton = doc.getElementById("take-snapshot"); EventUtils.synthesizeMouseAtCenter(takeSnapshotButton, {}, panel.panelWin);
--- a/devtools/client/memory/test/browser/browser_memory_keyboard-snapshot-list.js +++ b/devtools/client/memory/test/browser/browser_memory_keyboard-snapshot-list.js @@ -1,17 +1,16 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ // Test that using ACCEL+UP/DOWN, the user can navigate between snapshots. "use strict"; const { - snapshotState, viewState, censusState } = require("devtools/client/memory/constants"); const { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); const { changeView } = require("devtools/client/memory/actions/view");
--- a/devtools/client/memory/test/browser/browser_memory_keyboard.js +++ b/devtools/client/memory/test/browser/browser_memory_keyboard.js @@ -2,17 +2,16 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ // Bug 1246570 - Check that when pressing on LEFT arrow, the parent tree node // gets focused. "use strict"; const { - snapshotState, censusState, viewState } = require("devtools/client/memory/constants"); const { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); const { changeView } = require("devtools/client/memory/actions/view");
--- a/devtools/client/memory/test/browser/browser_memory_no_allocation_stacks.js +++ b/devtools/client/memory/test/browser/browser_memory_no_allocation_stacks.js @@ -30,10 +30,11 @@ this.test = makeMemoryTest(TEST_URL, fun is(getState().censusDisplay.breakdown.by, "allocationStack", "Should be using allocation stack breakdown"); ok(!getState().allocations.recording, "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"); });
--- a/devtools/client/memory/test/browser/browser_memory_no_auto_expand.js +++ b/devtools/client/memory/test/browser/browser_memory_no_auto_expand.js @@ -22,16 +22,18 @@ this.test = makeMemoryTest(TEST_URL, fun yield dispatch(takeSnapshotAndCensus(front, heapWorker)); is(getState().allocations.recording, false); const recordingCheckbox = doc.getElementById("record-allocation-stacks-checkbox"); 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()}`); is(el.style.marginInlineStart, "0px", "None of the elements should be an indented/expanded child"); } });
--- 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,20 +1,21 @@ /* 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. // // IF THIS TEST STARTS FAILING, YOU ARE LEAKING EVERY WINDOW EVER NAVIGATED TO // WHILE DEVTOOLS ARE OPEN! THIS IS NOT SPECIFIC TO THE MEMORY TOOL ONLY! "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"; function* getWindowsInSnapshot(front) { dumpn("Taking snapshot."); const path = yield front.saveHeapSnapshot(); dumpn("Took snapshot with path = " + path); @@ -45,24 +46,21 @@ const DESCRIPTION = { }, other: { by: "internalType", then: { by: "count", count: true, bytes: false }, } }; 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); const endWindows = yield getWindowsInSnapshot(front); is(endWindows.length, 1); if (endWindows.length === 1) { @@ -79,25 +77,27 @@ this.test = makeMemoryTest(TEST_URL, fun dumpn("Reading full runtime heap snapshot."); const snapshot = ChromeUtils.readHeapSnapshot(path); dumpn("Done reading full runtime heap snapshot."); const dominatorTree = snapshot.computeDominatorTree(); 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])) { // Skip paths that loop out from the target window and back to it again. 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) + " (" + label.join(" > ") + ")"); dumpn(" |"); dumpn(" " + part.edge); dumpn(" |"); dumpn(" V");
--- a/devtools/client/memory/test/browser/browser_memory_simple_01.js +++ b/devtools/client/memory/test/browser/browser_memory_simple_01.js @@ -1,11 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + /** * Tests taking snapshots and default states. */ const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html"; const { viewState, censusState } = require("devtools/client/memory/constants"); const { changeView } = require("devtools/client/memory/actions/view"); @@ -18,23 +20,26 @@ this.test = makeMemoryTest(TEST_URL, fun 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 rendered"); yield takeSnapshot(panel.panelWin); 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"); });
--- 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,11 +1,13 @@ /* 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. "use strict"; const TEST_URL = "data:text/html,<html><body></body></html>";
--- a/devtools/client/memory/test/browser/browser_memory_tree_map-02.js +++ b/devtools/client/memory/test/browser/browser_memory_tree_map-02.js @@ -18,18 +18,18 @@ this.test = makeMemoryTest(TEST_URL, fun const panelWin = panel.panelWin; const panelDoc = panelWin.document; const div = panelDoc.createElement("div"); Object.assign(div.style, { width: "100px", height: "200px", position: "absolute", - left:0, - top:0 + left: 0, + top: 0 }); let rafMock = createRAFMock(); panelDoc.body.appendChild(div); let canvases = new CanvasUtils(div, 0); let dragZoom = new DragZoom(canvases.container, 0, rafMock.raf); @@ -73,18 +73,16 @@ this.test = makeMemoryTest(TEST_URL, fun is(dragZoom.zoom, dragZoom.smoothZoom, "The smooth and target zoom values match"); isnot(MAX_RAF_LOOP, i, "The RAF loop correctly stopped"); } info("Dragging correctly translates the div"); { - let initialX = dragZoom.translateX; - let initialY = dragZoom.translateY; div.dispatchEvent(new MouseEvent("mousemove", { clientX: 10, clientY: 10, })); div.dispatchEvent(new MouseEvent("mousedown")); div.dispatchEvent(new MouseEvent("mousemove", { clientX: 20, clientY: 20,
--- a/devtools/client/memory/test/browser/doc_big_tree.html +++ b/devtools/client/memory/test/browser/doc_big_tree.html @@ -1,15 +1,17 @@ <!DOCTYPE html> <html> - <body> - <script> - window.big = (function makeBig(depth = 0) { - var big = Array(5); - big.fill(undefined); - if (depth < 5) { - big = big.map(_ => makeBig(depth + 1)); - } - return big; - }()); - </script> - </body> + <body> + <script> + "use strict"; + + window.big = (function makeBig(depth = 0) { + let big = Array(5); + big.fill(undefined); + if (depth < 5) { + big = big.map(_ => makeBig(depth + 1)); + } + return big; + }()); + </script> + </body> </html>
--- a/devtools/client/memory/test/browser/doc_steady_allocation.html +++ b/devtools/client/memory/test/browser/doc_steady_allocation.html @@ -1,16 +1,18 @@ <!DOCTYPE html> <html> - <body> - <script> - var objects = window.objects = []; + <body> + <script> + "use strict"; - var allocate = this.allocate = function allocate() { - for (var i = 0; i < 100; i++) - objects.push({}); - setTimeout(allocate, 10); - } + var objects = window.objects = []; + var allocate = this.allocate = function allocate() { + for (let i = 0; i < 100; i++) { + objects.push({}); + } + setTimeout(allocate, 10); + }; - allocate(); - </script> - </body> + allocate(); + </script> + </body> </html>
--- a/devtools/client/memory/test/browser/head.js +++ b/devtools/client/memory/test/browser/head.js @@ -104,17 +104,18 @@ function waitUntilDominatorTreeState(sto return waitUntilState(store, predicate); } function takeSnapshot(window) { let { gStore, document } = 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) { let { gStore, document } = window; document.querySelector(".devtools-toolbar .clear-snapshots").click(); return waitUntilState(gStore, () => gStore.getState().snapshots.every( (snapshot) => snapshot.state !== states.READ) ); @@ -171,17 +172,16 @@ function getSelectedSnapshotIndex(store) * @return {Promise} */ function waitUntilSnapshotSelected(store, snapshotIndex) { return waitUntilState(store, state => state.snapshots[snapshotIndex] && state.snapshots[snapshotIndex].selected === true); } - /** * Wait until the state has censuses in a certain state. * * @return {Promise} */ function waitUntilCensusState(store, getCensus, expected) { let predicate = () => { let snapshots = store.getState().snapshots; @@ -214,17 +214,17 @@ function waitUntilCensusState(store, get */ function createRAFMock() { let queuedFns = []; let mock = { timesCalled: 0 }; 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](); } }; mock.raf = function (fn) { mock.timesCalled++; queuedFns.push(fn); };
new file mode 100644 --- /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" }], + } +};
--- a/devtools/client/memory/test/chrome/head.js +++ b/devtools/client/memory/test/chrome/head.js @@ -1,10 +1,11 @@ /* 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; var { BrowserLoader } = Cu.import("resource://devtools/client/shared/browser-loader.js", {}); var { require } = BrowserLoader({ baseURI: "resource://devtools/client/memory/", window @@ -12,18 +13,19 @@ var { require } = BrowserLoader({ var { Assert } = require("resource://testing-common/Assert.jsm"); var Services = require("Services"); var { Task } = require("devtools/shared/task"); 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); } }); var DevToolsUtils = require("devtools/shared/DevToolsUtils"); var { immutableUpdate } = DevToolsUtils; var flags = require("devtools/shared/flags"); flags.testing = true; @@ -110,17 +112,19 @@ function makeTestDominatorTreeNode(opts, shallowSize: 1, retainedSize: (children || []).reduce((size, c) => size + c.retainedSize, 1), parentId: undefined, children, moreChildrenAvailable: true, }, opts); if (children && children.length) { - children.map(c => c.parentId = node.nodeId); + children.map(c => { + c.parentId = node.nodeId; + }); } return node; } var TEST_DOMINATOR_TREE = Object.freeze({ dominatorTreeId: 666, root: (function makeTree(depth = 0) {
--- a/devtools/client/memory/test/unit/.eslintrc.js +++ b/devtools/client/memory/test/unit/.eslintrc.js @@ -1,6 +1,12 @@ "use strict"; 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$" + }] + } };
--- a/devtools/client/memory/test/unit/head.js +++ b/devtools/client/memory/test/unit/head.js @@ -21,17 +21,18 @@ var promise = require("promise"); var defer = require("devtools/shared/defer"); var { Task } = require("devtools/shared/task"); var { expectState } = require("devtools/server/actors/common"); var HeapSnapshotFileUtils = require("devtools/shared/heapsnapshot/HeapSnapshotFileUtils"); var HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient"); 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; do_register_cleanup(function () { equal(DevToolsUtils.assertionFailureCount, EXPECTED_DTU_ASSERT_FAILURE_COUNT, "Should have had the expected number of DevToolsUtils.assert() failures."); }); @@ -54,27 +55,30 @@ function StubbedMemoryFront() { StubbedMemoryFront.prototype.attach = Task.async(function* () { this.state = "attached"; }); 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 = () => { let snapshots = store.getState().snapshots; do_print(snapshots.map(x => x.state)); return snapshots.length === expected.length && expected.every((state, i) => state === "*" || snapshots[i].state === state); };
--- 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,15 +1,17 @@ /* 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() { run_next_test(); } add_task(function* () { let front = new StubbedMemoryFront();
--- 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,11 +1,13 @@ /* 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"); let { snapshotState: states, treeMapState, actions } = require("devtools/client/memory/constants"); function run_test() { run_next_test(); }
--- 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,11 +1,13 @@ /* 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"); let { snapshotState: states, treeMapState, actions } = require("devtools/client/memory/constants"); function run_test() { run_next_test(); }
--- 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,11 +1,13 @@ /* 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"); function run_test() { run_next_test(); } @@ -17,18 +19,17 @@ add_task(function* () { let store = Store(); const { getState, dispatch } = store; ok(true, "create 3 snapshots with a saved census"); dispatch(takeSnapshotAndCensus(front, heapWorker)); 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"); let id = getState().snapshots[0].id; dispatch({ type: actions.SNAPSHOT_ERROR, id, error: new Error("_") }); yield waitUntilSnapshotState(store, [states.ERROR, states.READ, states.READ]); ok(true, "first snapshot set to error state");
--- 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,15 +1,17 @@ /* 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(); } add_task(function* () { let front = new StubbedMemoryFront(); let heapWorker = new HeapAnalysesClient();
--- a/devtools/client/memory/test/unit/test_action-clear-snapshots_06.js +++ b/devtools/client/memory/test/unit/test_action-clear-snapshots_06.js @@ -5,17 +5,16 @@ // Test that clearSnapshots disables diffing when deleting snapshots const { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot"); const { - snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants"); const { toggleDiffing, selectSnapshotForDiffingAndRefresh } = require("devtools/client/memory/actions/diffing");
--- a/devtools/client/memory/test/unit/test_action-export-snapshot.js +++ b/devtools/client/memory/test/unit/test_action-export-snapshot.js @@ -1,16 +1,18 @@ /* 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(); } add_task(function* () { let front = new StubbedMemoryFront(); let heapWorker = new HeapAnalysesClient();
--- a/devtools/client/memory/test/unit/test_action-filter-01.js +++ b/devtools/client/memory/test/unit/test_action-filter-01.js @@ -1,11 +1,13 @@ /* 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"); function run_test() { run_next_test(); }
--- a/devtools/client/memory/test/unit/test_action-filter-02.js +++ b/devtools/client/memory/test/unit/test_action-filter-02.js @@ -1,18 +1,18 @@ /* 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() { run_next_test(); } add_task(function* () { let front = new StubbedMemoryFront(); @@ -25,50 +25,40 @@ add_task(function* () { equal(getState().filter, null, "no filter by default"); dispatch(takeSnapshotAndCensus(front, heapWorker)); dispatch(takeSnapshotAndCensus(front, heapWorker)); 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); equal(getState().snapshots[2].census.filter, "str"); 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"); equal(getState().snapshots[2].census.filter, "str"); heapWorker.destroy(); yield front.detach(); });
--- a/devtools/client/memory/test/unit/test_action-filter-03.js +++ b/devtools/client/memory/test/unit/test_action-filter-03.js @@ -1,11 +1,13 @@ /* 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. let { snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants"); let { setFilterString, setFilterStringAndRefresh } = require("devtools/client/memory/actions/filter"); let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); let { changeView } = require("devtools/client/memory/actions/view");
--- 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,10 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** * Tests the task creator `importSnapshotAndCensus()` for the whole flow of * importing a snapshot, and its sub-actions. */ let { actions, snapshotState: states, treeMapState } = require("devtools/client/memory/constants"); @@ -56,38 +57,45 @@ add_task(function* () { censusI++; } } }; 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 let snapshot1 = getState().snapshots[0]; let snapshot2 = getState().snapshots[1]; equal(snapshot1.treeMap.display, snapshot2.treeMap.display, "imported snapshot has correct display"); // Clone the census data so we can destructively remove the ID/parents to compare // equal census data 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 || []; for (let child of children) { delete child.id; delete child.parent; stripUnique(child); }
--- 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,10 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** * Tests `importSnapshotAndCensus()` when importing snapshots from the dominator * tree view. The snapshot is expected to be loaded and its dominator tree * should be computed. */
--- a/devtools/client/memory/test/unit/test_action-select-snapshot.js +++ b/devtools/client/memory/test/unit/test_action-select-snapshot.js @@ -1,11 +1,13 @@ /* 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)` */ let actions = require("devtools/client/memory/actions/snapshot"); let { snapshotState: states } = require("devtools/client/memory/constants"); function run_test() { @@ -16,22 +18,26 @@ add_task(function* () { let front = new StubbedMemoryFront(); yield front.attach(); let store = Store(); for (let i = 0; i < 5; i++) { 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}]`); store.dispatch(actions.selectSnapshot(store.getState().snapshots[i].id)); yield waitUntilState(store, ({ snapshots }) => snapshots[i].selected); 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; +}
--- 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,20 +1,21 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** * Tests the task creator `setCensusDisplayAndRefreshAndRefresh()` for display * changing. We test this rather than `setCensusDisplayAndRefresh` directly, as * we use the refresh action in the app itself composed from * `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"); function run_test() { run_next_test(); } @@ -58,61 +59,59 @@ add_task(function* () { // Updates when changing display during `SAVING` dispatch(takeSnapshotAndCensus(front, heapWorker)); yield waitUntilCensusState(store, snapshot => snapshot.census, [censusState.SAVED, censusState.SAVING]); dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.coarseType)); 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, "Second snapshot using `allocationStack` display and updated to correct display"); heapWorker.destroy(); yield front.detach(); });
--- 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,18 +1,19 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** * Tests the task creator `setCensusDisplayAndRefreshAndRefresh()` for custom * 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"); let CUSTOM = { displayName: "Custom", tooltip: "Custom tooltip", inverted: false, @@ -43,11 +44,12 @@ add_task(function* () { equal(getState().snapshots[0].census.display, CUSTOM, "New snapshot stored CUSTOM display when done taking census"); ok(getState().snapshots[0].census.report.children.length, "Census has some children"); // Ensure we don't have `count` in any results 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"); });
--- a/devtools/client/memory/test/unit/test_action-set-display.js +++ b/devtools/client/memory/test/unit/test_action-set-display.js @@ -1,19 +1,20 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** * Tests the action creator `setCensusDisplay()` for display changing. Does not * test refreshing the census information, check `setCensusDisplayAndRefresh` * 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"); function run_test() { run_next_test(); }
--- a/devtools/client/memory/test/unit/test_action-take-census.js +++ b/devtools/client/memory/test/unit/test_action-take-census.js @@ -1,20 +1,21 @@ /* 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(); } // This tests taking a census on a snapshot that is still being read, which // triggers an assertion failure. EXPECTED_DTU_ASSERT_FAILURE_COUNT = 1; @@ -50,10 +51,9 @@ add_task(function* () { yield waitUntilCensusState(store, s => s.census, [censusState.SAVING]); yield waitUntilCensusState(store, s => s.census, [censusState.SAVED]); snapshot = store.getState().snapshots[0]; ok(snapshot.census, "Snapshot has census after saved census"); 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"); - });
--- 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,11 +1,13 @@ /* 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. */ let { snapshotState: states, treeMapState } = require("devtools/client/memory/constants"); let actions = require("devtools/client/memory/actions/snapshot"); @@ -38,21 +40,23 @@ add_task(function* () { if (snapshot.treeMap && censusI < censusStates.length) { if (snapshot.treeMap.state === treeMapState[censusStates[censusI]]) { ok(true, `Found expected census state ${censusStates[censusI]}`); censusI++; } } }; - 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"); });
--- a/devtools/client/memory/test/unit/test_action-take-snapshot.js +++ b/devtools/client/memory/test/unit/test_action-take-snapshot.js @@ -1,11 +1,13 @@ /* 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)` */ let actions = require("devtools/client/memory/actions/snapshot"); let { snapshotState: states } = require("devtools/client/memory/constants"); function run_test() { @@ -26,18 +28,17 @@ add_task(function* () { let { snapshots } = store.getState(); let lastSnapshot = snapshots[snapshots.length - 1]; if (lastSnapshot.state === states.SAVING) { foundPendingState = true; 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"); ok(lastSnapshot.path, "Snapshot fetched with a path"); ok(snapshots.every(s => s.selected === (s.id === lastSnapshot.id)), "Only recent snapshot is selected"); } }
--- 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,17 +1,18 @@ /* 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"); const { setCensusDisplayAndRefresh } = require("devtools/client/memory/actions/census-display"); const { takeSnapshotAndCensus, @@ -35,48 +36,44 @@ add_task(function* () { // Select a non-inverted display. dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack)); equal(getState().censusDisplay.inverted, false, "not inverted by default"); 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(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); equal(getState().snapshots[2].census.display.inverted, true); heapWorker.destroy(); yield front.detach(); });
--- 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,10 +1,11 @@ /* 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 // in an inverted census. const { censusDisplays, snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants"); const { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot"); const { @@ -28,31 +29,33 @@ add_task(function* () { dispatch(setCensusDisplay(censusDisplays.allocationStack)); equal(getState().censusDisplay.inverted, false, "Should not have an inverted census display"); 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]); ok(getState().censusDisplay.inverted, "should want inverted trees"); ok(getState().snapshots[0].census.display.inverted, "snapshot-we-were-in-the-middle-of-saving's census should be inverted"); dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack)); yield waitUntilCensusState(store, s => s.census, [censusState.SAVING]); 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, "census-we-were-in-the-middle-of-recomputing should be inverted again"); heapWorker.destroy(); yield front.detach(); });
--- a/devtools/client/memory/test/unit/test_action-toggle-inverted.js +++ b/devtools/client/memory/test/unit/test_action-toggle-inverted.js @@ -1,10 +1,11 @@ /* 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. const { censusDisplays } = require("devtools/client/memory/constants"); const { setCensusDisplay } = require("devtools/client/memory/actions/census-display"); function run_test() {
--- 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,10 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** * Test toggling the recording of allocation stacks. */ let { toggleRecordingAllocationStacks } = require("devtools/client/memory/actions/allocations");
--- a/devtools/client/memory/test/unit/test_action_diffing_01.js +++ b/devtools/client/memory/test/unit/test_action_diffing_01.js @@ -1,11 +1,13 @@ /* 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"); function run_test() { run_next_test(); }
--- a/devtools/client/memory/test/unit/test_action_diffing_02.js +++ b/devtools/client/memory/test/unit/test_action_diffing_02.js @@ -1,14 +1,16 @@ /* 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"); function run_test() { run_next_test(); } @@ -21,19 +23,18 @@ add_task(function* () { dispatch(changeView(viewState.CENSUS)); equal(getState().diffing, null, "not diffing by default"); 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"); dispatch(toggleDiffing()); ok(getState().diffing, "now diffing after toggling"); for (let s of getState().snapshots) {
--- a/devtools/client/memory/test/unit/test_action_diffing_03.js +++ b/devtools/client/memory/test/unit/test_action_diffing_03.js @@ -1,11 +1,13 @@ /* 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"); const { toggleDiffing, selectSnapshotForDiffing } = require("devtools/client/memory/actions/diffing"); const { takeSnapshot } = require("devtools/client/memory/actions/snapshot"); @@ -29,19 +31,18 @@ add_task(function* () { dispatch(changeView(viewState.CENSUS)); equal(getState().diffing, null, "not diffing by default"); dispatch(takeSnapshot(front, heapWorker)); 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. dispatch(toggleDiffing()); ok(getState().diffing, "now diffing after toggling"); equal(getState().diffing.firstSnapshotId, null, "no first snapshot selected"); equal(getState().diffing.secondSnapshotId, null,
--- a/devtools/client/memory/test/unit/test_action_diffing_04.js +++ b/devtools/client/memory/test/unit/test_action_diffing_04.js @@ -1,11 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + // Test that we compute census diffs. const { diffingState, snapshotState, viewState } = require("devtools/client/memory/constants"); const { @@ -33,19 +35,18 @@ add_task(function* () { equal(getState().diffing, null, "not diffing by default"); const s1 = yield dispatch(takeSnapshot(front, heapWorker)); const s2 = yield dispatch(takeSnapshot(front, heapWorker)); const s3 = yield dispatch(takeSnapshot(front, heapWorker)); 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, getState().snapshots[0])); dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, getState().snapshots[1])); ok(getState().diffing, "We should be diffing.");
--- a/devtools/client/memory/test/unit/test_action_diffing_05.js +++ b/devtools/client/memory/test/unit/test_action_diffing_05.js @@ -1,11 +1,13 @@ /* 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 { diffingState, snapshotState, censusDisplays, viewState, } = require("devtools/client/memory/constants"); @@ -45,19 +47,18 @@ add_task(function* () { equal(getState().diffing, null, "not diffing by default"); const s1 = yield dispatch(takeSnapshot(front, heapWorker)); const s2 = yield dispatch(takeSnapshot(front, heapWorker)); const s3 = yield dispatch(takeSnapshot(front, heapWorker)); 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, getState().snapshots[0])); dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, getState().snapshots[1])); yield waitUntilState(store, state => state.diffing.state === diffingState.TOOK_DIFF);
--- a/devtools/client/memory/test/unit/test_dominator_trees_01.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_01.js @@ -1,15 +1,16 @@ /* 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"); let { takeSnapshotAndCensus, computeAndFetchDominatorTree, } = require("devtools/client/memory/actions/snapshot");
--- a/devtools/client/memory/test/unit/test_dominator_trees_02.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_02.js @@ -1,16 +1,17 @@ /* 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, } = require("devtools/client/memory/constants"); const { takeSnapshotAndCensus, } = require("devtools/client/memory/actions/snapshot"); const {
--- a/devtools/client/memory/test/unit/test_dominator_trees_03.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_03.js @@ -1,16 +1,17 @@ /* 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"); const { takeSnapshotAndCensus, } = require("devtools/client/memory/actions/snapshot"); const { changeView
--- a/devtools/client/memory/test/unit/test_dominator_trees_04.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_04.js @@ -1,11 +1,13 @@ /* 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. const { snapshotState: states, dominatorTreeState, viewState, } = require("devtools/client/memory/constants"); @@ -20,20 +22,19 @@ function run_test() { run_next_test(); } add_task(function* () { let front = new StubbedMemoryFront(); 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; dispatch(takeSnapshotAndCensus(front, heapWorker)); yield waitUntilSnapshotState(store, [intermediateSnapshotState]); dispatch(changeView(viewState.DOMINATOR_TREE));
--- a/devtools/client/memory/test/unit/test_dominator_trees_05.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_05.js @@ -1,16 +1,17 @@ /* 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, } = require("devtools/client/memory/constants"); let { takeSnapshotAndCensus, selectSnapshotAndRefresh, } = require("devtools/client/memory/actions/snapshot"); @@ -25,18 +26,18 @@ add_task(function* () { let front = new StubbedMemoryFront(); let heapWorker = new HeapAnalysesClient(); yield front.attach(); let store = Store(); let { getState, dispatch } = store; 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"); // Change to the dominator tree view. dispatch(changeView(viewState.DOMINATOR_TREE)); // Wait for the dominator tree to finish being fetched. yield waitUntilState(store, state =>
--- a/devtools/client/memory/test/unit/test_dominator_trees_06.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_06.js @@ -1,21 +1,21 @@ /* 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 = require("devtools/client/memory/dominator-tree-lazy-children"); const { changeView } = require("devtools/client/memory/actions/view"); function run_test() { @@ -63,17 +63,18 @@ add_task(function* () { const oldNode = findNode(oldRoot); ok(oldNode, "Should have found a node with children that are not loaded since we " + "only send partial dominator trees across initially and load the rest " + "on demand"); 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, "Fetching immediately dominated children should put us in the " + "INCREMENTAL_FETCHING state"); yield waitUntilState(store, state => state.snapshots[0].dominatorTree.state === dominatorTreeState.LOADED); @@ -114,14 +115,15 @@ add_task(function* () { } } return null; } 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(); yield front.detach(); });
--- a/devtools/client/memory/test/unit/test_dominator_trees_07.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_07.js @@ -1,22 +1,22 @@ /* 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 = require("devtools/client/memory/dominator-tree-lazy-children"); const { changeView } = require("devtools/client/memory/actions/view"); function run_test() {
--- a/devtools/client/memory/test/unit/test_dominator_trees_08.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_08.js @@ -1,30 +1,30 @@ /* 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, treeMapState } = require("devtools/client/memory/constants"); const { setLabelDisplayAndRefresh } = require("devtools/client/memory/actions/label-display"); const { changeView, } = require("devtools/client/memory/actions/view"); const { takeSnapshotAndCensus, - computeAndFetchDominatorTree, } = require("devtools/client/memory/actions/snapshot"); function run_test() { run_next_test(); } add_task(function* () { let front = new StubbedMemoryFront();
--- a/devtools/client/memory/test/unit/test_dominator_trees_09.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_09.js @@ -1,30 +1,30 @@ /* 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, treeMapState, } = require("devtools/client/memory/constants"); const { setLabelDisplayAndRefresh } = require("devtools/client/memory/actions/label-display"); const { changeView, } = require("devtools/client/memory/actions/view"); const { takeSnapshotAndCensus, - computeAndFetchDominatorTree, } = require("devtools/client/memory/actions/snapshot"); function run_test() { run_next_test(); } add_task(function* () { let front = new StubbedMemoryFront();
--- a/devtools/client/memory/test/unit/test_dominator_trees_10.js +++ b/devtools/client/memory/test/unit/test_dominator_trees_10.js @@ -1,16 +1,17 @@ /* 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, } = require("devtools/client/memory/constants"); let { takeSnapshotAndCensus, focusDominatorTreeNode, } = require("devtools/client/memory/actions/snapshot");
--- a/devtools/client/memory/test/unit/test_individuals_01.js +++ b/devtools/client/memory/test/unit/test_individuals_01.js @@ -1,10 +1,11 @@ /* 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. const { censusState, viewState, individualsState,
--- a/devtools/client/memory/test/unit/test_individuals_02.js +++ b/devtools/client/memory/test/unit/test_individuals_02.js @@ -1,10 +1,11 @@ /* 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 // a dominator tree. const { censusState, dominatorTreeState,
--- a/devtools/client/memory/test/unit/test_individuals_03.js +++ b/devtools/client/memory/test/unit/test_individuals_03.js @@ -1,10 +1,11 @@ /* 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. const { censusState, diffingState, viewState, @@ -40,18 +41,18 @@ add_task(function* () { const { getState, dispatch } = store; dispatch(changeView(viewState.CENSUS)); // Take two snapshots and diff them from each other. 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])); dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, getState().snapshots[1])); yield waitUntilState(store, state => { return state.diffing && state.diffing.state === diffingState.TOOK_DIFF;
--- a/devtools/client/memory/test/unit/test_individuals_04.js +++ b/devtools/client/memory/test/unit/test_individuals_04.js @@ -1,10 +1,11 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; // Test showing individual Array objects. const { censusState, viewState, individualsState,
--- a/devtools/client/memory/test/unit/test_individuals_05.js +++ b/devtools/client/memory/test/unit/test_individuals_05.js @@ -1,10 +1,11 @@ /* 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. const { censusState, viewState, individualsState,
--- a/devtools/client/memory/test/unit/test_individuals_06.js +++ b/devtools/client/memory/test/unit/test_individuals_06.js @@ -1,10 +1,11 @@ /* 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 // view. const { censusState, viewState,
--- a/devtools/client/memory/test/unit/test_pop_view_01.js +++ b/devtools/client/memory/test/unit/test_pop_view_01.js @@ -1,10 +1,11 @@ /* 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. const { censusState, viewState, individualsState,
--- a/devtools/client/memory/test/unit/test_tree-map-01.js +++ b/devtools/client/memory/test/unit/test_tree-map-01.js @@ -1,22 +1,28 @@ /* 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() { run_next_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, y: 30, dx: 50, dy: 70, type: "other", depth: 2 @@ -31,17 +37,16 @@ add_task(function* () { drawBox(ctx, node, borderWidth, dragZoom, padding); ok(true, JSON.stringify([ctx, fillRectValues, strokeRectValues])); equal(ctx.fillStyle, "hsl(210,60%,70%)", "The fillStyle is set"); equal(ctx.strokeStyle, "hsl(210,60%,35%)", "The strokeStyle is set"); equal(ctx.lineWidth, 1, "The lineWidth is set"); 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); ok(true, JSON.stringify([ctx, fillRectValues, strokeRectValues])); deepEqual(fillRectValues, [15.5, 30.5, 74, 104], "Draws a zoomed filled rectangle"); deepEqual(strokeRectValues, [15.5, 30.5, 74, 104], "Draws a zoomed stroked rectangle");
--- 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,18 +1,19 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ + "use strict"; /** * Tests that we use the correct snapshot aggregate value * 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"); const { changeView } = require("devtools/client/memory/actions/view"); function run_test() { run_next_test(); }
--- a/devtools/client/memory/test/unit/test_utils.js +++ b/devtools/client/memory/test/unit/test_utils.js @@ -1,10 +1,11 @@ /* 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. Tests the formatNumber and * formatPercent methods. */ @@ -14,21 +15,23 @@ let { Preferences } = require("resource: function run_test() { run_next_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"); ok(true, "test formatNumber util functions"); equal(utils.formatNumber(12), "12", "formatNumber returns 12 for 12"); equal(utils.formatNumber(0), "0", "formatNumber returns 0 for 0");
--- a/devtools/client/memory/utils.js +++ b/devtools/client/memory/utils.js @@ -1,13 +1,15 @@ /* 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/. */ -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"; const L10N = exports.L10N = new LocalizationHelper(STRINGS_URI); const { OS } = require("resource://gre/modules/osfile.jsm"); const { assert } = require("devtools/shared/DevToolsUtils"); const { Preferences } = require("resource://gre/modules/Preferences.jsm"); @@ -325,17 +327,16 @@ exports.createSnapshot = function create */ exports.censusIsUpToDate = function (filter, display, census) { return census // Filter could be null == undefined so use loose equality. && filter == census.filter && display === census.display; }; - /** * Check to see if the snapshot is in a state that it can take a census. * * @param {SnapshotModel} A snapshot to check. * @param {Boolean} Assert that the snapshot must be in a ready state. * @returns {Boolean} */ exports.canTakeCensus = function (snapshot) { @@ -408,18 +409,18 @@ exports.getSnapshotTotals = function (ce * @param {String} .defaultName * The default name chosen by the file picker window. * @param {String} .mode * The mode that this filepicker should open in. Can be "open" or "save". * @return {Promise<?nsILocalFile>} * 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."); } let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); fp.init(window, title, mode);