toolkit/components/aboutmemory/tests/test_aboutmemory.xul

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ef95dbe1615b
1 <?xml version="1.0"?>
2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?>
3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
4 <window title="about:memory"
5 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
6 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
7 <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
8
9 <!-- This file uses fake memory reporters to test the presentation of memory
10 reports in about:memory. test_memoryReporters.xul uses the real
11 memory reporters to test whether the memory reporters are producing
12 sensible results. -->
13
14 <!-- test results are displayed in the html:body -->
15 <body xmlns="http://www.w3.org/1999/xhtml"></body>
16
17 <!-- test code goes here -->
18 <script type="application/javascript">
19 <![CDATA[
20 "use strict";
21
22 SimpleTest.expectAssertions(27);
23
24 const Cc = Components.classes;
25 const Ci = Components.interfaces;
26 const Cr = Components.results;
27 let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
28 getService(Ci.nsIMemoryReporterManager);
29
30 // Hide all the real reporters; we'll restore them at the end.
31 mgr.blockRegistrationAndHideExistingReporters();
32
33 // Setup various fake-but-deterministic reporters.
34 const KB = 1024;
35 const MB = KB * KB;
36 const NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP;
37 const HEAP = Ci.nsIMemoryReporter.KIND_HEAP;
38 const OTHER = Ci.nsIMemoryReporter.KIND_OTHER;
39
40 const BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
41 const COUNT = Ci.nsIMemoryReporter.UNITS_COUNT;
42 const COUNT_CUMULATIVE = Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE;
43 const PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
44
45 let fakeReporters = [
46 { collectReports: function(aCbObj, aClosure) {
47 function f(aP, aK, aU, aA) {
48 aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
49 }
50 f("heap-allocated", OTHER, BYTES, 500 * MB);
51 f("heap-unallocated", OTHER, BYTES, 100 * MB);
52 f("explicit/a", HEAP, BYTES, 222 * MB);
53 f("explicit/b/a", HEAP, BYTES, 85 * MB);
54 f("explicit/b/b", HEAP, BYTES, 75 * MB);
55 f("explicit/b/c/a", HEAP, BYTES, 70 * MB);
56 f("explicit/b/c/b", HEAP, BYTES, 2 * MB); // omitted
57 f("explicit/g/a", HEAP, BYTES, 6 * MB);
58 f("explicit/g/b", HEAP, BYTES, 5 * MB);
59 f("explicit/g/other", HEAP, BYTES, 4 * MB);
60 // A degenerate tree with the same name as a non-degenerate tree should
61 // work ok.
62 f("explicit", OTHER, BYTES, 888 * MB);
63 f("other1/a/b", OTHER, BYTES, 111 * MB);
64 f("other1/c/d", OTHER, BYTES, 22 * MB);
65 f("other1/c/e", OTHER, BYTES, 33 * MB);
66 f("other4", OTHER, COUNT_CUMULATIVE, 777);
67 f("other4", OTHER, COUNT_CUMULATIVE, 111);
68 f("other3/a/b/c/d/e", OTHER, PERCENTAGE, 2000);
69 f("other3/a/b/c/d/f", OTHER, PERCENTAGE, 10);
70 f("other3/a/b/c/d/g", OTHER, PERCENTAGE, 5);
71 f("other3/a/b/c/d/g", OTHER, PERCENTAGE, 5);
72 // Check that a rounded-up-to-100.00% value is shown as "100.0%" (i.e. one
73 // decimal point).
74 f("other6/big", OTHER, COUNT, 99999);
75 f("other6/small", OTHER, COUNT, 1);
76 // Check that a 0 / 0 is handled correctly.
77 f("other7/zero", OTHER, BYTES, 0);
78 // These compartments ones shouldn't be displayed.
79 f("compartments/user/foo", OTHER, COUNT, 1);
80 f("compartments/system/foo", OTHER, COUNT, 1);
81 }
82 },
83 { collectReports: function(aCbObj, aClosure) {
84 function f(aP, aK, aU, aA) {
85 aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
86 }
87 f("explicit/c/d", NONHEAP, BYTES, 13 * MB);
88 f("explicit/c/d", NONHEAP, BYTES, 10 * MB); // dup
89 f("explicit/c/other", NONHEAP, BYTES, 77 * MB);
90 f("explicit/cc", NONHEAP, BYTES, 13 * MB);
91 f("explicit/cc", NONHEAP, BYTES, 10 * MB); // dup
92 f("explicit/d", NONHEAP, BYTES, 499 * KB); // omitted
93 f("explicit/e", NONHEAP, BYTES, 100 * KB); // omitted
94 f("explicit/f/g/h/i", HEAP, BYTES, 10 * MB);
95 f("explicit/f/g/h/j", HEAP, BYTES, 10 * MB);
96 }
97 },
98 { collectReports: function(aCbObj, aClosure) {
99 function f(aP, aK, aU, aA) {
100 aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
101 }
102 f("other3", OTHER, COUNT, 777);
103 f("other2", OTHER, BYTES, 222 * MB);
104 f("perc2", OTHER, PERCENTAGE, 10000);
105 f("perc1", OTHER, PERCENTAGE, 4567);
106 f("compartments/user/https:\\\\very-long-url.com\\very-long\\oh-so-long\\really-quite-long.html?a=2&b=3&c=4&d=5&e=abcdefghijklmnopqrstuvwxyz&f=123456789123456789123456789", OTHER, COUNT, 1);
107 }
108 },
109 { collectReports: function(aCbObj, aClosure) {
110 function f(aP) {
111 aCbObj.callback("", aP, OTHER, COUNT, 1, "Desc.", aClosure);
112 }
113 f("compartments/user/bar");
114 f("compartments/system/bar");
115 }
116 }
117 ];
118 for (let i = 0; i < fakeReporters.length; i++) {
119 mgr.registerStrongReporterEvenIfBlocked(fakeReporters[i]);
120 }
121
122 // mgr.explicit sums "heap-allocated" and all the appropriate NONHEAP ones:
123 // - "explicit/c", "explicit/cc" x 2, "explicit/d", "explicit/e"
124 // - but *not* "explicit/c/d" x 2
125 // Check explicit now before we add the fake reporters for the fake 2nd
126 // and subsequent processes.
127 //
128 // Nb: mgr.explicit will throw NS_ERROR_NOT_AVAILABLE if this is a
129 // --enable-trace-malloc build. Allow for that exception, but *only* that
130 // exception.
131 try {
132 is(mgr.explicit, 500*MB + (100 + 13 + 10)*MB + 599*KB, "mgr.explicit");
133 } catch (ex) {
134 is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.explicit exception");
135 }
136
137 // The main process always comes first when we display about:memory. The
138 // remaining processes are sorted by their |resident| values (starting with
139 // the largest). Processes without a |resident| memory reporter are saved
140 // for the end.
141 let fakeReporters2 = [
142 { collectReports: function(aCbObj, aClosure) {
143 function f(aP1, aP2, aK, aU, aA) {
144 aCbObj.callback(aP1, aP2, aK, aU, aA, "Desc.", aClosure);
145 }
146 f("2nd", "heap-allocated", OTHER, BYTES,1000* MB);
147 f("2nd", "heap-unallocated",OTHER, BYTES,100 * MB);
148 f("2nd", "explicit/a/b/c", HEAP, BYTES,497 * MB);
149 f("2nd", "explicit/a/b/c", HEAP, BYTES, 1 * MB); // dup: merge
150 f("2nd", "explicit/a/b/c", HEAP, BYTES, 1 * MB); // dup: merge
151 f("2nd", "explicit/flip\\the\\backslashes",
152 HEAP, BYTES,200 * MB);
153 f("2nd", "explicit/compartment(compartment-url)",
154 HEAP, BYTES,200 * MB);
155 f("2nd", "other0", OTHER, BYTES,666 * MB);
156 f("2nd", "other1", OTHER, BYTES,111 * MB);
157
158 // Check that we can handle "heap-allocated" not being present.
159 f("3rd", "explicit/a/b", HEAP, BYTES,333 * MB);
160 f("3rd", "explicit/a/c", HEAP, BYTES,444 * MB);
161 f("3rd", "other1", OTHER, BYTES, 1 * MB);
162 f("3rd", "resident", OTHER, BYTES,100 * MB);
163
164 // Invalid values (negative, too-big) should be identified.
165 f("4th", "heap-allocated", OTHER, BYTES,100 * MB);
166 f("4th", "resident", OTHER, BYTES,200 * MB);
167 f("4th", "explicit/js/compartment(http:\\\\too-big.com\\)/stuff",
168 HEAP, BYTES,150 * MB);
169 f("4th", "explicit/ok", HEAP, BYTES, 5 * MB);
170 f("4th", "explicit/neg1", NONHEAP, BYTES, -2 * MB);
171 // -111 becomes "-0.00MB" in non-verbose mode, and getting the negative
172 // sign in there correctly is non-trivial.
173 f("4th", "other1", OTHER, BYTES,-111);
174 f("4th", "other2", OTHER, BYTES,-222 * MB);
175 f("4th", "other3", OTHER, COUNT, -333);
176 f("4th", "other4", OTHER, COUNT_CUMULATIVE, -444);
177 f("4th", "other5", OTHER, PERCENTAGE, -555);
178 f("4th", "other6", OTHER, PERCENTAGE, 66666);
179
180 // If a negative value is within a collapsed sub-tree in non-verbose mode,
181 // we should get the warning at the top and the relevant sub-trees should
182 // be expanded, even in non-verbose mode.
183 f("5th", "heap-allocated", OTHER, BYTES,100 * MB);
184 f("5th", "explicit/big", HEAP, BYTES, 99 * MB);
185 f("5th", "explicit/a/pos", HEAP, BYTES, 40 * KB);
186 f("5th", "explicit/a/neg1", NONHEAP, BYTES,-20 * KB);
187 f("5th", "explicit/a/neg2", NONHEAP, BYTES,-10 * KB);
188 f("5th", "explicit/b/c/d/e", NONHEAP, BYTES, 20 * KB);
189 f("5th", "explicit/b/c/d/f", NONHEAP, BYTES,-60 * KB);
190 f("5th", "explicit/b/c/g/h", NONHEAP, BYTES, 10 * KB);
191 f("5th", "explicit/b/c/i/j", NONHEAP, BYTES, 5 * KB);
192 }
193 }
194 ];
195 for (let i = 0; i < fakeReporters2.length; i++) {
196 mgr.registerStrongReporterEvenIfBlocked(fakeReporters2[i]);
197 }
198 fakeReporters = fakeReporters.concat(fakeReporters2);
199 ]]>
200 </script>
201
202 <iframe id="amFrame" height="300" src="about:memory"></iframe>
203 <!-- vary the capitalization to make sure that works -->
204 <iframe id="amvFrame" height="300" src="About:Memory"></iframe>
205
206 <script type="application/javascript">
207 <![CDATA[
208 let amExpectedText =
209 "\
210 Main Process\n\
211 Explicit Allocations\n\
212 \n\
213 623.58 MB (100.0%) -- explicit\n\
214 ├──232.00 MB (37.20%) -- b\n\
215 │ ├───85.00 MB (13.63%) ── a\n\
216 │ ├───75.00 MB (12.03%) ── b\n\
217 │ └───72.00 MB (11.55%) -- c\n\
218 │ ├──70.00 MB (11.23%) ── a\n\
219 │ └───2.00 MB (00.32%) ── b\n\
220 ├──222.00 MB (35.60%) ── a\n\
221 ├──100.00 MB (16.04%) -- c\n\
222 │ ├───77.00 MB (12.35%) ── other\n\
223 │ └───23.00 MB (03.69%) ── d [2]\n\
224 ├───23.00 MB (03.69%) ── cc [2]\n\
225 ├───20.00 MB (03.21%) -- f/g/h\n\
226 │ ├──10.00 MB (01.60%) ── i\n\
227 │ └──10.00 MB (01.60%) ── j\n\
228 ├───15.00 MB (02.41%) ++ g\n\
229 ├───11.00 MB (01.76%) ── heap-unclassified\n\
230 └────0.58 MB (00.09%) ++ (2 tiny)\n\
231 \n\
232 Other Measurements\n\
233 \n\
234 5 (100.0%) -- compartments\n\
235 ├──3 (60.00%) -- user\n\
236 │ ├──1 (20.00%) ── bar\n\
237 │ ├──1 (20.00%) ── foo\n\
238 │ └──1 (20.00%) ── https://very-long-url.com/very-long/oh-so-long/really-quite-long.html?a=2&b=3&c=4&d=5&e=abcdefghijklmnopqrstuvwxyz&f=123456789123456789123456789\n\
239 └──2 (40.00%) -- system\n\
240 ├──1 (20.00%) ── bar\n\
241 └──1 (20.00%) ── foo\n\
242 \n\
243 166.00 MB (100.0%) -- other1\n\
244 ├──111.00 MB (66.87%) ── a/b\n\
245 └───55.00 MB (33.13%) -- c\n\
246 ├──33.00 MB (19.88%) ── e\n\
247 └──22.00 MB (13.25%) ── d\n\
248 \n\
249 20.20% (100.0%) -- other3\n\
250 └──20.20% (100.0%) -- a/b/c/d\n\
251 ├──20.00% (99.01%) ── e\n\
252 └───0.20% (00.99%) ++ (2 tiny)\n\
253 \n\
254 100,000 (100.0%) -- other6\n\
255 ├───99,999 (100.0%) ── big\n\
256 └────────1 (00.00%) ── small\n\
257 \n\
258 0.00 MB (100.0%) -- other7\n\
259 └──0.00 MB (100.0%) ── zero\n\
260 \n\
261 888.00 MB ── explicit\n\
262 500.00 MB ── heap-allocated\n\
263 100.00 MB ── heap-unallocated\n\
264 222.00 MB ── other2\n\
265 777 ── other3\n\
266 888 ── other4 [2]\n\
267 45.67% ── perc1\n\
268 100.00% ── perc2\n\
269 \n\
270 End of Main Process\n\
271 4th\n\
272 \n\
273 WARNING: the following values are negative or unreasonably large.\n\
274 \n\
275 explicit/js/compartment(http://too-big.com/)/stuff\n\
276 explicit/(2 tiny)\n\
277 explicit/(2 tiny)/neg1\n\
278 explicit/(2 tiny)/heap-unclassified\n\
279 other1\n\
280 other2\n\
281 other3\n\
282 other4\n\
283 other5 \n\
284 \n\
285 This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
286 Explicit Allocations\n\
287 \n\
288 98.00 MB (100.0%) -- explicit\n\
289 ├──150.00 MB (153.06%) ── js/compartment(http://too-big.com/)/stuff [?!]\n\
290 ├───5.00 MB (05.10%) ── ok\n\
291 └──-57.00 MB (-58.16%) -- (2 tiny) [?!]\n\
292 ├───-2.00 MB (-2.04%) ── neg1 [?!]\n\
293 └──-55.00 MB (-56.12%) ── heap-unclassified [?!]\n\
294 \n\
295 Other Measurements\n\
296 \n\
297 100.00 MB ── heap-allocated\n\
298 -0.00 MB ── other1 [?!]\n\
299 -222.00 MB ── other2 [?!]\n\
300 -333 ── other3 [?!]\n\
301 -444 ── other4 [?!]\n\
302 -5.55% ── other5 [?!]\n\
303 666.66% ── other6\n\
304 200.00 MB ── resident\n\
305 \n\
306 End of 4th\n\
307 3rd\n\
308 \n\
309 WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
310 Explicit Allocations\n\
311 \n\
312 777.00 MB (100.0%) -- explicit\n\
313 └──777.00 MB (100.0%) -- a\n\
314 ├──444.00 MB (57.14%) ── c\n\
315 └──333.00 MB (42.86%) ── b\n\
316 \n\
317 Other Measurements\n\
318 \n\
319 1.00 MB ── other1\n\
320 100.00 MB ── resident\n\
321 \n\
322 End of 3rd\n\
323 2nd\n\
324 Explicit Allocations\n\
325 \n\
326 1,000.00 MB (100.0%) -- explicit\n\
327 ├────499.00 MB (49.90%) ── a/b/c [3]\n\
328 ├────200.00 MB (20.00%) ── compartment(compartment-url)\n\
329 ├────200.00 MB (20.00%) ── flip/the/backslashes\n\
330 └────101.00 MB (10.10%) ── heap-unclassified\n\
331 \n\
332 Other Measurements\n\
333 \n\
334 1,000.00 MB ── heap-allocated\n\
335 100.00 MB ── heap-unallocated\n\
336 666.00 MB ── other0\n\
337 111.00 MB ── other1\n\
338 \n\
339 End of 2nd\n\
340 5th\n\
341 \n\
342 WARNING: the following values are negative or unreasonably large.\n\
343 \n\
344 explicit/(3 tiny)/a/neg2\n\
345 explicit/(3 tiny)/a/neg1\n\
346 explicit/(3 tiny)/b/c\n\
347 explicit/(3 tiny)/b/c/d\n\
348 explicit/(3 tiny)/b/c/d/f \n\
349 \n\
350 This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
351 Explicit Allocations\n\
352 \n\
353 99.95 MB (100.0%) -- explicit\n\
354 ├──99.00 MB (99.05%) ── big\n\
355 └───0.95 MB (00.95%) -- (3 tiny)\n\
356 ├──0.96 MB (00.96%) ── heap-unclassified\n\
357 ├──0.01 MB (00.01%) -- a\n\
358 │ ├──0.04 MB (00.04%) ── pos\n\
359 │ ├──-0.01 MB (-0.01%) ── neg2 [?!]\n\
360 │ └──-0.02 MB (-0.02%) ── neg1 [?!]\n\
361 └──-0.02 MB (-0.02%) -- b/c [?!]\n\
362 ├───0.01 MB (00.01%) ── g/h\n\
363 ├───0.00 MB (00.00%) ── i/j\n\
364 └──-0.04 MB (-0.04%) -- d [?!]\n\
365 ├───0.02 MB (00.02%) ── e\n\
366 └──-0.06 MB (-0.06%) ── f [?!]\n\
367 \n\
368 Other Measurements\n\
369 \n\
370 100.00 MB ── heap-allocated\n\
371 \n\
372 End of 5th\n\
373 ";
374
375 let amvExpectedText =
376 "\
377 Main Process\n\
378 Explicit Allocations\n\
379 \n\
380 653,876,224 B (100.0%) -- explicit\n\
381 ├──243,269,632 B (37.20%) -- b\n\
382 │ ├───89,128,960 B (13.63%) ── a\n\
383 │ ├───78,643,200 B (12.03%) ── b\n\
384 │ └───75,497,472 B (11.55%) -- c\n\
385 │ ├──73,400,320 B (11.23%) ── a\n\
386 │ └───2,097,152 B (00.32%) ── b\n\
387 ├──232,783,872 B (35.60%) ── a\n\
388 ├──104,857,600 B (16.04%) -- c\n\
389 │ ├───80,740,352 B (12.35%) ── other\n\
390 │ └───24,117,248 B (03.69%) ── d [2]\n\
391 ├───24,117,248 B (03.69%) ── cc [2]\n\
392 ├───20,971,520 B (03.21%) -- f/g/h\n\
393 │ ├──10,485,760 B (01.60%) ── i\n\
394 │ └──10,485,760 B (01.60%) ── j\n\
395 ├───15,728,640 B (02.41%) -- g\n\
396 │ ├───6,291,456 B (00.96%) ── a\n\
397 │ ├───5,242,880 B (00.80%) ── b\n\
398 │ └───4,194,304 B (00.64%) ── other\n\
399 ├───11,534,336 B (01.76%) ── heap-unclassified\n\
400 ├──────510,976 B (00.08%) ── d\n\
401 └──────102,400 B (00.02%) ── e\n\
402 \n\
403 Other Measurements\n\
404 \n\
405 5 (100.0%) -- compartments\n\
406 ├──3 (60.00%) -- user\n\
407 │ ├──1 (20.00%) ── bar\n\
408 │ ├──1 (20.00%) ── foo\n\
409 │ └──1 (20.00%) ── https://very-long-url.com/very-long/oh-so-long/really-quite-long.html?a=2&b=3&c=4&d=5&e=abcdefghijklmnopqrstuvwxyz&f=123456789123456789123456789\n\
410 └──2 (40.00%) -- system\n\
411 ├──1 (20.00%) ── bar\n\
412 └──1 (20.00%) ── foo\n\
413 \n\
414 174,063,616 B (100.0%) -- other1\n\
415 ├──116,391,936 B (66.87%) ── a/b\n\
416 └───57,671,680 B (33.13%) -- c\n\
417 ├──34,603,008 B (19.88%) ── e\n\
418 └──23,068,672 B (13.25%) ── d\n\
419 \n\
420 20.20% (100.0%) -- other3\n\
421 └──20.20% (100.0%) -- a/b/c/d\n\
422 ├──20.00% (99.01%) ── e\n\
423 ├───0.10% (00.50%) ── f\n\
424 └───0.10% (00.50%) ── g [2]\n\
425 \n\
426 100,000 (100.0%) -- other6\n\
427 ├───99,999 (100.0%) ── big\n\
428 └────────1 (00.00%) ── small\n\
429 \n\
430 0 B (100.0%) -- other7\n\
431 └──0 B (100.0%) ── zero\n\
432 \n\
433 931,135,488 B ── explicit\n\
434 524,288,000 B ── heap-allocated\n\
435 104,857,600 B ── heap-unallocated\n\
436 232,783,872 B ── other2\n\
437 777 ── other3\n\
438 888 ── other4 [2]\n\
439 45.67% ── perc1\n\
440 100.00% ── perc2\n\
441 \n\
442 End of Main Process\n\
443 4th\n\
444 \n\
445 WARNING: the following values are negative or unreasonably large.\n\
446 \n\
447 explicit/js/compartment(http://too-big.com/)/stuff\n\
448 explicit/neg1\n\
449 explicit/heap-unclassified\n\
450 other1\n\
451 other2\n\
452 other3\n\
453 other4\n\
454 other5 \n\
455 \n\
456 This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
457 Explicit Allocations\n\
458 \n\
459 102,760,448 B (100.0%) -- explicit\n\
460 ├──157,286,400 B (153.06%) ── js/compartment(http://too-big.com/)/stuff [?!]\n\
461 ├────5,242,880 B (05.10%) ── ok\n\
462 ├───-2,097,152 B (-2.04%) ── neg1 [?!]\n\
463 └──-57,671,680 B (-56.12%) ── heap-unclassified [?!]\n\
464 \n\
465 Other Measurements\n\
466 \n\
467 104,857,600 B ── heap-allocated\n\
468 -111 B ── other1 [?!]\n\
469 -232,783,872 B ── other2 [?!]\n\
470 -333 ── other3 [?!]\n\
471 -444 ── other4 [?!]\n\
472 -5.55% ── other5 [?!]\n\
473 666.66% ── other6\n\
474 209,715,200 B ── resident\n\
475 \n\
476 End of 4th\n\
477 3rd\n\
478 \n\
479 WARNING: the 'heap-allocated' memory reporter does not work for this platform and/or configuration. This means that 'heap-unclassified' is not shown and the 'explicit' tree shows less memory than it should.\n\
480 Explicit Allocations\n\
481 \n\
482 814,743,552 B (100.0%) -- explicit\n\
483 └──814,743,552 B (100.0%) -- a\n\
484 ├──465,567,744 B (57.14%) ── c\n\
485 └──349,175,808 B (42.86%) ── b\n\
486 \n\
487 Other Measurements\n\
488 \n\
489 1,048,576 B ── other1\n\
490 104,857,600 B ── resident\n\
491 \n\
492 End of 3rd\n\
493 2nd\n\
494 Explicit Allocations\n\
495 \n\
496 1,048,576,000 B (100.0%) -- explicit\n\
497 ├────523,239,424 B (49.90%) ── a/b/c [3]\n\
498 ├────209,715,200 B (20.00%) ── compartment(compartment-url)\n\
499 ├────209,715,200 B (20.00%) ── flip/the/backslashes\n\
500 └────105,906,176 B (10.10%) ── heap-unclassified\n\
501 \n\
502 Other Measurements\n\
503 \n\
504 1,048,576,000 B ── heap-allocated\n\
505 104,857,600 B ── heap-unallocated\n\
506 698,351,616 B ── other0\n\
507 116,391,936 B ── other1\n\
508 \n\
509 End of 2nd\n\
510 5th\n\
511 \n\
512 WARNING: the following values are negative or unreasonably large.\n\
513 \n\
514 explicit/a/neg2\n\
515 explicit/a/neg1\n\
516 explicit/b/c\n\
517 explicit/b/c/d\n\
518 explicit/b/c/d/f \n\
519 \n\
520 This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
521 Explicit Allocations\n\
522 \n\
523 104,801,280 B (100.0%) -- explicit\n\
524 ├──103,809,024 B (99.05%) ── big\n\
525 ├────1,007,616 B (00.96%) ── heap-unclassified\n\
526 ├───────10,240 B (00.01%) -- a\n\
527 │ ├──40,960 B (00.04%) ── pos\n\
528 │ ├──-10,240 B (-0.01%) ── neg2 [?!]\n\
529 │ └──-20,480 B (-0.02%) ── neg1 [?!]\n\
530 └──────-25,600 B (-0.02%) -- b/c [?!]\n\
531 ├───10,240 B (00.01%) ── g/h\n\
532 ├────5,120 B (00.00%) ── i/j\n\
533 └──-40,960 B (-0.04%) -- d [?!]\n\
534 ├───20,480 B (00.02%) ── e\n\
535 └──-61,440 B (-0.06%) ── f [?!]\n\
536 \n\
537 Other Measurements\n\
538 \n\
539 104,857,600 B ── heap-allocated\n\
540 \n\
541 End of 5th\n\
542 ";
543
544 function finish()
545 {
546 mgr.unblockRegistrationAndRestoreOriginalReporters();
547 SimpleTest.finish();
548 }
549
550 // Cut+paste the entire page and check that the cut text matches what we
551 // expect. This tests the output in general and also that the cutting and
552 // pasting works as expected.
553 function test(aFrameId, aVerbose, aExpected, aNext) {
554 SimpleTest.executeSoon(function() {
555 ok(document.title === "about:memory", "document.title is correct");
556 let mostRecentActual;
557 let frame = document.getElementById(aFrameId);
558 frame.focus();
559
560 // Set the verbose checkbox value and click the go button.
561 let doc = frame.contentWindow.document;
562 let measureButton = doc.getElementById("measureButton");
563 let verbose = doc.getElementById("verbose");
564 verbose.checked = aVerbose;
565 measureButton.click();
566
567 SimpleTest.waitForClipboard(
568 function(aActual) {
569 mostRecentActual = aActual;
570 return aActual === aExpected;
571 },
572 function() {
573 synthesizeKey("A", {accelKey: true});
574 synthesizeKey("C", {accelKey: true});
575 },
576 aNext,
577 function() {
578 ok(false, "pasted text doesn't match for " + aFrameId);
579 dump("******EXPECTED******\n");
580 dump("<<<" + aExpected + ">>>\n");
581 dump("*******ACTUAL*******\n");
582 dump("<<<" + mostRecentActual + ">>>\n");
583 dump("********************\n");
584 finish();
585 }
586 );
587 });
588 }
589
590 SimpleTest.waitForFocus(function() {
591 test(
592 "amFrame",
593 /* verbose = */ false,
594 amExpectedText,
595 function() {
596 test(
597 "amvFrame",
598 /* verbose = */ true,
599 amvExpectedText,
600 function() {
601 finish()
602 }
603 )
604 }
605 );
606 });
607 SimpleTest.waitForExplicitFinish();
608 ]]>
609 </script>
610 </window>

mercurial