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