2011-05-03 17:12:58 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
|
|
|
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
|
|
|
<window title="about:memory"
|
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/>
|
|
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
|
|
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
|
|
|
|
|
|
|
<!-- test results are displayed in the html:body -->
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml"></body>
|
|
|
|
|
|
|
|
<!-- test code goes here -->
|
|
|
|
<script type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
var mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
|
|
|
|
getService(Ci.nsIMemoryReporterManager);
|
|
|
|
|
|
|
|
// Remove all the real reporters; save them to restore at the end.
|
|
|
|
var e = mgr.enumerateReporters();
|
|
|
|
var realReporters = [];
|
|
|
|
while (e.hasMoreElements()) {
|
|
|
|
var mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter);
|
|
|
|
mgr.unregisterReporter(mr);
|
|
|
|
realReporters.push(mr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup various fake-but-deterministic reporters.
|
|
|
|
const KB = 1024;
|
|
|
|
const MB = KB * KB;
|
2011-05-22 19:49:56 -07:00
|
|
|
const kUnknown = -1;
|
|
|
|
const MAPPED = Ci.nsIMemoryReporter.MR_MAPPED;
|
|
|
|
const HEAP = Ci.nsIMemoryReporter.MR_HEAP;
|
|
|
|
const OTHER = Ci.nsIMemoryReporter.MR_OTHER;
|
|
|
|
|
2011-05-03 17:12:58 -07:00
|
|
|
fakeReporters = [
|
2011-05-22 19:49:56 -07:00
|
|
|
{ path: "heap-used", kind: OTHER, memoryUsed: 500 * MB },
|
|
|
|
{ path: "heap-unused", kind: OTHER, memoryUsed: 100 * MB },
|
|
|
|
{ path: "explicit/a", kind: HEAP, memoryUsed: 222 * MB },
|
|
|
|
{ path: "explicit/b/a", kind: HEAP, memoryUsed: 85 * MB },
|
|
|
|
{ path: "explicit/b/b", kind: HEAP, memoryUsed: 75 * MB },
|
|
|
|
{ path: "explicit/b/c/a", kind: HEAP, memoryUsed: 70 * MB },
|
|
|
|
{ path: "explicit/b/c/b", kind: HEAP, memoryUsed: 2 * MB }, // omitted
|
|
|
|
{ path: "explicit/c", kind: MAPPED,memoryUsed: 123 * MB },
|
|
|
|
{ path: "explicit/d", kind: MAPPED,memoryUsed: 499 * KB }, // omitted
|
|
|
|
{ path: "explicit/e", kind: MAPPED,memoryUsed: 100 * KB }, // omitted
|
|
|
|
{ path: "explicit/f/g/h/i", kind: HEAP, memoryUsed: 20 * MB },
|
|
|
|
{ path: "explicit/g", kind: HEAP, memoryUsed: 14 * MB }, // internal
|
|
|
|
{ path: "explicit/g", kind: HEAP, memoryUsed: 1 * MB }, // internal, dup: merge
|
|
|
|
{ path: "explicit/g/a", kind: HEAP, memoryUsed: 6 * MB },
|
|
|
|
{ path: "explicit/g/b", kind: HEAP, memoryUsed: 5 * MB },
|
|
|
|
{ path: "other1", kind: OTHER, memoryUsed: 111 * MB },
|
|
|
|
{ path: "other2", kind: OTHER, memoryUsed: 222 * MB },
|
2011-05-03 17:12:58 -07:00
|
|
|
|
2011-05-22 19:49:56 -07:00
|
|
|
{ path: "2nd:heap-used", kind: OTHER, memoryUsed: 1000 * MB },
|
|
|
|
{ path: "2nd:heap-unused", kind: OTHER, memoryUsed: 100 * MB },
|
|
|
|
{ path: "2nd:explicit/a/b/c",kind: HEAP, memoryUsed: 498 * MB },
|
|
|
|
{ path: "2nd:explicit/a/b/c",kind: HEAP, memoryUsed: 1 * MB }, // dup: merge
|
|
|
|
{ path: "2nd:explicit/b", kind: HEAP, memoryUsed: 400 * MB },
|
|
|
|
{ path: "2nd:other1", kind: OTHER, memoryUsed: 777 * MB },
|
2011-05-03 17:12:58 -07:00
|
|
|
|
2011-05-22 19:49:56 -07:00
|
|
|
// kUnknown should be handled gracefully for "heap-used", non-leaf
|
|
|
|
// reporters, leaf-reporters, and "other" reporters.
|
|
|
|
{ path: "3rd:heap-used", kind: OTHER, memoryUsed: kUnknown },
|
|
|
|
{ path: "3rd:explicit/a", kind: HEAP, memoryUsed: kUnknown },
|
|
|
|
{ path: "3rd:explicit/a/b", kind: HEAP, memoryUsed: 333 * MB },
|
|
|
|
{ path: "3rd:explicit/a/c", kind: HEAP, memoryUsed: 444 * MB },
|
|
|
|
{ path: "3rd:explicit/a/d", kind: HEAP, memoryUsed: kUnknown },
|
|
|
|
{ path: "3rd:explicit/b", kind: MAPPED,memoryUsed: kUnknown },
|
|
|
|
{ path: "3rd:other1", kind: OTHER, memoryUsed: kUnknown }
|
2011-05-03 17:12:58 -07:00
|
|
|
];
|
|
|
|
for (var i = 0; i < fakeReporters.length; i++) {
|
2011-05-22 19:49:56 -07:00
|
|
|
fakeReporters[i].description = "(description)";
|
2011-05-03 17:12:58 -07:00
|
|
|
mgr.registerReporter(fakeReporters[i]);
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
2011-05-11 16:09:50 -07:00
|
|
|
<iframe id="amFrame" height="300" src="about:memory"></iframe>
|
|
|
|
<iframe id="amvFrame" height="300" src="about:memory?verbose"></iframe>
|
2011-05-03 17:12:58 -07:00
|
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
var amExpectedText =
|
|
|
|
"\
|
|
|
|
Main Process\n\
|
|
|
|
\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
Explicit Allocations\n\
|
|
|
|
623.58 MB (100.0%) -- explicit\n\
|
|
|
|
├──232.00 MB (37.20%) -- b\n\
|
|
|
|
│ ├───85.00 MB (13.63%) -- a\n\
|
|
|
|
│ ├───75.00 MB (12.03%) -- b\n\
|
|
|
|
│ └───72.00 MB (11.55%) -- c\n\
|
|
|
|
│ ├──70.00 MB (11.23%) -- a\n\
|
|
|
|
│ └───2.00 MB (00.32%) -- (1 omitted)\n\
|
|
|
|
├──222.00 MB (35.60%) -- a\n\
|
|
|
|
├──123.00 MB (19.72%) -- c\n\
|
|
|
|
├───20.00 MB (03.21%) -- f\n\
|
|
|
|
│ └──20.00 MB (03.21%) -- g\n\
|
|
|
|
│ └──20.00 MB (03.21%) -- h\n\
|
|
|
|
│ └──20.00 MB (03.21%) -- i\n\
|
|
|
|
├───15.00 MB (02.41%) -- g\n\
|
|
|
|
│ ├───6.00 MB (00.96%) -- a\n\
|
|
|
|
│ ├───5.00 MB (00.80%) -- b\n\
|
|
|
|
│ └───4.00 MB (00.64%) -- other\n\
|
|
|
|
├───11.00 MB (01.76%) -- heap-unclassified\n\
|
|
|
|
└────0.58 MB (00.09%) -- (2 omitted)\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
Other Measurements\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
500.00 MB -- heap-used\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
222.00 MB -- other2\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
111.00 MB -- other1\n\
|
|
|
|
100.00 MB -- heap-unused\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
2nd Process\n\
|
|
|
|
\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
Explicit Allocations\n\
|
|
|
|
1,000.00 MB (100.0%) -- explicit\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
├────499.00 MB (49.90%) -- a\n\
|
|
|
|
│ └──499.00 MB (49.90%) -- b\n\
|
|
|
|
│ └──499.00 MB (49.90%) -- c\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
├────400.00 MB (40.00%) -- b\n\
|
|
|
|
└────101.00 MB (10.10%) -- heap-unclassified\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
Other Measurements\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
1,000.00 MB -- heap-used\n\
|
|
|
|
777.00 MB -- other1\n\
|
|
|
|
100.00 MB -- heap-unused\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
3rd Process\n\
|
|
|
|
\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
Explicit Allocations\n\
|
|
|
|
777.00 MB (100.0%) -- explicit\n\
|
|
|
|
├──777.00 MB (100.0%) -- a [*]\n\
|
|
|
|
│ ├──444.00 MB (57.14%) -- c\n\
|
|
|
|
│ ├──333.00 MB (42.86%) -- b\n\
|
|
|
|
│ └────0.00 MB (00.00%) -- (1 omitted)\n\
|
|
|
|
└────0.00 MB (00.00%) -- (2 omitted)\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
Other Measurements\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
0.00 MB -- heap-used [*]\n\
|
|
|
|
0.00 MB -- other1 [*]\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
";
|
|
|
|
|
|
|
|
var amvExpectedText =
|
|
|
|
"\
|
|
|
|
Main Process\n\
|
|
|
|
\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
Explicit Allocations\n\
|
|
|
|
653,876,224 B (100.0%) -- explicit\n\
|
|
|
|
├──243,269,632 B (37.20%) -- b\n\
|
|
|
|
│ ├───89,128,960 B (13.63%) -- a\n\
|
|
|
|
│ ├───78,643,200 B (12.03%) -- b\n\
|
|
|
|
│ └───75,497,472 B (11.55%) -- c\n\
|
|
|
|
│ ├──73,400,320 B (11.23%) -- a\n\
|
|
|
|
│ └───2,097,152 B (00.32%) -- b\n\
|
|
|
|
├──232,783,872 B (35.60%) -- a\n\
|
|
|
|
├──128,974,848 B (19.72%) -- c\n\
|
|
|
|
├───20,971,520 B (03.21%) -- f\n\
|
|
|
|
│ └──20,971,520 B (03.21%) -- g\n\
|
|
|
|
│ └──20,971,520 B (03.21%) -- h\n\
|
|
|
|
│ └──20,971,520 B (03.21%) -- i\n\
|
|
|
|
├───15,728,640 B (02.41%) -- g\n\
|
|
|
|
│ ├───6,291,456 B (00.96%) -- a\n\
|
|
|
|
│ ├───5,242,880 B (00.80%) -- b\n\
|
|
|
|
│ └───4,194,304 B (00.64%) -- other\n\
|
|
|
|
├───11,534,336 B (01.76%) -- heap-unclassified\n\
|
|
|
|
├──────510,976 B (00.08%) -- d\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
└──────102,400 B (00.02%) -- e\n\
|
|
|
|
\n\
|
|
|
|
Other Measurements\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
524,288,000 B -- heap-used\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
232,783,872 B -- other2\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
116,391,936 B -- other1\n\
|
|
|
|
104,857,600 B -- heap-unused\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
2nd Process\n\
|
|
|
|
\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
Explicit Allocations\n\
|
|
|
|
1,048,576,000 B (100.0%) -- explicit\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
├────523,239,424 B (49.90%) -- a\n\
|
|
|
|
│ └──523,239,424 B (49.90%) -- b\n\
|
|
|
|
│ └──523,239,424 B (49.90%) -- c\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
├────419,430,400 B (40.00%) -- b\n\
|
|
|
|
└────105,906,176 B (10.10%) -- heap-unclassified\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
Other Measurements\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
1,048,576,000 B -- heap-used\n\
|
|
|
|
814,743,552 B -- other1\n\
|
|
|
|
104,857,600 B -- heap-unused\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
3rd Process\n\
|
|
|
|
\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
Explicit Allocations\n\
|
|
|
|
814,743,552 B (100.0%) -- explicit\n\
|
|
|
|
├──814,743,552 B (100.0%) -- a [*]\n\
|
|
|
|
│ ├──465,567,744 B (57.14%) -- c\n\
|
|
|
|
│ ├──349,175,808 B (42.86%) -- b\n\
|
|
|
|
│ └────────────0 B (00.00%) -- d [*]\n\
|
|
|
|
├────────────0 B (00.00%) -- b [*]\n\
|
|
|
|
└────────────0 B (00.00%) -- heap-unclassified [*]\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
Other Measurements\n\
|
2011-05-22 19:49:56 -07:00
|
|
|
0 B -- heap-used [*]\n\
|
|
|
|
0 B -- other1 [*]\n\
|
2011-05-03 17:12:58 -07:00
|
|
|
\n\
|
|
|
|
"
|
|
|
|
|
|
|
|
function finish()
|
|
|
|
{
|
|
|
|
// Unregister fake reporters, re-register the real reporters, just in
|
|
|
|
// case subsequent tests rely on them.
|
|
|
|
for (var i = 0; i < fakeReporters.length; i++) {
|
|
|
|
mgr.unregisterReporter(fakeReporters[i]);
|
|
|
|
}
|
|
|
|
for (var i = 0; i < realReporters.length; i++) {
|
|
|
|
mgr.registerReporter(realReporters[i]);
|
|
|
|
}
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cut+paste the entire page and check that the cut text matches what we
|
|
|
|
// expect. This tests the output in general and also that the cutting and
|
|
|
|
// pasting works as expected.
|
|
|
|
function test(aFrame, aExpectedText, aNext) {
|
|
|
|
document.querySelector("#" + aFrame).focus();
|
|
|
|
SimpleTest.waitForClipboard(aExpectedText,
|
|
|
|
function() {
|
|
|
|
synthesizeKey("A", {accelKey: true});
|
|
|
|
synthesizeKey("C", {accelKey: true});
|
|
|
|
},
|
|
|
|
aNext,
|
|
|
|
function() {
|
|
|
|
ok(false, "pasted text doesn't match for " + aFrame);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
addLoadEvent(function() {
|
|
|
|
test(
|
|
|
|
"amFrame",
|
|
|
|
amExpectedText,
|
|
|
|
function() {
|
|
|
|
test(
|
|
|
|
"amvFrame",
|
|
|
|
amvExpectedText,
|
|
|
|
function() {
|
|
|
|
finish()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
</window>
|