Bug 1251728 - Make devtools/client/memory/ eslint clean. r=ntim

MozReview-Commit-ID: KlM4HF81imy
This commit is contained in:
tdraebing 2016-12-21 15:21:24 +01:00
parent aea12c5f05
commit 523c563b92
106 changed files with 662 additions and 492 deletions

View File

@ -86,7 +86,6 @@ devtools/client/framework/**
!devtools/client/framework/selection.js
!devtools/client/framework/toolbox.js
devtools/client/jsonview/lib/**
devtools/client/memory/**
devtools/client/netmonitor/test/**
devtools/client/netmonitor/har/test/**
devtools/client/projecteditor/**

View File

@ -0,0 +1,11 @@
"use strict";
module.exports = {
"env": {
"browser": true,
},
"globals": {
"d3": true,
"dagreD3": true,
}
};

View File

@ -25,7 +25,8 @@ const setCensusDisplay = exports.setCensusDisplay = function (display) {
&& display
&& display.breakdown
&& display.breakdown.by,
`Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`);
"Breakdowns must be an object with a \`by\` property, attempted to set: " +
uneval(display));
return {
type: actions.SET_CENSUS_DISPLAY,

View File

@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert, reportException } = require("devtools/shared/DevToolsUtils");
@ -12,13 +13,11 @@ const {
snapshotIsDiffable,
findSelectedSnapshot,
} = require("../utils");
// This is a circular dependency, so do not destructure the needed properties.
const snapshotActions = require("./snapshot");
/**
* Toggle diffing mode on or off.
*/
const toggleDiffing = exports.toggleDiffing = function () {
exports.toggleDiffing = function () {
return function (dispatch, getState) {
dispatch({
type: actions.CHANGE_VIEW,
@ -155,7 +154,7 @@ const refreshDiffing = exports.refreshDiffing = function (heapWorker) {
* @param {HeapAnalysesClient} heapWorker
* @param {snapshotModel} snapshot
*/
const selectSnapshotForDiffingAndRefresh = exports.selectSnapshotForDiffingAndRefresh = function (heapWorker, snapshot) {
exports.selectSnapshotForDiffingAndRefresh = function (heapWorker, snapshot) {
return function* (dispatch, getState) {
assert(getState().diffing,
"If we are selecting for diffing, we must be in diffing mode");
@ -169,7 +168,7 @@ const selectSnapshotForDiffingAndRefresh = exports.selectSnapshotForDiffingAndRe
*
* @param {CensusTreeNode} node
*/
const expandDiffingCensusNode = exports.expandDiffingCensusNode = function (node) {
exports.expandDiffingCensusNode = function (node) {
return {
type: actions.EXPAND_DIFFING_CENSUS_NODE,
node,
@ -181,7 +180,7 @@ const expandDiffingCensusNode = exports.expandDiffingCensusNode = function (node
*
* @param {CensusTreeNode} node
*/
const collapseDiffingCensusNode = exports.collapseDiffingCensusNode = function (node) {
exports.collapseDiffingCensusNode = function (node) {
return {
type: actions.COLLAPSE_DIFFING_CENSUS_NODE,
node,
@ -193,7 +192,7 @@ const collapseDiffingCensusNode = exports.collapseDiffingCensusNode = function (
*
* @param {DominatorTreeNode} node
*/
const focusDiffingCensusNode = exports.focusDiffingCensusNode = function (node) {
exports.focusDiffingCensusNode = function (node) {
return {
type: actions.FOCUS_DIFFING_CENSUS_NODE,
node,

View File

@ -4,16 +4,14 @@
"use strict";
const { immutableUpdate, reportException, assert } = require("devtools/shared/DevToolsUtils");
const { snapshotState: states, actions, viewState } = require("../constants");
const { snapshotState: states, actions} = require("../constants");
const { L10N, openFilePicker, createSnapshot } = require("../utils");
const telemetry = require("../telemetry");
const { OS } = require("resource://gre/modules/osfile.jsm");
const {
selectSnapshot,
computeSnapshotData,
readSnapshot,
takeCensus,
takeTreeMap
readSnapshot
} = require("./snapshot");
const VALID_EXPORT_STATES = [states.SAVED, states.READ];
@ -54,7 +52,7 @@ const exportSnapshot = exports.exportSnapshot = function (snapshot, dest) {
};
};
const pickFileAndImportSnapshotAndCensus = exports.pickFileAndImportSnapshotAndCensus = function (heapWorker) {
exports.pickFileAndImportSnapshotAndCensus = function (heapWorker) {
return function* (dispatch, getState) {
let input = yield openFilePicker({
title: L10N.getFormatStr("snapshot.io.import.window"),
@ -70,7 +68,7 @@ const pickFileAndImportSnapshotAndCensus = exports.pickFileAndImportSnapshotAndC
};
};
const importSnapshotAndCensus = exports.importSnapshotAndCensus = function (heapWorker, path) {
const importSnapshotAndCensus = function (heapWorker, path) {
return function* (dispatch, getState) {
telemetry.countImportSnapshot();
@ -95,3 +93,4 @@ const importSnapshotAndCensus = exports.importSnapshotAndCensus = function (heap
dispatch({ type: actions.IMPORT_SNAPSHOT_END, id });
};
};
exports.importSnapshotAndCensus = importSnapshotAndCensus;

View File

@ -29,7 +29,8 @@ const setLabelDisplay = exports.setLabelDisplay = function (display) {
&& display
&& display.breakdown
&& display.breakdown.by,
`Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`);
"Breakdowns must be an object with a \`by\` property, attempted to set: " +
uneval(display));
return {
type: actions.SET_LABEL_DISPLAY,

View File

@ -34,7 +34,7 @@ const TaskCache = require("./task-cache");
* @param {HeapAnalysesClient}
* @param {Object}
*/
const takeSnapshotAndCensus = exports.takeSnapshotAndCensus = function (front, heapWorker) {
exports.takeSnapshotAndCensus = function (front, heapWorker) {
return function* (dispatch, getState) {
const id = yield dispatch(takeSnapshot(front));
if (id === null) {
@ -82,7 +82,7 @@ const computeSnapshotData = exports.computeSnapshotData = function (heapWorker,
* @param {HeapAnalysesClient} heapWorker
* @param {snapshotId} id
*/
const selectSnapshotAndRefresh = exports.selectSnapshotAndRefresh = function (heapWorker, id) {
exports.selectSnapshotAndRefresh = function (heapWorker, id) {
return function* (dispatch, getState) {
if (getState().diffing || getState().individuals) {
dispatch(view.changeView(viewState.CENSUS));
@ -200,7 +200,9 @@ function makeTakeCensusTask({ getDisplay, getFilter, getCensus, beginAction,
// Assert that snapshot is in a valid state
assert(canTakeCensus(snapshot),
`Attempting to take a census when the snapshot is not in a ready state. snapshot.state = ${snapshot.state}, census.state = ${(getCensus(snapshot) || { state: null }).state}`);
"Attempting to take a census when the snapshot is not in a ready state. " +
`snapshot.state = ${snapshot.state}, ` +
`census.state = ${(getCensus(snapshot) || { state: null }).state}`);
let report, parentMap;
let display = getDisplay(getState());
@ -322,7 +324,7 @@ const getCurrentCensusTaker = exports.getCurrentCensusTaker = function (currentV
*
* @param {DominatorTreeNode} node.
*/
const focusIndividual = exports.focusIndividual = function (node) {
exports.focusIndividual = function (node) {
return {
type: actions.FOCUS_INDIVIDUAL,
node,
@ -412,7 +414,7 @@ function (heapWorker, id, censusBreakdown, reportLeafIndex) {
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshIndividuals = exports.refreshIndividuals = function (heapWorker) {
exports.refreshIndividuals = function (heapWorker) {
return function* (dispatch, getState) {
assert(getState().view.state === viewState.INDIVIDUALS,
"Should be in INDIVIDUALS view.");
@ -453,7 +455,7 @@ const refreshIndividuals = exports.refreshIndividuals = function (heapWorker) {
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshSelectedCensus = exports.refreshSelectedCensus = function (heapWorker) {
exports.refreshSelectedCensus = function (heapWorker) {
return function* (dispatch, getState) {
let snapshot = getState().snapshots.find(s => s.selected);
if (!snapshot || snapshot.state !== states.READ) {
@ -479,7 +481,7 @@ const refreshSelectedCensus = exports.refreshSelectedCensus = function (heapWork
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshSelectedTreeMap = exports.refreshSelectedTreeMap = function (heapWorker) {
exports.refreshSelectedTreeMap = function (heapWorker) {
return function* (dispatch, getState) {
let snapshot = getState().snapshots.find(s => s.selected);
if (!snapshot || snapshot.state !== states.READ) {
@ -596,8 +598,7 @@ TaskCache.declareCacheableTask({
* @param {SnapshotId} id
* @param {DominatorTreeLazyChildren} lazyChildren
*/
const fetchImmediatelyDominated = exports.fetchImmediatelyDominated =
TaskCache.declareCacheableTask({
exports.fetchImmediatelyDominated = TaskCache.declareCacheableTask({
getCacheKey(_, id, lazyChildren) {
return `${id}-${lazyChildren.key()}`;
},
@ -630,7 +631,7 @@ TaskCache.declareCacheableTask({
removeFromCache();
reportException("actions/snapshot/fetchImmediatelyDominated", error);
dispatch({ type: actions.DOMINATOR_TREE_ERROR, id, error });
return null;
return;
}
}
while (display !== getState().labelDisplay);
@ -643,6 +644,7 @@ TaskCache.declareCacheableTask({
nodes: response.nodes,
moreChildrenAvailable: response.moreChildrenAvailable,
});
return;
}
});
@ -684,7 +686,7 @@ TaskCache.declareCacheableTask({
*
* @param {HeapAnalysesClient} heapWorker
*/
const refreshSelectedDominatorTree = exports.refreshSelectedDominatorTree = function (heapWorker) {
exports.refreshSelectedDominatorTree = function (heapWorker) {
return function* (dispatch, getState) {
let snapshot = getState().snapshots.find(s => s.selected);
if (!snapshot) {
@ -731,7 +733,7 @@ const selectSnapshot = exports.selectSnapshot = function (id) {
*
* @param {HeapAnalysesClient} heapWorker
*/
const clearSnapshots = exports.clearSnapshots = function (heapWorker) {
exports.clearSnapshots = function (heapWorker) {
return function* (dispatch, getState) {
let snapshots = getState().snapshots.filter(s => {
let snapshotReady = s.state === states.READ || s.state === states.ERROR;
@ -769,7 +771,7 @@ const clearSnapshots = exports.clearSnapshots = function (heapWorker) {
* @param {HeapAnalysesClient} heapWorker
* @param {snapshotModel} snapshot
*/
const deleteSnapshot = exports.deleteSnapshot = function (heapWorker, snapshot) {
exports.deleteSnapshot = function (heapWorker, snapshot) {
return function* (dispatch, getState) {
dispatch({ type: actions.DELETE_SNAPSHOTS_START, ids: [snapshot.id] });
@ -789,7 +791,7 @@ const deleteSnapshot = exports.deleteSnapshot = function (heapWorker, snapshot)
*
* @param {CensusTreeNode} node
*/
const expandCensusNode = exports.expandCensusNode = function (id, node) {
exports.expandCensusNode = function (id, node) {
return {
type: actions.EXPAND_CENSUS_NODE,
id,
@ -802,7 +804,7 @@ const expandCensusNode = exports.expandCensusNode = function (id, node) {
*
* @param {CensusTreeNode} node
*/
const collapseCensusNode = exports.collapseCensusNode = function (id, node) {
exports.collapseCensusNode = function (id, node) {
return {
type: actions.COLLAPSE_CENSUS_NODE,
id,
@ -816,7 +818,7 @@ const collapseCensusNode = exports.collapseCensusNode = function (id, node) {
* @param {SnapshotId} id
* @param {DominatorTreeNode} node
*/
const focusCensusNode = exports.focusCensusNode = function (id, node) {
exports.focusCensusNode = function (id, node) {
return {
type: actions.FOCUS_CENSUS_NODE,
id,
@ -829,7 +831,7 @@ const focusCensusNode = exports.focusCensusNode = function (id, node) {
*
* @param {DominatorTreeTreeNode} node
*/
const expandDominatorTreeNode = exports.expandDominatorTreeNode = function (id, node) {
exports.expandDominatorTreeNode = function (id, node) {
return {
type: actions.EXPAND_DOMINATOR_TREE_NODE,
id,
@ -842,7 +844,7 @@ const expandDominatorTreeNode = exports.expandDominatorTreeNode = function (id,
*
* @param {DominatorTreeTreeNode} node
*/
const collapseDominatorTreeNode = exports.collapseDominatorTreeNode = function (id, node) {
exports.collapseDominatorTreeNode = function (id, node) {
return {
type: actions.COLLAPSE_DOMINATOR_TREE_NODE,
id,
@ -856,7 +858,7 @@ const collapseDominatorTreeNode = exports.collapseDominatorTreeNode = function (
* @param {SnapshotId} id
* @param {DominatorTreeNode} node
*/
const focusDominatorTreeNode = exports.focusDominatorTreeNode = function (id, node) {
exports.focusDominatorTreeNode = function (id, node) {
return {
type: actions.FOCUS_DOMINATOR_TREE_NODE,
id,

View File

@ -28,7 +28,8 @@ const setTreeMap = exports.setTreeMap = function (display) {
&& display
&& display.breakdown
&& display.breakdown.by,
`Breakdowns must be an object with a \`by\` property, attempted to set: ${uneval(display)}`);
"Breakdowns must be an object with a \`by\` property, attempted to set: " +
uneval(display));
return {
type: actions.SET_TREE_MAP_DISPLAY,

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert } = require("devtools/shared/DevToolsUtils");
const { appinfo } = require("Services");
const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react");
@ -54,10 +56,24 @@ const MemoryApp = createClass({
propTypes: appModel,
childContextTypes: {
front: PropTypes.any,
heapWorker: PropTypes.any,
toolbox: PropTypes.any,
},
getDefaultProps() {
return {};
},
getChildContext() {
return {
front: this.props.front,
heapWorker: this.props.heapWorker,
toolbox: this.props.toolbox,
};
},
componentDidMount() {
// Attach the keydown listener directly to the window. When an element that
// has the focus (such as a tree node) is removed from the DOM, the focus
@ -69,20 +85,6 @@ const MemoryApp = createClass({
window.removeEventListener("keydown", this.onKeyDown);
},
childContextTypes: {
front: PropTypes.any,
heapWorker: PropTypes.any,
toolbox: PropTypes.any,
},
getChildContext() {
return {
front: this.props.front,
heapWorker: this.props.heapWorker,
toolbox: this.props.toolbox,
};
},
onKeyDown(e) {
let { snapshots, dispatch, heapWorker } = this.props;
const selectedSnapshot = snapshots.find(s => s.selected);
@ -219,7 +221,8 @@ const MemoryApp = createClass({
Heap({
snapshot: selectedSnapshot,
diffing,
onViewSourceInDebugger: frame => toolbox.viewSourceInDebugger(frame.source, frame.line),
onViewSourceInDebugger: frame =>
toolbox.viewSourceInDebugger(frame.source, frame.line),
onSnapshotClick: () =>
dispatch(takeSnapshotAndCensus(front, heapWorker)),
onLoadMoreSiblings: lazyChildren =>
@ -249,7 +252,8 @@ const MemoryApp = createClass({
dispatch(expandDiffingCensusNode(node));
} else {
assert(selectedSnapshot && selectedSnapshot.census === census,
"If not diffing, should be expanding on selected snapshot's census");
"If not diffing, " +
"should be expanding on selected snapshot's census");
dispatch(expandCensusNode(selectedSnapshot.id, node));
}
},
@ -260,7 +264,8 @@ const MemoryApp = createClass({
dispatch(collapseDiffingCensusNode(node));
} else {
assert(selectedSnapshot && selectedSnapshot.census === census,
"If not diffing, should be collapsing on selected snapshot's census");
"If not diffing, " +
"should be collapsing on selected snapshot's census");
dispatch(collapseCensusNode(selectedSnapshot.id, node));
}
},
@ -271,13 +276,15 @@ const MemoryApp = createClass({
dispatch(focusDiffingCensusNode(node));
} else {
assert(selectedSnapshot && selectedSnapshot.census === census,
"If not diffing, should be focusing on nodes in selected snapshot's census");
"If not diffing, " +
"should be focusing on nodes in selected snapshot's census");
dispatch(focusCensusNode(selectedSnapshot.id, node));
}
},
onDominatorTreeExpand: node => {
assert(view.state === viewState.DOMINATOR_TREE,
"If expanding dominator tree nodes, should be in dominator tree view");
"If expanding dominator tree nodes, " +
"should be in dominator tree view");
assert(selectedSnapshot, "...and we should have a selected snapshot");
assert(selectedSnapshot.dominatorTree,
"...and that snapshot should have a dominator tree");
@ -285,7 +292,8 @@ const MemoryApp = createClass({
},
onDominatorTreeCollapse: node => {
assert(view.state === viewState.DOMINATOR_TREE,
"If collapsing dominator tree nodes, should be in dominator tree view");
"If collapsing dominator tree nodes, " +
"should be in dominator tree view");
assert(selectedSnapshot, "...and we should have a selected snapshot");
assert(selectedSnapshot.dominatorTree,
"...and that snapshot should have a dominator tree");
@ -293,7 +301,8 @@ const MemoryApp = createClass({
},
onDominatorTreeFocus: node => {
assert(view.state === viewState.DOMINATOR_TREE,
"If focusing dominator tree nodes, should be in dominator tree view");
"If focusing dominator tree nodes, " +
"should be in dominator tree view");
assert(selectedSnapshot, "...and we should have a selected snapshot");
assert(selectedSnapshot.dominatorTree,
"...and that snapshot should have a dominator tree");

View File

@ -2,11 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react");
const { L10N } = require("../utils");
const models = require("../models");
const CensusHeader = module.exports = createClass({
module.exports = createClass({
displayName: "CensusHeader",
propTypes: {

View File

@ -9,7 +9,7 @@ const { L10N, formatNumber, formatPercent } = require("../utils");
const Frame = createFactory(require("devtools/client/shared/components/frame"));
const { TREE_ROW_HEIGHT } = require("../constants");
const CensusTreeItem = module.exports = createClass({
module.exports = createClass({
displayName: "CensusTreeItem",
shouldComponentUpdate(nextProps, nextState) {
@ -20,6 +20,31 @@ const CensusTreeItem = module.exports = createClass({
|| this.props.diffing != nextProps.diffing;
},
toLabel(name, linkToDebugger) {
if (isSavedFrame(name)) {
return Frame({
frame: name,
onClick: () => linkToDebugger(name),
showFunctionName: true,
showHost: true,
});
}
if (name === null) {
return L10N.getStr("tree-item.root");
}
if (name === "noStack") {
return L10N.getStr("tree-item.nostack");
}
if (name === "noFilename") {
return L10N.getStr("tree-item.nofilename");
}
return String(name);
},
render() {
let {
item,
@ -106,29 +131,4 @@ const CensusTreeItem = module.exports = createClass({
)
);
},
toLabel(name, linkToDebugger) {
if (isSavedFrame(name)) {
return Frame({
frame: name,
onClick: () => linkToDebugger(name),
showFunctionName: true,
showHost: true,
});
}
if (name === null) {
return L10N.getStr("tree-item.root");
}
if (name === "noStack") {
return L10N.getStr("tree-item.nostack");
}
if (name === "noFilename") {
return L10N.getStr("tree-item.nofilename");
}
return String(name);
},
});

View File

@ -2,14 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
"use strict";
const { createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const Tree = createFactory(require("devtools/client/shared/components/tree"));
const CensusTreeItem = createFactory(require("./census-tree-item"));
const { createParentMap } = require("../utils");
const { TREE_ROW_HEIGHT } = require("../constants");
const { censusModel, diffingModel } = require("../models");
const Census = module.exports = createClass({
module.exports = createClass({
displayName: "Census",
propTypes: {

View File

@ -2,10 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
"use strict";
const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react");
const { L10N } = require("../utils");
const DominatorTreeHeader = module.exports = createClass({
module.exports = createClass({
displayName: "DominatorTreeHeader",
propTypes: { },

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert, isSavedFrame } = require("devtools/shared/DevToolsUtils");
const { DOM: dom, createClass, createFactory, PropTypes } = require("devtools/client/shared/vendor/react");
const { L10N, formatNumber, formatPercent } = require("../utils");
@ -16,7 +18,7 @@ const Separator = createFactory(createClass({
}
}));
const DominatorTreeItem = module.exports = createClass({
module.exports = createClass({
displayName: "DominatorTreeItem",
propTypes: {

View File

@ -2,8 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const { assert, safeErrorString } = require("devtools/shared/DevToolsUtils");
const { assert } = require("devtools/shared/DevToolsUtils");
const { createParentMap } = require("devtools/shared/heapsnapshot/CensusUtils");
const Tree = createFactory(require("devtools/client/shared/components/tree"));
const DominatorTreeItem = createFactory(require("./dominator-tree-item"));
@ -21,16 +23,16 @@ const DOMINATOR_TREE_AUTO_EXPAND_DEPTH = 3;
const DominatorTreeSubtreeFetching = createFactory(createClass({
displayName: "DominatorTreeSubtreeFetching",
shouldComponentUpdate(nextProps, nextState) {
return this.props.depth !== nextProps.depth
|| this.props.focused !== nextProps.focused;
},
propTypes: {
depth: PropTypes.number.isRequired,
focused: PropTypes.bool.isRequired,
},
shouldComponentUpdate(nextProps, nextState) {
return this.props.depth !== nextProps.depth
|| this.props.focused !== nextProps.focused;
},
render() {
let {
depth,
@ -103,7 +105,7 @@ const DominatorTreeSiblingLink = createFactory(createClass({
/**
* The actual dominator tree rendered as an expandable and collapsible tree.
*/
const DominatorTree = module.exports = createClass({
module.exports = createClass({
displayName: "DominatorTree",
propTypes: {

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const { assert, safeErrorString } = require("devtools/shared/DevToolsUtils");
const Census = createFactory(require("./census"));
@ -178,7 +180,7 @@ function getError(snapshot, diffing, individuals) {
* state of only a button to take a snapshot, loading states, the census view
* tree, the dominator tree, etc.
*/
const Heap = module.exports = createClass({
module.exports = createClass({
displayName: "Heap",
propTypes: {
@ -202,68 +204,6 @@ const Heap = module.exports = createClass({
sizes: PropTypes.object.isRequired,
},
render() {
let {
snapshot,
diffing,
onSnapshotClick,
onLoadMoreSiblings,
onViewSourceInDebugger,
onViewIndividuals,
individuals,
view,
} = this.props;
if (!diffing && !snapshot && !individuals) {
return this._renderInitial(onSnapshotClick);
}
const state = getState(view, snapshot, diffing, individuals);
const statusText = getStateStatusText(state, diffing);
if (shouldDisplayStatus(state, view, snapshot)) {
return this._renderStatus(state, statusText, diffing);
}
const error = getError(snapshot, diffing, individuals);
if (error) {
return this._renderError(state, statusText, error);
}
if (view.state === viewState.CENSUS || view.state === viewState.DIFFING) {
const census = view.state === viewState.CENSUS
? snapshot.census
: diffing.census;
if (!census) {
return this._renderStatus(state, statusText, diffing);
}
return this._renderCensus(state, census, diffing, onViewSourceInDebugger,
onViewIndividuals);
}
if (view.state === viewState.TREE_MAP) {
return this._renderTreeMap(state, snapshot.treeMap);
}
if (view.state === viewState.INDIVIDUALS) {
assert(individuals.state === individualsState.FETCHED,
"Should have fetched the individuals -- other states are rendered as statuses");
return this._renderIndividuals(state, individuals,
individuals.dominatorTree,
onViewSourceInDebugger);
}
assert(view.state === viewState.DOMINATOR_TREE,
"If we aren't in progress, looking at a census, or diffing, then we " +
"must be looking at a dominator tree");
assert(!diffing, "Should not have diffing");
assert(snapshot.dominatorTree, "Should have a dominator tree");
return this._renderDominatorTree(state, onViewSourceInDebugger, snapshot.dominatorTree,
onLoadMoreSiblings);
},
/**
* Render the heap view's container panel with the given contents inside of
* it.
@ -325,9 +265,10 @@ const Heap = module.exports = createClass({
assert(census.report, "Should not render census that does not have a report");
if (!census.report.children) {
const msg = diffing ? L10N.getStr("heapview.no-difference")
: census.filter ? L10N.getStr("heapview.none-match")
const censusFilterMsg = census.filter ? L10N.getStr("heapview.none-match")
: L10N.getStr("heapview.empty");
const msg = diffing ? L10N.getStr("heapview.no-difference")
: censusFilterMsg;
return this._renderHeapView(state, dom.div({ className: "empty" }, msg));
}
@ -452,4 +393,67 @@ const Heap = module.exports = createClass({
})
);
},
render() {
let {
snapshot,
diffing,
onSnapshotClick,
onLoadMoreSiblings,
onViewSourceInDebugger,
onViewIndividuals,
individuals,
view,
} = this.props;
if (!diffing && !snapshot && !individuals) {
return this._renderInitial(onSnapshotClick);
}
const state = getState(view, snapshot, diffing, individuals);
const statusText = getStateStatusText(state, diffing);
if (shouldDisplayStatus(state, view, snapshot)) {
return this._renderStatus(state, statusText, diffing);
}
const error = getError(snapshot, diffing, individuals);
if (error) {
return this._renderError(state, statusText, error);
}
if (view.state === viewState.CENSUS || view.state === viewState.DIFFING) {
const census = view.state === viewState.CENSUS
? snapshot.census
: diffing.census;
if (!census) {
return this._renderStatus(state, statusText, diffing);
}
return this._renderCensus(state, census, diffing, onViewSourceInDebugger,
onViewIndividuals);
}
if (view.state === viewState.TREE_MAP) {
return this._renderTreeMap(state, snapshot.treeMap);
}
if (view.state === viewState.INDIVIDUALS) {
assert(individuals.state === individualsState.FETCHED,
"Should have fetched the individuals -- " +
"other states are rendered as statuses");
return this._renderIndividuals(state, individuals,
individuals.dominatorTree,
onViewSourceInDebugger);
}
assert(view.state === viewState.DOMINATOR_TREE,
"If we aren't in progress, looking at a census, or diffing, then we " +
"must be looking at a dominator tree");
assert(!diffing, "Should not have diffing");
assert(snapshot.dominatorTree, "Should have a dominator tree");
return this._renderDominatorTree(state, onViewSourceInDebugger,
snapshot.dominatorTree,
onLoadMoreSiblings);
},
});

View File

@ -2,10 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
"use strict";
const { DOM: dom, createClass } = require("devtools/client/shared/vendor/react");
const { L10N } = require("../utils");
const IndividualsHeader = module.exports = createClass({
module.exports = createClass({
displayName: "IndividualsHeader",
propTypes: { },

View File

@ -2,19 +2,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { DOM: dom, createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const { assert } = require("devtools/shared/DevToolsUtils");
const { createParentMap } = require("devtools/shared/heapsnapshot/CensusUtils");
"use strict";
const { createClass, PropTypes, createFactory } = require("devtools/client/shared/vendor/react");
const Tree = createFactory(require("devtools/client/shared/components/tree"));
const DominatorTreeItem = createFactory(require("./dominator-tree-item"));
const { L10N } = require("../utils");
const { TREE_ROW_HEIGHT } = require("../constants");
const models = require("../models");
/**
* The list of individuals in a census group.
*/
const Individuals = module.exports = createClass({
module.exports = createClass({
displayName: "Individuals",
propTypes: {

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
/**
@ -9,7 +11,7 @@ const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/ven
* the children nodes as `itemComponent`, and a list of items to render
* as that component with a click handler.
*/
const List = module.exports = createClass({
module.exports = createClass({
displayName: "List",
propTypes: {

View File

@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {
@ -29,7 +30,8 @@ function stringifyLabel(label, id) {
if (isSavedFrame(piece)) {
const { short } = getSourceNames(piece.source);
sanitized[i] = `${piece.functionDisplayName} @ ${short}:${piece.line}:${piece.column}`;
sanitized[i] = `${piece.functionDisplayName} @ ` +
`${short}:${piece.line}:${piece.column}`;
} else if (piece === NO_STACK) {
sanitized[i] = L10N.getStr("tree-item.nostack");
} else if (piece === NO_FILENAME) {
@ -62,16 +64,16 @@ module.exports = createClass({
return { zoom: null };
},
shouldComponentUpdate(nextProps) {
return this.props.graph != nextProps.graph;
},
componentDidMount() {
if (this.props.graph) {
this._renderGraph(this.refs.container, this.props.graph);
}
},
shouldComponentUpdate(nextProps) {
return this.props.graph != nextProps.graph;
},
componentDidUpdate() {
if (this.props.graph) {
this._renderGraph(this.refs.container, this.props.graph);
@ -84,44 +86,6 @@ module.exports = createClass({
}
},
render() {
let contents;
if (this.props.graph) {
// Let the componentDidMount or componentDidUpdate method draw the graph
// with DagreD3. We just provide the container for the graph here.
contents = dom.div({
ref: "container",
style: {
flex: 1,
height: "100%",
width: "100%",
}
});
} else {
contents = dom.div(
{
id: "shortest-paths-select-node-msg"
},
L10N.getStr("shortest-paths.select-node")
);
}
return dom.div(
{
id: "shortest-paths",
className: "vbox",
},
dom.label(
{
id: "shortest-paths-header",
className: "header",
},
L10N.getStr("shortest-paths.header")
),
contents
);
},
_renderGraph(container, { nodes, edges }) {
if (!container.firstChild) {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
@ -181,4 +145,42 @@ module.exports = createClass({
const layout = dagreD3.layout();
renderer.layout(layout).run(graph, target);
},
render() {
let contents;
if (this.props.graph) {
// Let the componentDidMount or componentDidUpdate method draw the graph
// with DagreD3. We just provide the container for the graph here.
contents = dom.div({
ref: "container",
style: {
flex: 1,
height: "100%",
width: "100%",
}
});
} else {
contents = dom.div(
{
id: "shortest-paths-select-node-msg"
},
L10N.getStr("shortest-paths.select-node")
);
}
return dom.div(
{
id: "shortest-paths",
className: "vbox",
},
dom.label(
{
id: "shortest-paths-header",
className: "header",
},
L10N.getStr("shortest-paths.header")
),
contents
);
},
});

View File

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const { assert } = require("devtools/shared/DevToolsUtils");
"use strict";
const { DOM: dom, createClass, PropTypes } = require("devtools/client/shared/vendor/react");
const {
L10N,
@ -12,15 +13,10 @@ const {
snapshotIsDiffable,
getSavedCensus
} = require("../utils");
const {
snapshotState: states,
diffingState,
censusState,
treeMapState
} = require("../constants");
const { diffingState } = require("../constants");
const { snapshot: snapshotModel } = require("../models");
const SnapshotListItem = module.exports = createClass({
module.exports = createClass({
displayName: "SnapshotListItem",
propTypes: {
@ -32,7 +28,7 @@ const SnapshotListItem = module.exports = createClass({
},
render() {
let { index, item: snapshot, onClick, onSave, onDelete, diffing } = this.props;
let { item: snapshot, onClick, onSave, onDelete, diffing } = this.props;
let className = `snapshot-list-item ${snapshot.selected ? " selected" : ""}`;
let statusText = getStatusText(snapshot.state);
let wantThrobber = !!statusText;
@ -75,7 +71,8 @@ const SnapshotListItem = module.exports = createClass({
// If there is census data, fill in the total bytes.
if (census) {
let { bytes } = getSnapshotTotals(census);
let formatBytes = L10N.getFormatStr("aggregate.mb", L10N.numberWithDecimals(bytes / 1000000, 2));
let formatBytes = L10N.getFormatStr("aggregate.mb",
L10N.numberWithDecimals(bytes / 1000000, 2));
details = dom.span({ className: "snapshot-totals" },
dom.span({ className: "total-bytes" }, formatBytes)
@ -99,7 +96,9 @@ const SnapshotListItem = module.exports = createClass({
return (
dom.li({ className, onClick },
dom.span({ className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}` },
dom.span({
className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}`
},
checkbox,
title,
deleteButton

View File

@ -260,7 +260,8 @@ module.exports = createClass({
dom.button(
{
id: "diff-snapshots",
className: "devtools-button devtools-monospace" + (!!diffing ? " checked" : ""),
className: "devtools-button devtools-monospace" +
(diffing ? " checked" : ""),
disabled: snapshots.length < 2,
onClick: onToggleDiffing,
title: L10N.getStr("diff-snapshots.tooltip"),

View File

@ -9,12 +9,12 @@ const { treeMapModel } = require("../models");
const startVisualization = require("./tree-map/start");
module.exports = createClass({
displayName: "TreeMap",
propTypes: {
treeMap: treeMapModel
},
displayName: "TreeMap",
getInitialState() {
return {};
},

View File

@ -238,7 +238,6 @@ function setScrollHandlers(container, dragZoom, emitChanged, update) {
let scrollDelta = getScrollDelta(event, window);
let prevZoom = dragZoom.zoom;
dragZoom.zoom = Math.max(0, dragZoom.zoom - scrollDelta * ZOOM_SPEED);
let deltaZoom = dragZoom.zoom - prevZoom;
// Calculate the updated width and height
let prevZoomedWidth = container.offsetWidth * (1 + prevZoom);

View File

@ -122,7 +122,10 @@ actions.RESIZE_SHORTEST_PATHS = "resize-shortest-paths";
const COUNT = Object.freeze({ by: "count", count: true, bytes: true });
const INTERNAL_TYPE = Object.freeze({ by: "internalType", then: COUNT });
const ALLOCATION_STACK = Object.freeze({ by: "allocationStack", then: COUNT, noStack: COUNT });
const ALLOCATION_STACK = Object.freeze({
by: "allocationStack", then: COUNT,
noStack: COUNT
});
const OBJECT_CLASS = Object.freeze({ by: "objectClass", then: COUNT, other: COUNT });
const COARSE_TYPE = Object.freeze({
by: "coarseType",

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* The `DominatorTreeLazyChildren` is a placeholder that represents a future
* subtree in an existing `DominatorTreeNode` tree that is currently being

View File

@ -2,9 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* exported initialize, destroy */
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const { utils: Cu } = Components;
const BrowserLoaderModule = {};
Cu.import("resource://devtools/client/shared/browser-loader.js", BrowserLoaderModule);
const { require } = BrowserLoaderModule.BrowserLoader({
@ -20,19 +22,21 @@ const Store = require("devtools/client/memory/store");
const { assert } = require("devtools/shared/DevToolsUtils");
/**
* The current target, toolbox, MemoryFront, and HeapAnalysesClient, set by this tool's host.
* The current target, toolbox, MemoryFront, and HeapAnalysesClient,
* set by this tool's host.
*/
var gToolbox, gTarget, gFront, gHeapAnalysesClient;
var gToolbox, gFront, gHeapAnalysesClient;
/**
* Variables set by `initialize()`
*/
var gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted, telemetry;
var gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted;
var initialize = Task.async(function* () {
gRoot = document.querySelector("#app");
gStore = Store();
gApp = createElement(App, { toolbox: gToolbox, front: gFront, heapWorker: gHeapAnalysesClient });
gApp = createElement(App,
{ toolbox: gToolbox, front: gFront, heapWorker: gHeapAnalysesClient });
gProvider = createElement(Provider, { store: gStore }, gApp);
ReactDOM.render(gProvider, gRoot);
unsubscribe = gStore.subscribe(onStateChange);
@ -44,7 +48,7 @@ var destroy = Task.async(function* () {
unsubscribe();
gStore, gRoot, gApp, gProvider, unsubscribe, isHighlighted;
gStore = gRoot = gApp = gProvider = unsubscribe = isHighlighted = null;
});
/**

View File

@ -2,6 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global treeMapState, censusState */
/* eslint no-shadow: ["error", { "allow": ["app"] }] */
"use strict";
const { assert } = require("devtools/shared/DevToolsUtils");
const { MemoryFront } = require("devtools/shared/fronts/memory");
const HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient");
@ -39,7 +44,9 @@ function catchAndIgnore(fn) {
return function (...args) {
try {
fn(...args);
} catch (err) { }
} catch (err) {
// continue regardless of error
}
return null;
};
@ -103,6 +110,7 @@ const treeMapModel = exports.treeMapModel = PropTypes.shape({
assert(!treeMap.report, "Should not have a report");
assert(!treeMap.error, "Should not have an error");
break;
case treeMapState.SAVED:
assert(treeMap.report, "Should have a report");
assert(!treeMap.error, "Should not have an error");
@ -443,7 +451,7 @@ const individualsModel = exports.individuals = PropTypes.shape({
}),
});
let appModel = exports.app = {
exports.app = {
// {MemoryFront} Used to communicate with platform
front: PropTypes.instanceOf(MemoryFront),
@ -494,7 +502,7 @@ let appModel = exports.app = {
break;
default:
assert(false, `Unexpected type of view: ${view.state}`);
assert(false, `Unexpected type of view: ${app.view.state}`);
}
})(app);
@ -512,7 +520,7 @@ let appModel = exports.app = {
break;
default:
assert(false, `Unexpected type of view: ${view.state}`);
assert(false, `Unexpected type of view: ${app.view.state}`);
}
})(app);
},

View File

@ -4,12 +4,10 @@
"use strict";
const { Cc, Ci, Cu, Cr } = require("chrome");
const { Task } = require("devtools/shared/task");
const EventEmitter = require("devtools/shared/event-emitter");
const { MemoryFront } = require("devtools/shared/fronts/memory");
const HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClient");
const promise = require("promise");
function MemoryPanel(iframeWindow, toolbox) {
this.panelWin = iframeWindow;

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { assert } = require("devtools/shared/DevToolsUtils");
const { actions } = require("../constants");

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { ERROR_TYPE: TASK_ERROR_TYPE } = require("devtools/client/shared/redux/middleware/task");
/**

View File

@ -8,7 +8,7 @@ const { actions } = require("../constants");
module.exports = function (filterString = null, action) {
if (action.type === actions.SET_FILTER_STRING) {
return action.filter || null;
} else {
return filterString;
}
return filterString;
};

View File

@ -240,7 +240,8 @@ handlers[actions.COMPUTE_DOMINATOR_TREE_START] = function (snapshots, { id }) {
});
};
handlers[actions.COMPUTE_DOMINATOR_TREE_END] = function (snapshots, { id, dominatorTreeId }) {
handlers[actions.COMPUTE_DOMINATOR_TREE_END] =
function (snapshots, { id, dominatorTreeId }) {
return snapshots.map(snapshot => {
if (snapshot.id !== id) {
return snapshot;
@ -267,7 +268,8 @@ handlers[actions.FETCH_DOMINATOR_TREE_START] = function (snapshots, { id, displa
assert(snapshot.dominatorTree, "Should have a dominator tree model");
assert(snapshot.dominatorTree.state !== dominatorTreeState.COMPUTING &&
snapshot.dominatorTree.state !== dominatorTreeState.ERROR,
`Should have already computed the dominator tree, found state = ${snapshot.dominatorTree.state}`);
"Should have already computed the dominator tree, found state = " +
snapshot.dominatorTree.state);
const dominatorTree = immutableUpdate(snapshot.dominatorTree, {
state: dominatorTreeState.FETCHING,

View File

@ -2,10 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { combineReducers } = require("../shared/vendor/redux");
const createStore = require("../shared/redux/create-store");
const reducers = require("./reducers");
const { viewState } = require("./constants");
const flags = require("devtools/shared/flags");
module.exports = function () {

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// This module exports methods to record telemetry data for memory tool usage.
//
// NB: Ensure that *every* exported function is wrapped in `makeInfallible` so
@ -10,7 +12,7 @@
const { telemetry } = require("Services");
const { makeInfallible, immutableUpdate } = require("devtools/shared/DevToolsUtils");
const { labelDisplays, treeMapDisplays, censusDisplays } = require("./constants");
const { labelDisplays, censusDisplays } = require("./constants");
exports.countTakeSnapshot = makeInfallible(function () {
const histogram = telemetry.getHistogramById("DEVTOOLS_MEMORY_TAKE_SNAPSHOT_COUNT");
@ -80,7 +82,8 @@ exports.countDominatorTree = makeInfallible(function ({ display }) {
let histogram = telemetry.getHistogramById("DEVTOOLS_MEMORY_DOMINATOR_TREE_COUNT");
histogram.add(1);
histogram = telemetry.getKeyedHistogramById("DEVTOOLS_MEMORY_BREAKDOWN_DOMINATOR_TREE_COUNT");
histogram =
telemetry.getKeyedHistogramById("DEVTOOLS_MEMORY_BREAKDOWN_DOMINATOR_TREE_COUNT");
if (display === labelDisplays.coarseType) {
histogram.add(COARSE_TYPE);
} else if (display === labelDisplays.allocationStack) {

View File

@ -2,5 +2,16 @@
module.exports = {
// Extend from the shared list of defined globals for mochitests.
"extends": "../../../../.eslintrc.mochitests.js"
"extends": "../../../../.eslintrc.mochitests.js",
"globals": {
"addTab": true,
"censusState": true,
"refreshTab": true,
"removeTab": true,
"waitForTime": true,
"waitUntilState": true
},
"rules": {
"no-unused-vars": ["error", { "vars": "local", "args": "none" }],
}
};

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests taking and then clearing snapshots.
*/
@ -10,7 +12,7 @@
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const { gStore, document } = panel.panelWin;
const { getState, dispatch } = gStore;
const { getState } = gStore;
let snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 0, "Starts with no snapshots in store");

View File

@ -6,7 +6,6 @@
"use strict";
const {
snapshotState,
diffingState,
treeMapState
} = require("devtools/client/memory/constants");
@ -14,10 +13,8 @@ const {
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const { getState } = store;
const doc = panel.panelWin.document;
ok(!getState().diffing, "Not diffing by default.");

View File

@ -111,7 +111,9 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
// Find the most up-to-date version of the node whose children we just
// incrementally fetched.
const newDeepest = (function findNewDeepest(node = getState().snapshots[0].dominatorTree.root) {
const newDeepest = (function findNewDeepest(node = getState().snapshots[0]
.dominatorTree
.root) {
if (node.nodeId === deepest.nodeId) {
return node;
}

View File

@ -7,7 +7,6 @@
const {
dominatorTreeState,
snapshotState,
viewState,
censusState,
} = require("devtools/client/memory/constants");
@ -17,9 +16,8 @@ const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const { dispatch } = store;
const doc = panel.panelWin.document;
dispatch(changeView(viewState.CENSUS));
@ -49,7 +47,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
let nameElem = doc.querySelector(".heap-tree-item-field.heap-tree-item-name");
ok(nameElem, "Should get a tree item row with a name");
is(nameElem.textContent.trim(), "js::Shape", "the tree item should be the one we filtered for");
is(nameElem.textContent.trim(), "js::Shape",
"the tree item should be the one we filtered for");
is(filterInput.value, "js::Shape",
"and filter input contains the user value");

View File

@ -11,15 +11,13 @@ const {
viewState,
censusState,
} = require("devtools/client/memory/constants");
const { changeViewAndRefresh, changeView } = require("devtools/client/memory/actions/view");
const { changeView } = require("devtools/client/memory/actions/view");
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const { dispatch } = store;
const doc = panel.panelWin.document;
dispatch(changeView(viewState.CENSUS));

View File

@ -6,7 +6,6 @@
"use strict";
const {
snapshotState,
viewState,
censusState
} = require("devtools/client/memory/constants");

View File

@ -7,7 +7,6 @@
"use strict";
const {
snapshotState,
censusState,
viewState
} = require("devtools/client/memory/constants");

View File

@ -35,5 +35,6 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
"Should still not be recording allocagtions");
ok(doc.querySelector(".no-allocation-stacks"),
"Because we did not record allocations, the no-allocation-stack warning should be visible");
"Because we did not record allocations, " +
"the no-allocation-stack warning should be visible");
});

View File

@ -27,7 +27,9 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
EventUtils.synthesizeMouseAtCenter(recordingCheckbox, {}, panel.panelWin);
is(getState().allocations.recording, true);
const nameElems = [...doc.querySelectorAll(".heap-tree-item-field.heap-tree-item-name")];
const nameElems = [
...doc.querySelectorAll(".heap-tree-item-field.heap-tree-item-name")
];
for (let el of nameElems) {
dumpn(`Found ${el.textContent.trim()}`);

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* global ChromeUtils */
// Test that refreshing the page with devtools open does not leak the old
// windows from previous navigations.
//
@ -9,7 +11,6 @@
"use strict";
const HeapSnapshotFileUtils = require("devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
const { getLabelAndShallowSize } = require("devtools/shared/heapsnapshot/DominatorTreeNode");
const TEST_URL = "http://example.com/browser/devtools/client/memory/test/browser/doc_empty.html";
@ -50,14 +51,11 @@ const DESCRIPTION = {
};
this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const front = panel.panelWin.gFront;
const store = panel.panelWin.gStore;
const { getState, dispatch } = store;
const doc = panel.panelWin.document;
const startWindows = yield getWindowsInSnapshot(front);
dumpn("Initial windows found = " + startWindows.map(w => "0x" + w.toString(16)).join(", "));
dumpn("Initial windows found = " + startWindows.map(w => "0x" +
w.toString(16)).join(", "));
is(startWindows.length, 1);
yield refreshTab(tab);
@ -84,7 +82,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
const paths = snapshot.computeShortestPaths(dominatorTree.root, startWindows, 50);
for (let i = 0; i < startWindows.length; i++) {
dumpn("Shortest retaining paths for leaking Window 0x" + startWindows[i].toString(16) + " =========================");
dumpn("Shortest retaining paths for leaking Window 0x" +
startWindows[i].toString(16) + " =========================");
let j = 0;
for (let retainingPath of paths.get(startWindows[i])) {
if (retainingPath.find(part => part.predecessor === startWindows[i])) {
@ -92,7 +91,8 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
continue;
}
dumpn(" Path #" + (++j) + ": --------------------------------------------------------------------");
dumpn(" Path #" + (++j) +
": --------------------------------------------------------------------");
for (let part of retainingPath) {
const { label } = getLabelAndShallowSize(part.predecessor, snapshot, DESCRIPTION);
dumpn(" 0x" + part.predecessor.toString(16) +

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests taking snapshots and default states.
*/
@ -23,17 +25,20 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 1, "One snapshot was created in store");
is(snapshotEls.length, 1, "One snapshot was rendered");
ok(snapshotEls[0].classList.contains("selected"), "Only snapshot has `selected` class");
ok(snapshotEls[0].classList.contains("selected"),
"Only snapshot has `selected` class");
yield takeSnapshot(panel.panelWin);
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 2, "Two snapshots created in store");
is(snapshotEls.length, 2, "Two snapshots rendered");
ok(!snapshotEls[0].classList.contains("selected"), "First snapshot no longer has `selected` class");
ok(snapshotEls[1].classList.contains("selected"), "Second snapshot has `selected` class");
ok(!snapshotEls[0].classList.contains("selected"),
"First snapshot no longer has `selected` class");
ok(snapshotEls[1].classList.contains("selected"),
"Second snapshot has `selected` class");
yield waitUntilCensusState(gStore, s => s.census, [censusState.SAVED,
censusState.SAVED]);
yield waitUntilCensusState(gStore, s => s.census,
[censusState.SAVED, censusState.SAVED]);
ok(document.querySelector(".heap-tree-item-name"),
"Should have rendered some tree items");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* global ChromeUtils, HeapSnapshot */
// Test that we can save a heap snapshot and transfer it over the RDP in e10s
// where the child process is sandboxed and so we have to use
// HeapSnapshotFileActor to get the heap snapshot file.

View File

@ -78,8 +78,6 @@ this.test = makeMemoryTest(TEST_URL, function* ({ tab, panel }) {
info("Dragging correctly translates the div");
{
let initialX = dragZoom.translateX;
let initialY = dragZoom.translateY;
div.dispatchEvent(new MouseEvent("mousemove", {
clientX: 10,
clientY: 10,

View File

@ -2,8 +2,10 @@
<html>
<body>
<script>
"use strict";
window.big = (function makeBig(depth = 0) {
var big = Array(5);
let big = Array(5);
big.fill(undefined);
if (depth < 5) {
big = big.map(_ => makeBig(depth + 1));

View File

@ -2,13 +2,15 @@
<html>
<body>
<script>
var objects = window.objects = [];
"use strict";
var objects = window.objects = [];
var allocate = this.allocate = function allocate() {
for (var i = 0; i < 100; i++)
for (let i = 0; i < 100; i++) {
objects.push({});
setTimeout(allocate, 10);
}
setTimeout(allocate, 10);
};
allocate();
</script>

View File

@ -109,7 +109,8 @@ function takeSnapshot(window) {
let snapshotCount = gStore.getState().snapshots.length;
info("Taking snapshot...");
document.querySelector(".devtools-toolbar .take-snapshot").click();
return waitUntilState(gStore, () => gStore.getState().snapshots.length === snapshotCount + 1);
return waitUntilState(gStore,
() => gStore.getState().snapshots.length === snapshotCount + 1);
}
function clearSnapshots(window) {
@ -176,7 +177,6 @@ function waitUntilSnapshotSelected(store, snapshotIndex) {
state.snapshots[snapshotIndex].selected === true);
}
/**
* Wait until the state has censuses in a certain state.
*
@ -219,7 +219,7 @@ function createRAFMock() {
mock.nextFrame = function () {
let thisQueue = queuedFns;
queuedFns = [];
for (var i = 0; i < thisQueue.length; i++) {
for (let i = 0; i < thisQueue.length; i++) {
thisQueue[i]();
}
};

View File

@ -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" }],
}
};

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
@ -17,8 +18,9 @@ var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0;
SimpleTest.registerCleanupFunction(function () {
if (DevToolsUtils.assertionFailureCount !== EXPECTED_DTU_ASSERT_FAILURE_COUNT) {
ok(false, "Should have had the expected number of DevToolsUtils.assert() failures. Expected " +
EXPECTED_DTU_ASSERT_FAILURE_COUNT + ", got " + DevToolsUtils.assertionFailureCount);
ok(false, "Should have had the expected number of DevToolsUtils.assert() failures." +
"Expected " + EXPECTED_DTU_ASSERT_FAILURE_COUNT +
", got " + DevToolsUtils.assertionFailureCount);
}
});
@ -115,7 +117,9 @@ function makeTestDominatorTreeNode(opts, children) {
}, opts);
if (children && children.length) {
children.map(c => c.parentId = node.nodeId);
children.map(c => {
c.parentId = node.nodeId;
});
}
return node;

View File

@ -2,5 +2,11 @@
module.exports = {
// Extend from the shared list of defined globals for mochitests.
"extends": "../../../../.eslintrc.xpcshell.js"
"extends": "../../../../.eslintrc.xpcshell.js",
"rules": {
"no-unused-vars": ["error", {
"vars": "local",
"varsIgnorePattern": "^run_test$"
}]
}
};

View File

@ -26,7 +26,8 @@ var HeapAnalysesClient = require("devtools/shared/heapsnapshot/HeapAnalysesClien
var { addDebuggerToGlobal } = require("resource://gre/modules/jsdebugger.jsm");
var Store = require("devtools/client/memory/store");
var { L10N } = require("devtools/client/memory/utils");
var SYSTEM_PRINCIPAL = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
var SYSTEM_PRINCIPAL =
Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0;
@ -59,15 +60,18 @@ StubbedMemoryFront.prototype.detach = Task.async(function* () {
this.state = "detached";
});
StubbedMemoryFront.prototype.saveHeapSnapshot = expectState("attached", Task.async(function* () {
StubbedMemoryFront.prototype.saveHeapSnapshot = expectState("attached",
Task.async(function* () {
return ThreadSafeChromeUtils.saveHeapSnapshot({ runtime: true });
}), "saveHeapSnapshot");
StubbedMemoryFront.prototype.startRecordingAllocations = expectState("attached", Task.async(function* () {
StubbedMemoryFront.prototype.startRecordingAllocations = expectState("attached",
Task.async(function* () {
this.recordingAllocations = true;
}));
StubbedMemoryFront.prototype.stopRecordingAllocations = expectState("attached", Task.async(function* () {
StubbedMemoryFront.prototype.stopRecordingAllocations = expectState("attached",
Task.async(function* () {
this.recordingAllocations = false;
}));

View File

@ -1,10 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes snapshots with READ censuses
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");
let { snapshotState: states, actions } = require("devtools/client/memory/constants");
let { actions } = require("devtools/client/memory/constants");
const { treeMapState } = require("devtools/client/memory/constants");
function run_test() {

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots preserves snapshots with state != READ or ERROR
let { takeSnapshotAndCensus, clearSnapshots, takeSnapshot } = require("devtools/client/memory/actions/snapshot");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes snapshots with state ERROR
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes several snapshots
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");
@ -22,8 +24,7 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.treeMap,
[treeMapState.SAVED, treeMapState.SAVED,
treeMapState.SAVED]);
[treeMapState.SAVED, treeMapState.SAVED, treeMapState.SAVED]);
ok(true, "snapshots created with a saved census");
ok(true, "set first snapshot state to error");

View File

@ -1,10 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test clearSnapshots deletes several snapshots
let { takeSnapshotAndCensus, clearSnapshots } = require("devtools/client/memory/actions/snapshot");
let { snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants");
let { actions, treeMapState } = require("devtools/client/memory/constants");
function run_test() {
run_next_test();

View File

@ -10,7 +10,6 @@ const {
clearSnapshots
} = require("devtools/client/memory/actions/snapshot");
const {
snapshotState: states,
actions,
treeMapState
} = require("devtools/client/memory/constants");

View File

@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test exporting a snapshot to a user specified location on disk.
let { exportSnapshot } = require("devtools/client/memory/actions/io");
let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot");
let { snapshotState: states, actions, treeMapState } = require("devtools/client/memory/constants");
let { actions, treeMapState } = require("devtools/client/memory/constants");
function run_test() {
run_next_test();

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test setting the filter string.
let { setFilterString } = require("devtools/client/memory/actions/filter");

View File

@ -1,13 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that changing filter state properly refreshes the selected census.
let { snapshotState: states, viewState, censusState } = require("devtools/client/memory/constants");
let { viewState, censusState } = require("devtools/client/memory/constants");
let { setFilterStringAndRefresh } = require("devtools/client/memory/actions/filter");
let { takeSnapshotAndCensus, selectSnapshotAndRefresh } = require("devtools/client/memory/actions/snapshot");
let { setCensusDisplay } = require("devtools/client/memory/actions/census-display");
let { changeView } = require("devtools/client/memory/actions/view");
function run_test() {
@ -30,24 +30,18 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
ok(true, "saved 3 snapshots and took a census of each of them");
dispatch(setFilterStringAndRefresh("str", heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVING]);
[censusState.SAVED, censusState.SAVED, censusState.SAVING]);
ok(true, "setting filter string should recompute the selected snapshot's census");
equal(getState().filter, "str", "now inverted");
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[0].census.filter, null);
equal(getState().snapshots[1].census.filter, null);
@ -55,15 +49,11 @@ add_task(function* () {
dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVING,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVING, censusState.SAVED]);
ok(true, "selecting non-inverted census should trigger a recompute");
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[0].census.filter, null);
equal(getState().snapshots[1].census.filter, "str");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that changing filter state in the middle of taking a snapshot results in
// the properly fitered census.

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
@ -61,13 +62,19 @@ add_task(function* () {
let unsubscribe = subscribe(expectStates);
dispatch(importSnapshotAndCensus(heapWorker, destPath));
yield waitUntilState(store, () => { return snapshotI === snapshotStates.length &&
censusI === censusStates.length; });
yield waitUntilState(store, () => {
return snapshotI === snapshotStates.length &&
censusI === censusStates.length;
});
unsubscribe();
equal(snapshotI, snapshotStates.length, "importSnapshotAndCensus() produces the correct sequence of states in a snapshot");
equal(getState().snapshots[1].state, states.READ, "imported snapshot is in READ state");
equal(censusI, censusStates.length, "importSnapshotAndCensus() produces the correct sequence of states in a census");
equal(getState().snapshots[1].treeMap.state, treeMapState.SAVED, "imported snapshot is in READ state");
equal(snapshotI, snapshotStates.length,
"importSnapshotAndCensus() produces the correct sequence of states in a snapshot");
equal(getState().snapshots[1].state, states.READ,
"imported snapshot is in READ state");
equal(censusI, censusStates.length,
"importSnapshotAndCensus() produces the correct sequence of states in a census");
equal(getState().snapshots[1].treeMap.state, treeMapState.SAVED,
"imported snapshot is in READ state");
ok(getState().snapshots[1].selected, "imported snapshot is selected");
// Check snapshot data
@ -82,7 +89,8 @@ add_task(function* () {
let census1 = stripUnique(JSON.parse(JSON.stringify(snapshot1.treeMap.report)));
let census2 = stripUnique(JSON.parse(JSON.stringify(snapshot2.treeMap.report)));
equal(JSON.stringify(census1), JSON.stringify(census2), "Imported snapshot has correct census");
equal(JSON.stringify(census1), JSON.stringify(census2),
"Imported snapshot has correct census");
function stripUnique(obj) {
let children = obj.children || [];

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the reducer responding to the action `selectSnapshot(snapshot)`
*/
@ -21,7 +23,8 @@ add_task(function* () {
store.dispatch(actions.takeSnapshot(front));
}
yield waitUntilState(store, ({ snapshots }) => snapshots.length === 5 && snapshots.every(isDone));
yield waitUntilState(store,
({ snapshots }) => snapshots.length === 5 && snapshots.every(isDone));
for (let i = 0; i < 5; i++) {
do_print(`Selecting snapshot[${i}]`);
@ -30,8 +33,11 @@ add_task(function* () {
let { snapshots } = store.getState();
ok(snapshots[i].selected, `snapshot[${i}] selected`);
equal(snapshots.filter(s => !s.selected).length, 4, "All other snapshots are unselected");
equal(snapshots.filter(s => !s.selected).length, 4,
"All other snapshots are unselected");
}
});
function isDone(s) { return s.state === states.SAVED; }
function isDone(s) {
return s.state === states.SAVED;
}

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
@ -9,7 +10,7 @@
* `setCensusDisplayAndRefresh`.
*/
let { censusDisplays, snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants");
let { censusDisplays, censusState, viewState } = require("devtools/client/memory/constants");
let { setCensusDisplayAndRefresh } = require("devtools/client/memory/actions/census-display");
let { takeSnapshotAndCensus, selectSnapshotAndRefresh } = require("devtools/client/memory/actions/snapshot");
const { changeView } = require("devtools/client/memory/actions/view");
@ -63,51 +64,49 @@ add_task(function* () {
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[1].census.display, censusDisplays.coarseType,
"Changing display while saving a snapshot results in a census using the new display");
"Changing display while saving a snapshot results " +
"in a census using the new display");
// Updates when changing display during `SAVING_CENSUS`
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVING]);
[censusState.SAVED, censusState.SAVED, censusState.SAVING]);
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[2].census.display, censusDisplays.allocationStack,
"Display can be changed while saving census, stores updated display in snapshot");
// Updates census on currently selected snapshot when changing display
ok(getState().snapshots[2].selected, "Third snapshot currently selected");
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.coarseType));
yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVING);
yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVED);
yield waitUntilState(store,
state => state.snapshots[2].census.state === censusState.SAVING);
yield waitUntilState(store,
state => state.snapshots[2].census.state === censusState.SAVED);
equal(getState().snapshots[2].census.display, censusDisplays.coarseType,
"Snapshot census updated when changing displays after already generating one census");
"Snapshot census updated when changing displays " +
"after already generating one census");
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.allocationStack));
yield waitUntilState(store, state => state.snapshots[2].census.state === censusState.SAVED);
yield waitUntilState(store,
state => state.snapshots[2].census.state === censusState.SAVED);
equal(getState().snapshots[2].census.display, censusDisplays.allocationStack,
"Snapshot census updated when changing displays after already generating one census");
"Snapshot census updated when changing displays " +
"after already generating one census");
// Does not update unselected censuses.
ok(!getState().snapshots[1].selected, "Second snapshot selected currently");
equal(getState().snapshots[1].census.display, censusDisplays.coarseType,
"Second snapshot using `coarseType` display still and not yet updated to correct display");
"Second snapshot using `coarseType` display still and " +
"not yet updated to correct display");
// Updates to current display when switching to stale snapshot.
dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id));
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVING,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVING, censusState.SAVED]);
yield waitUntilCensusState(store, snapshot => snapshot.census,
[censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
ok(getState().snapshots[1].selected, "Second snapshot selected currently");
equal(getState().snapshots[1].census.display, censusDisplays.allocationStack,

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
@ -7,7 +8,7 @@
* displays.
*/
let { snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants");
let { censusState, viewState } = require("devtools/client/memory/constants");
let { setCensusDisplayAndRefresh } = require("devtools/client/memory/actions/census-display");
let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot");
let { changeView } = require("devtools/client/memory/actions/view");
@ -48,6 +49,7 @@ add_task(function* () {
ok(getState().snapshots[0].census.report.children.every(c => !c.count),
"Census used CUSTOM display without counts");
// Ensure we do have `bytes` in the results
ok(getState().snapshots[0].census.report.children.every(c => typeof c.bytes === "number"),
ok(getState().snapshots[0].census.report.children
.every(c => typeof c.bytes === "number"),
"Census used CUSTOM display with bytes");
});

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
@ -8,7 +9,7 @@
* action for that.
*/
let { censusDisplays, snapshotState: states, censusState, viewState } = require("devtools/client/memory/constants");
let { censusDisplays, censusState, viewState } = require("devtools/client/memory/constants");
let { setCensusDisplay } = require("devtools/client/memory/actions/census-display");
let { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot");
const { changeView } = require("devtools/client/memory/actions/view");

View File

@ -1,15 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the async reducer responding to the action `takeCensus(heapWorker, snapshot)`
*/
var { snapshotState: states, censusDisplays, censusState, censusState, viewState } = require("devtools/client/memory/constants");
var { snapshotState: states, censusDisplays, censusState, viewState } = require("devtools/client/memory/constants");
var actions = require("devtools/client/memory/actions/snapshot");
var { changeView } = require("devtools/client/memory/actions/view");
function run_test() {
run_next_test();
}
@ -55,5 +56,4 @@ add_task(function* () {
ok(snapshot.census.report.children.length, "Census is in tree node form");
equal(snapshot.census.display, censusDisplays.coarseType,
"Snapshot stored correct display used for the census");
});

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the task creator `takeSnapshotAndCensus()` for the whole flow of
* taking a snapshot, and its sub-actions.
@ -43,15 +45,17 @@ add_task(function* () {
}
};
let unsubscribe = store.subscribe(expectStates);
store.dispatch(actions.takeSnapshotAndCensus(front, heapWorker));
yield waitUntilState(store, () => { return snapshotI === snapshotStates.length &&
censusI === censusStates.length; });
yield waitUntilState(store, () => {
return snapshotI === snapshotStates.length &&
censusI === censusStates.length;
});
unsubscribe();
ok(true, "takeSnapshotAndCensus() produces the correct sequence of states in a snapshot");
ok(true,
"takeSnapshotAndCensus() produces the correct sequence of states in a snapshot");
let snapshot = store.getState().snapshots[0];
ok(snapshot.treeMap, "snapshot has tree map census data");
ok(snapshot.selected, "snapshot is selected");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests the async reducer responding to the action `takeSnapshot(front)`
*/
@ -31,8 +33,7 @@ add_task(function* () {
ok(foundPendingState, "Got state change for pending heap snapshot request");
ok(!lastSnapshot.path, "Snapshot does not yet have a path");
ok(!lastSnapshot.census, "Has no census data when loading");
}
else if (lastSnapshot.state === states.SAVED) {
} else if (lastSnapshot.state === states.SAVED) {
foundDoneState = true;
ok(foundDoneState, "Got state change for completed heap snapshot request");
ok(foundPendingState, "SAVED state occurs after SAVING state");

View File

@ -1,12 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that changing displays with different inverted state properly
// refreshes the selected census.
const {
censusDisplays,
snapshotState: states,
censusState,
viewState
} = require("devtools/client/memory/constants");
@ -40,38 +41,34 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
yield waitUntilCensusState(store, s => s.census,
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
ok(true, "saved 3 snapshots and took a census of each of them");
// Select an inverted display.
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.invertedAllocationStack));
dispatch(setCensusDisplayAndRefresh(heapWorker,
censusDisplays.invertedAllocationStack));
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED,
censusState.SAVED,
censusState.SAVING]);
yield waitUntilCensusState(store, s => s.census,
[censusState.SAVED, censusState.SAVED, censusState.SAVING]);
ok(true, "toggling inverted should recompute the selected snapshot's census");
equal(getState().censusDisplay.inverted, true, "now inverted");
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
yield waitUntilCensusState(store, s => s.census,
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[0].census.display.inverted, false);
equal(getState().snapshots[1].census.display.inverted, false);
equal(getState().snapshots[2].census.display.inverted, true);
dispatch(selectSnapshotAndRefresh(heapWorker, getState().snapshots[1].id));
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED,
censusState.SAVING,
censusState.SAVED]);
yield waitUntilCensusState(store, s => s.census,
[censusState.SAVED, censusState.SAVING, censusState.SAVED]);
ok(true, "selecting non-inverted census should trigger a recompute");
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
yield waitUntilCensusState(store, s => s.census,
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
equal(getState().snapshots[0].census.display.inverted, false);
equal(getState().snapshots[1].census.display.inverted, true);

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that changing inverted state in the middle of taking a snapshot results
@ -33,7 +34,8 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilSnapshotState(store, [states.SAVING]);
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.invertedAllocationStack));
dispatch(setCensusDisplayAndRefresh(heapWorker,
censusDisplays.invertedAllocationStack));
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED]);
@ -47,7 +49,8 @@ add_task(function* () {
ok(true, "toggling inverted retriggers census");
ok(!getState().censusDisplay.inverted, "no longer inverted");
dispatch(setCensusDisplayAndRefresh(heapWorker, censusDisplays.invertedAllocationStack));
dispatch(setCensusDisplayAndRefresh(heapWorker,
censusDisplays.invertedAllocationStack));
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED]);
ok(getState().censusDisplay.inverted, "inverted again");
ok(getState().snapshots[0].census.display.inverted,

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test toggling the top level inversion state of the tree.

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test toggling of diffing.
const { toggleDiffing } = require("devtools/client/memory/actions/diffing");

View File

@ -1,9 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that toggling diffing unselects all snapshots.
const { snapshotState, censusState, viewState } = require("devtools/client/memory/constants");
const { censusState, viewState } = require("devtools/client/memory/constants");
const { toggleDiffing } = require("devtools/client/memory/actions/diffing");
const { takeSnapshotAndCensus } = require("devtools/client/memory/actions/snapshot");
const { changeView } = require("devtools/client/memory/actions/view");
@ -26,9 +28,8 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
dispatch(takeSnapshotAndCensus(front, heapWorker));
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED,
censusState.SAVED,
censusState.SAVED]);
yield waitUntilCensusState(store, s => s.census,
[censusState.SAVED, censusState.SAVED, censusState.SAVED]);
ok(getState().snapshots.some(s => s.selected),
"One of the new snapshots is selected");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test selecting snapshots for diffing.
const { diffingState, snapshotState, viewState } = require("devtools/client/memory/constants");
@ -34,9 +36,8 @@ add_task(function* () {
dispatch(takeSnapshot(front, heapWorker));
dispatch(takeSnapshot(front, heapWorker));
yield waitUntilSnapshotState(store, [snapshotState.SAVED,
snapshotState.SAVED,
snapshotState.SAVED]);
yield waitUntilSnapshotState(store,
[snapshotState.SAVED, snapshotState.SAVED, snapshotState.SAVED]);
dispatch(takeSnapshot(front));
// Start diffing.

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we compute census diffs.
const {
@ -38,9 +40,8 @@ add_task(function* () {
dispatch(readSnapshot(heapWorker, s1));
dispatch(readSnapshot(heapWorker, s2));
dispatch(readSnapshot(heapWorker, s3));
yield waitUntilSnapshotState(store, [snapshotState.READ,
snapshotState.READ,
snapshotState.READ]);
yield waitUntilSnapshotState(store,
[snapshotState.READ, snapshotState.READ, snapshotState.READ]);
dispatch(toggleDiffing());
dispatch(selectSnapshotForDiffingAndRefresh(heapWorker,

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we recompute census diffs at the appropriate times.
const {
@ -50,9 +52,8 @@ add_task(function* () {
dispatch(readSnapshot(heapWorker, s1));
dispatch(readSnapshot(heapWorker, s2));
dispatch(readSnapshot(heapWorker, s3));
yield waitUntilSnapshotState(store, [snapshotState.READ,
snapshotState.READ,
snapshotState.READ]);
yield waitUntilSnapshotState(store,
[snapshotState.READ, snapshotState.READ, snapshotState.READ]);
yield dispatch(toggleDiffing());
dispatch(selectSnapshotForDiffingAndRefresh(heapWorker,

View File

@ -1,10 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we can compute and fetch the dominator tree for a snapshot.
let {
snapshotState: states,
dominatorTreeState,
treeMapState,
} = require("devtools/client/memory/constants");

View File

@ -1,11 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that selecting the dominator tree view automatically kicks off fetching
// and computing dominator trees.
const {
snapshotState: states,
dominatorTreeState,
viewState,
treeMapState,

View File

@ -1,11 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that selecting the dominator tree view and then taking a snapshot
// properly kicks off fetching and computing dominator trees.
const {
snapshotState: states,
dominatorTreeState,
viewState,
} = require("devtools/client/memory/constants");

View File

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that selecting the dominator tree view while in the middle of taking a
// snapshot properly kicks off fetching and computing dominator trees.
@ -25,10 +27,9 @@ add_task(function* () {
let heapWorker = new HeapAnalysesClient();
yield front.attach();
for (let intermediateSnapshotState of [states.SAVING,
states.READING,
states.READ]) {
dumpn(`Testing switching to the DOMINATOR_TREE view in the middle of the ${intermediateSnapshotState} snapshot state`);
for (let intermediateSnapshotState of [states.SAVING, states.READING, states.READ]) {
dumpn("Testing switching to the DOMINATOR_TREE view in the middle of the " +
`${intermediateSnapshotState} snapshot state`);
let store = Store();
let { getState, dispatch } = store;

View File

@ -1,11 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that changing the currently selected snapshot to a snapshot that does
// not have a dominator tree will automatically compute and fetch one for it.
let {
snapshotState: states,
dominatorTreeState,
viewState,
treeMapState,
@ -30,8 +31,8 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, s => s.treeMap, [treeMapState.SAVED,
treeMapState.SAVED]);
yield waitUntilCensusState(store, s => s.treeMap,
[treeMapState.SAVED, treeMapState.SAVED]);
ok(getState().snapshots[1].selected, "The second snapshot is selected");

View File

@ -1,16 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we can incrementally fetch a subtree of a dominator tree.
const {
snapshotState: states,
dominatorTreeState,
viewState,
} = require("devtools/client/memory/constants");
const {
takeSnapshotAndCensus,
selectSnapshotAndRefresh,
fetchImmediatelyDominated,
} = require("devtools/client/memory/actions/snapshot");
const DominatorTreeLazyChildren
@ -68,7 +68,8 @@ add_task(function* () {
ok(oldNode !== oldRoot, "But the node should not be the root");
const lazyChildren = new DominatorTreeLazyChildren(oldNode.nodeId, 0);
dispatch(fetchImmediatelyDominated(heapWorker, getState().snapshots[0].id, lazyChildren));
dispatch(fetchImmediatelyDominated(heapWorker, getState().snapshots[0].id,
lazyChildren));
equal(getState().snapshots[0].dominatorTree.state,
dominatorTreeState.INCREMENTAL_FETCHING,
@ -119,7 +120,8 @@ add_task(function* () {
const newNode = findNewNode(newRoot);
ok(newNode, "Should find the node in the new tree again");
ok(newNode !== oldNode, "We did not mutate the old node in place, instead created a new node");
ok(newNode !== oldNode,
"We did not mutate the old node in place, instead created a new node");
ok(newNode.children, "And the new node should have the children attached");
heapWorker.destroy();

View File

@ -1,17 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we can incrementally fetch two subtrees in the same dominator tree
// concurrently. This exercises the activeFetchRequestCount machinery.
const {
snapshotState: states,
dominatorTreeState,
viewState,
} = require("devtools/client/memory/constants");
const {
takeSnapshotAndCensus,
selectSnapshotAndRefresh,
fetchImmediatelyDominated,
} = require("devtools/client/memory/actions/snapshot");
const DominatorTreeLazyChildren

View File

@ -1,11 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we can change the display with which we describe a dominator tree
// and that the dominator tree is re-fetched.
const {
snapshotState: states,
dominatorTreeState,
viewState,
labelDisplays,
@ -19,7 +20,6 @@ const {
} = require("devtools/client/memory/actions/view");
const {
takeSnapshotAndCensus,
computeAndFetchDominatorTree,
} = require("devtools/client/memory/actions/snapshot");
function run_test() {

View File

@ -1,11 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we can change the display with which we describe a dominator tree
// while the dominator tree is in the middle of being fetched.
const {
snapshotState: states,
dominatorTreeState,
viewState,
labelDisplays,
@ -19,7 +20,6 @@ const {
} = require("devtools/client/memory/actions/view");
const {
takeSnapshotAndCensus,
computeAndFetchDominatorTree,
} = require("devtools/client/memory/actions/snapshot");
function run_test() {

View File

@ -1,11 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we maintain focus of the selected dominator tree node across
// changing breakdowns for labeling them.
let {
snapshotState: states,
dominatorTreeState,
labelDisplays,
viewState,

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Basic test for switching to the individuals view.

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test switching to the individuals view when we are in the middle of computing

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test switching to the individuals view when we are in the diffing view.
@ -45,8 +46,8 @@ add_task(function* () {
dispatch(takeSnapshotAndCensus(front, heapWorker));
dispatch(takeSnapshotAndCensus(front, heapWorker));
yield waitUntilCensusState(store, s => s.census, [censusState.SAVED,
censusState.SAVED]);
yield waitUntilCensusState(store, s => s.census,
[censusState.SAVED, censusState.SAVED]);
dispatch(changeView(viewState.DIFFING));
dispatch(selectSnapshotForDiffingAndRefresh(heapWorker, getState().snapshots[0]));

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test showing individual Array objects.

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test showing individual objects that do not have allocation stacks.

View File

@ -1,5 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that clearing the current individuals' snapshot leaves the individuals

Some files were not shown because too many files have changed in this diff Show More