diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-22 17:32:39 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:50:57 +0200 |
commit | 36fc5f674ef1a02d1498484c563a7108f4de44ed (patch) | |
tree | 120483cd8fc0decd189d5118941a9b23d6156ad5 /dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_06.js | |
parent | 7b30664f59e65cadb7d5eb2e42591e90a32871f8 (diff) | |
download | UXP-36fc5f674ef1a02d1498484c563a7108f4de44ed.tar UXP-36fc5f674ef1a02d1498484c563a7108f4de44ed.tar.gz UXP-36fc5f674ef1a02d1498484c563a7108f4de44ed.tar.lz UXP-36fc5f674ef1a02d1498484c563a7108f4de44ed.tar.xz UXP-36fc5f674ef1a02d1498484c563a7108f4de44ed.zip |
Reclassify heapsnapshot and nsJSInspector as not part of devtools
This resolves Issue #316
Diffstat (limited to 'dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_06.js')
-rw-r--r-- | dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_06.js | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_06.js b/dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_06.js new file mode 100644 index 000000000..0412410c0 --- /dev/null +++ b/dom/heapsnapshot/tests/unit/test_HeapSnapshot_takeCensus_06.js @@ -0,0 +1,125 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Check HeapSnapshot.prototype.takeCensus handling of 'breakdown' argument. +// +// Ported from js/src/jit-test/tests/debug/Memory-takeCensus-06.js + +function run_test() { + var Pattern = Match.Pattern; + + var g = newGlobal(); + var dbg = new Debugger(g); + + Pattern({ count: Pattern.NATURAL, + bytes: Pattern.NATURAL }) + .assert(saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "count" } })); + + let census = saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "count", count: false, bytes: false } }); + equal("count" in census, false); + equal("bytes" in census, false); + + census = saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "count", count: true, bytes: false } }); + equal("count" in census, true); + equal("bytes" in census, false); + + census = saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "count", count: false, bytes: true } }); + equal("count" in census, false); + equal("bytes" in census, true); + + census = saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "count", count: true, bytes: true } }); + equal("count" in census, true); + equal("bytes" in census, true); + + + // Pattern doesn't mind objects with extra properties, so we'll restrict this + // list to the object classes we're pretty sure are going to stick around for + // the forseeable future. + Pattern({ + Function: { count: Pattern.NATURAL }, + Object: { count: Pattern.NATURAL }, + Debugger: { count: Pattern.NATURAL }, + Sandbox: { count: Pattern.NATURAL }, + + // The below are all Debugger prototype objects. + Source: { count: Pattern.NATURAL }, + Environment: { count: Pattern.NATURAL }, + Script: { count: Pattern.NATURAL }, + Memory: { count: Pattern.NATURAL }, + Frame: { count: Pattern.NATURAL } + }) + .assert(saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "objectClass" } })); + + Pattern({ + objects: { count: Pattern.NATURAL }, + scripts: { count: Pattern.NATURAL }, + strings: { count: Pattern.NATURAL }, + other: { count: Pattern.NATURAL } + }) + .assert(saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "coarseType" } })); + + // As for { by: 'objectClass' }, restrict our pattern to the types + // we predict will stick around for a long time. + Pattern({ + JSString: { count: Pattern.NATURAL }, + "js::Shape": { count: Pattern.NATURAL }, + JSObject: { count: Pattern.NATURAL }, + JSScript: { count: Pattern.NATURAL } + }) + .assert(saveHeapSnapshotAndTakeCensus(dbg, { breakdown: { by: "internalType" } })); + + + // Nested breakdowns. + + let coarseTypePattern = { + objects: { count: Pattern.NATURAL }, + scripts: { count: Pattern.NATURAL }, + strings: { count: Pattern.NATURAL }, + other: { count: Pattern.NATURAL } + }; + + Pattern({ + JSString: coarseTypePattern, + "js::Shape": coarseTypePattern, + JSObject: coarseTypePattern, + JSScript: coarseTypePattern, + }) + .assert(saveHeapSnapshotAndTakeCensus(dbg, { + breakdown: { by: "internalType", + then: { by: "coarseType" } + } + })); + + Pattern({ + Function: { count: Pattern.NATURAL }, + Object: { count: Pattern.NATURAL }, + Debugger: { count: Pattern.NATURAL }, + Sandbox: { count: Pattern.NATURAL }, + other: coarseTypePattern + }) + .assert(saveHeapSnapshotAndTakeCensus(dbg, { + breakdown: { + by: "objectClass", + then: { by: "count" }, + other: { by: "coarseType" } + } + })); + + Pattern({ + objects: { count: Pattern.NATURAL, label: "object" }, + scripts: { count: Pattern.NATURAL, label: "scripts" }, + strings: { count: Pattern.NATURAL, label: "strings" }, + other: { count: Pattern.NATURAL, label: "other" } + }) + .assert(saveHeapSnapshotAndTakeCensus(dbg, { + breakdown: { + by: "coarseType", + objects: { by: "count", label: "object" }, + scripts: { by: "count", label: "scripts" }, + strings: { by: "count", label: "strings" }, + other: { by: "count", label: "other" } + } + })); + + do_test_finished(); +} |