mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 01:35:35 +00:00
Backed out changeset 5f17f4325f31 (bug 1218679) for memory leaks on a CLOSED TREE
This commit is contained in:
parent
63b5112216
commit
f033128ee4
@ -29,9 +29,6 @@ actions.SELECT_SNAPSHOT = "select-snapshot";
|
||||
// Fired to toggle tree inversion on or off.
|
||||
actions.TOGGLE_INVERTED = "toggle-inverted";
|
||||
|
||||
// Fired to set a new breakdown.
|
||||
actions.SET_BREAKDOWN = "set-breakdown";
|
||||
|
||||
// Fired when there is an error processing a snapshot or taking a census.
|
||||
actions.SNAPSHOT_ERROR = "snapshot-error";
|
||||
|
||||
|
@ -19,21 +19,13 @@ const Store = require("devtools/client/memory/store");
|
||||
*/
|
||||
var gToolbox, gTarget, gFront, gHeapAnalysesClient;
|
||||
|
||||
/**
|
||||
* Globals set by initialize()
|
||||
*/
|
||||
var gRoot, gStore, gApp, gProvider;
|
||||
|
||||
function initialize () {
|
||||
return Task.spawn(function*() {
|
||||
gRoot = document.querySelector("#app");
|
||||
gStore = Store();
|
||||
gApp = createElement(App, {
|
||||
front: gFront,
|
||||
heapWorker: gHeapAnalysesClient
|
||||
});
|
||||
gProvider = createElement(Provider, { store: gStore }, gApp);
|
||||
render(gProvider, gRoot);
|
||||
let root = document.querySelector("#app");
|
||||
let store = Store();
|
||||
let app = createElement(App, { front: gFront, heapWorker: gHeapAnalysesClient });
|
||||
let provider = createElement(Provider, { store }, app);
|
||||
render(provider, root);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,4 @@ subsuite = devtools
|
||||
support-files =
|
||||
head.js
|
||||
|
||||
[browser_memory-breakdowns-01.js]
|
||||
[browser_memory-simple-01.js]
|
||||
[browser_memory_transferHeapSnapshot_e10s_01.js]
|
||||
|
@ -1,33 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Tests that the heap tree renders rows based on the breakdown
|
||||
*/
|
||||
|
||||
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 $$ = document.querySelectorAll.bind(document);
|
||||
|
||||
yield takeSnapshot(panel.panelWin);
|
||||
|
||||
yield waitUntilSnapshotState(gStore, [states.SAVED_CENSUS]);
|
||||
|
||||
info("Check coarse type heap view");
|
||||
["objects", "other", "scripts", "strings"].forEach(findNameCell);
|
||||
|
||||
yield setBreakdown(panel.panelWin, "objectClass");
|
||||
info("Check object class heap view");
|
||||
["Function", "Object"].forEach(findNameCell);
|
||||
|
||||
yield setBreakdown(panel.panelWin, "internalType");
|
||||
info("Check internal type heap view");
|
||||
["JSObject"].forEach(findNameCell);
|
||||
|
||||
function findNameCell (name) {
|
||||
let el = Array.prototype.find.call($$(".tree .heap-tree-item-name span"), el => el.textContent === name);
|
||||
ok(el, `Found heap tree item cell for ${name}.`);
|
||||
}
|
||||
});
|
@ -1,35 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Tests taking snapshots and default states.
|
||||
*/
|
||||
|
||||
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;
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
yield waitUntilSnapshotState(gStore, [states.SAVED_CENSUS, states.SAVED_CENSUS]);
|
||||
|
||||
ok(document.querySelector(".heap-tree-item-name"),
|
||||
"Should have rendered some tree items");
|
||||
});
|
@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
var objects = window.objects = [];
|
||||
|
||||
var allocate = this.allocate = function allocate() {
|
||||
for (var i = 0; i < 100; i++)
|
||||
objects.push({});
|
||||
setTimeout(allocate, 10);
|
||||
}
|
||||
|
||||
allocate();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -8,9 +8,6 @@ Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js",
|
||||
this);
|
||||
|
||||
var { snapshotState: states } = require("devtools/client/memory/constants");
|
||||
var { breakdownEquals, breakdownNameToSpec } = require("devtools/client/memory/utils");
|
||||
|
||||
Services.prefs.setBoolPref("devtools.memory.enabled", true);
|
||||
|
||||
/**
|
||||
@ -66,60 +63,3 @@ function makeMemoryTest(url, generator) {
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function waitUntilState (store, predicate) {
|
||||
let deferred = promise.defer();
|
||||
let unsubscribe = store.subscribe(check);
|
||||
|
||||
function check () {
|
||||
if (predicate(store.getState())) {
|
||||
unsubscribe();
|
||||
deferred.resolve()
|
||||
}
|
||||
}
|
||||
|
||||
// Fire the check immediately incase the action has already occurred
|
||||
check();
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function waitUntilSnapshotState (store, expected) {
|
||||
let predicate = () => {
|
||||
let snapshots = store.getState().snapshots;
|
||||
info(snapshots.map(x => x.state));
|
||||
return snapshots.length === expected.length &&
|
||||
expected.every((state, i) => state === "*" || snapshots[i].state === state);
|
||||
};
|
||||
info(`Waiting for snapshots to be of state: ${expected}`);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets breakdown and waits for currently selected breakdown to use it
|
||||
* and be completed the census.
|
||||
*/
|
||||
function setBreakdown (window, type) {
|
||||
info(`Setting breakdown to ${type}...`);
|
||||
let { gStore, gHeapAnalysesClient } = window;
|
||||
// XXX: Should handle this via clicking the DOM, but React doesn't
|
||||
// fire the onChange event, so just change it in the store.
|
||||
// window.document.querySelector(`.select-breakdown`).value = type;
|
||||
gStore.dispatch(require("devtools/client/memory/actions/breakdown")
|
||||
.setBreakdownAndRefresh(gHeapAnalysesClient, breakdownNameToSpec(type)));
|
||||
|
||||
return waitUntilState(window.gStore, () => {
|
||||
let selected = window.gStore.getState().snapshots.find(s => s.selected);
|
||||
return selected.state === states.SAVED_CENSUS &&
|
||||
breakdownEquals(breakdownNameToSpec(type), selected.breakdown);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user