From 4e2e9be6abed3225406b466099e397acc0f914d2 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 22 Feb 2020 17:32:39 -0500 Subject: Reclassify heapsnapshot and nsJSInspector as not part of devtools This resolves Issue #316 --- .../tests/unit/test_HeapSnapshot_takeCensus_02.js | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_02.js (limited to 'dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_02.js') diff --git a/dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_02.js b/dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_02.js new file mode 100644 index 000000000..680ac9b58 --- /dev/null +++ b/dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_02.js @@ -0,0 +1,57 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// HeapSnapshot.prototype.takeCensus behaves plausibly as we allocate objects. +// +// Exact object counts vary in ways we can't predict. For example, +// BaselineScripts can hold onto "template objects", which exist only to hold +// the shape and type for newly created objects. When BaselineScripts are +// discarded, these template objects go with them. +// +// So instead of expecting precise counts, we expect counts that are at least as +// many as we would expect given the object graph we've built. +// +// Ported from js/src/jit-tests/debug/Memory-takeCensus-02.js + +function run_test() { + // A Debugger with no debuggees had better not find anything. + var dbg = new Debugger; + var census0 = saveHeapSnapshotAndTakeCensus(dbg); + Census.walkCensus(census0, "census0", Census.assertAllZeros); + + function newGlobalWithDefs() { + var g = newGlobal(); + g.eval(` + function times(n, fn) { + var a=[]; + for (var i = 0; i ({}));"); + g.eval("var rxs = times(200, () => /foo/);"); + g.eval("var ars = times(400, () => []);"); + g.eval("var fns = times(800, () => () => {});"); + + var census1 = dbg.memory.takeCensus(dbg); + Census.walkCensus(census1, "census1", + Census.assertAllNotLessThan( + { "objects": + { "Object": { count: 100 }, + "RegExp": { count: 200 }, + "Array": { count: 400 }, + "Function": { count: 800 } + } + })); + + do_test_finished(); +} -- cgit v1.2.3