toolkit/components/aboutmemory/tests/test_aboutmemory.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,610 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
     1.6 +<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
     1.7 +<window title="about:memory"
     1.8 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
     1.9 +  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    1.10 +  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    1.11 +
    1.12 +  <!-- This file uses fake memory reporters to test the presentation of memory
    1.13 +       reports in about:memory.  test_memoryReporters.xul uses the real
    1.14 +       memory reporters to test whether the memory reporters are producing
    1.15 +       sensible results. -->
    1.16 +
    1.17 +  <!-- test results are displayed in the html:body -->
    1.18 +  <body xmlns="http://www.w3.org/1999/xhtml"></body>
    1.19 +
    1.20 +  <!-- test code goes here -->
    1.21 +  <script type="application/javascript">
    1.22 +  <![CDATA[
    1.23 +  "use strict";
    1.24 +
    1.25 +  SimpleTest.expectAssertions(27);
    1.26 +
    1.27 +  const Cc = Components.classes;
    1.28 +  const Ci = Components.interfaces;
    1.29 +  const Cr = Components.results;
    1.30 +  let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
    1.31 +            getService(Ci.nsIMemoryReporterManager);
    1.32 +
    1.33 +  // Hide all the real reporters;  we'll restore them at the end.
    1.34 +  mgr.blockRegistrationAndHideExistingReporters();
    1.35 +
    1.36 +  // Setup various fake-but-deterministic reporters.
    1.37 +  const KB = 1024;
    1.38 +  const MB = KB * KB;
    1.39 +  const NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP;
    1.40 +  const HEAP    = Ci.nsIMemoryReporter.KIND_HEAP;
    1.41 +  const OTHER   = Ci.nsIMemoryReporter.KIND_OTHER;
    1.42 +
    1.43 +  const BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
    1.44 +  const COUNT = Ci.nsIMemoryReporter.UNITS_COUNT;
    1.45 +  const COUNT_CUMULATIVE = Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE;
    1.46 +  const PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
    1.47 +
    1.48 +  let fakeReporters = [
    1.49 +    { collectReports: function(aCbObj, aClosure) {
    1.50 +        function f(aP, aK, aU, aA) {
    1.51 +          aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
    1.52 +        }
    1.53 +        f("heap-allocated",     OTHER,   BYTES, 500 * MB);
    1.54 +        f("heap-unallocated",   OTHER,   BYTES, 100 * MB);
    1.55 +        f("explicit/a",         HEAP,    BYTES, 222 * MB);
    1.56 +        f("explicit/b/a",       HEAP,    BYTES,  85 * MB);
    1.57 +        f("explicit/b/b",       HEAP,    BYTES,  75 * MB);
    1.58 +        f("explicit/b/c/a",     HEAP,    BYTES,  70 * MB);
    1.59 +        f("explicit/b/c/b",     HEAP,    BYTES,   2 * MB); // omitted
    1.60 +        f("explicit/g/a",       HEAP,    BYTES,   6 * MB);
    1.61 +        f("explicit/g/b",       HEAP,    BYTES,   5 * MB);
    1.62 +        f("explicit/g/other",   HEAP,    BYTES,   4 * MB);
    1.63 +        // A degenerate tree with the same name as a non-degenerate tree should
    1.64 +        // work ok.
    1.65 +        f("explicit",           OTHER,   BYTES, 888 * MB);
    1.66 +        f("other1/a/b",         OTHER,   BYTES, 111 * MB);
    1.67 +        f("other1/c/d",         OTHER,   BYTES,  22 * MB);
    1.68 +        f("other1/c/e",         OTHER,   BYTES,  33 * MB);
    1.69 +        f("other4",             OTHER,   COUNT_CUMULATIVE, 777);
    1.70 +        f("other4",             OTHER,   COUNT_CUMULATIVE, 111);
    1.71 +        f("other3/a/b/c/d/e",   OTHER,   PERCENTAGE, 2000);
    1.72 +        f("other3/a/b/c/d/f",   OTHER,   PERCENTAGE, 10);
    1.73 +        f("other3/a/b/c/d/g",   OTHER,   PERCENTAGE, 5);
    1.74 +        f("other3/a/b/c/d/g",   OTHER,   PERCENTAGE, 5);
    1.75 +        // Check that a rounded-up-to-100.00% value is shown as "100.0%" (i.e. one
    1.76 +        // decimal point).
    1.77 +        f("other6/big",         OTHER,   COUNT, 99999);
    1.78 +        f("other6/small",       OTHER,   COUNT, 1);
    1.79 +        // Check that a 0 / 0 is handled correctly.
    1.80 +        f("other7/zero",        OTHER,   BYTES, 0);
    1.81 +        // These compartments ones shouldn't be displayed.
    1.82 +        f("compartments/user/foo",   OTHER, COUNT, 1);
    1.83 +        f("compartments/system/foo", OTHER, COUNT, 1);
    1.84 +      }
    1.85 +    },
    1.86 +    { collectReports: function(aCbObj, aClosure) {
    1.87 +        function f(aP, aK, aU, aA) {
    1.88 +          aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
    1.89 +        }
    1.90 +        f("explicit/c/d",     NONHEAP, BYTES,  13 * MB);
    1.91 +        f("explicit/c/d",     NONHEAP, BYTES,  10 * MB); // dup
    1.92 +        f("explicit/c/other", NONHEAP, BYTES,  77 * MB);
    1.93 +        f("explicit/cc",      NONHEAP, BYTES,  13 * MB);
    1.94 +        f("explicit/cc",      NONHEAP, BYTES,  10 * MB); // dup
    1.95 +        f("explicit/d",       NONHEAP, BYTES, 499 * KB); // omitted
    1.96 +        f("explicit/e",       NONHEAP, BYTES, 100 * KB); // omitted
    1.97 +        f("explicit/f/g/h/i", HEAP,    BYTES,  10 * MB);
    1.98 +        f("explicit/f/g/h/j", HEAP,    BYTES,  10 * MB);
    1.99 +      }
   1.100 +    },
   1.101 +    { collectReports: function(aCbObj, aClosure) {
   1.102 +        function f(aP, aK, aU, aA) {
   1.103 +          aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
   1.104 +        }
   1.105 +        f("other3",           OTHER,   COUNT, 777);
   1.106 +        f("other2",           OTHER,   BYTES, 222 * MB);
   1.107 +        f("perc2",            OTHER,   PERCENTAGE, 10000);
   1.108 +        f("perc1",            OTHER,   PERCENTAGE, 4567);
   1.109 +        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);
   1.110 +      }
   1.111 +    },
   1.112 +    { collectReports: function(aCbObj, aClosure) {
   1.113 +        function f(aP) {
   1.114 +          aCbObj.callback("", aP, OTHER, COUNT, 1, "Desc.", aClosure);
   1.115 +        }
   1.116 +        f("compartments/user/bar");
   1.117 +        f("compartments/system/bar");
   1.118 +      }
   1.119 +    }
   1.120 +  ];
   1.121 +  for (let i = 0; i < fakeReporters.length; i++) {
   1.122 +    mgr.registerStrongReporterEvenIfBlocked(fakeReporters[i]);
   1.123 +  }
   1.124 +
   1.125 +  // mgr.explicit sums "heap-allocated" and all the appropriate NONHEAP ones:
   1.126 +  // - "explicit/c", "explicit/cc" x 2, "explicit/d", "explicit/e"
   1.127 +  // - but *not* "explicit/c/d" x 2
   1.128 +  // Check explicit now before we add the fake reporters for the fake 2nd
   1.129 +  // and subsequent processes.
   1.130 +  //
   1.131 +  // Nb: mgr.explicit will throw NS_ERROR_NOT_AVAILABLE if this is a
   1.132 +  // --enable-trace-malloc build.  Allow for that exception, but *only* that
   1.133 +  // exception.
   1.134 +  try {
   1.135 +    is(mgr.explicit, 500*MB + (100 + 13 + 10)*MB + 599*KB, "mgr.explicit");
   1.136 +  } catch (ex) {
   1.137 +    is(ex.result, Cr.NS_ERROR_NOT_AVAILABLE, "mgr.explicit exception");
   1.138 +  }
   1.139 +
   1.140 +  // The main process always comes first when we display about:memory.  The
   1.141 +  // remaining processes are sorted by their |resident| values (starting with
   1.142 +  // the largest).  Processes without a |resident| memory reporter are saved
   1.143 +  // for the end.
   1.144 +  let fakeReporters2 = [
   1.145 +    { collectReports: function(aCbObj, aClosure) {
   1.146 +        function f(aP1, aP2, aK, aU, aA) {
   1.147 +          aCbObj.callback(aP1, aP2, aK, aU, aA, "Desc.", aClosure);
   1.148 +        }
   1.149 +        f("2nd", "heap-allocated",  OTHER,   BYTES,1000* MB);
   1.150 +        f("2nd", "heap-unallocated",OTHER,   BYTES,100 * MB);
   1.151 +        f("2nd", "explicit/a/b/c",  HEAP,    BYTES,497 * MB);
   1.152 +        f("2nd", "explicit/a/b/c",  HEAP,    BYTES,  1 * MB); // dup: merge
   1.153 +        f("2nd", "explicit/a/b/c",  HEAP,    BYTES,  1 * MB); // dup: merge
   1.154 +        f("2nd", "explicit/flip\\the\\backslashes",
   1.155 +                                    HEAP,    BYTES,200 * MB);
   1.156 +        f("2nd", "explicit/compartment(compartment-url)",
   1.157 +                                    HEAP,    BYTES,200 * MB);
   1.158 +        f("2nd", "other0",          OTHER,   BYTES,666 * MB);
   1.159 +        f("2nd", "other1",          OTHER,   BYTES,111 * MB);
   1.160 +
   1.161 +        // Check that we can handle "heap-allocated" not being present.
   1.162 +        f("3rd", "explicit/a/b",    HEAP,    BYTES,333 * MB);
   1.163 +        f("3rd", "explicit/a/c",    HEAP,    BYTES,444 * MB);
   1.164 +        f("3rd", "other1",          OTHER,   BYTES,  1 * MB);
   1.165 +        f("3rd", "resident",        OTHER,   BYTES,100 * MB);
   1.166 +
   1.167 +        // Invalid values (negative, too-big) should be identified.
   1.168 +        f("4th", "heap-allocated",   OTHER,   BYTES,100 * MB);
   1.169 +        f("4th", "resident",         OTHER,   BYTES,200 * MB);
   1.170 +        f("4th", "explicit/js/compartment(http:\\\\too-big.com\\)/stuff",
   1.171 +                                     HEAP,    BYTES,150 * MB);
   1.172 +        f("4th", "explicit/ok",      HEAP,    BYTES,  5 * MB);
   1.173 +        f("4th", "explicit/neg1",    NONHEAP, BYTES, -2 * MB);
   1.174 +        // -111 becomes "-0.00MB" in non-verbose mode, and getting the negative
   1.175 +        // sign in there correctly is non-trivial.
   1.176 +        f("4th",  "other1",          OTHER,   BYTES,-111);
   1.177 +        f("4th",  "other2",          OTHER,   BYTES,-222 * MB);
   1.178 +        f("4th",  "other3",          OTHER,   COUNT, -333);
   1.179 +        f("4th",  "other4",          OTHER,   COUNT_CUMULATIVE, -444);
   1.180 +        f("4th",  "other5",          OTHER,   PERCENTAGE, -555);
   1.181 +        f("4th",  "other6",          OTHER,   PERCENTAGE, 66666);
   1.182 +
   1.183 +        // If a negative value is within a collapsed sub-tree in non-verbose mode,
   1.184 +        // we should get the warning at the top and the relevant sub-trees should
   1.185 +        // be expanded, even in non-verbose mode.
   1.186 +        f("5th", "heap-allocated",   OTHER,   BYTES,100 * MB);
   1.187 +        f("5th", "explicit/big",     HEAP,    BYTES, 99 * MB);
   1.188 +        f("5th", "explicit/a/pos",   HEAP,    BYTES, 40 * KB);
   1.189 +        f("5th", "explicit/a/neg1",  NONHEAP, BYTES,-20 * KB);
   1.190 +        f("5th", "explicit/a/neg2",  NONHEAP, BYTES,-10 * KB);
   1.191 +        f("5th", "explicit/b/c/d/e", NONHEAP, BYTES, 20 * KB);
   1.192 +        f("5th", "explicit/b/c/d/f", NONHEAP, BYTES,-60 * KB);
   1.193 +        f("5th", "explicit/b/c/g/h", NONHEAP, BYTES, 10 * KB);
   1.194 +        f("5th", "explicit/b/c/i/j", NONHEAP, BYTES,  5 * KB);
   1.195 +      }
   1.196 +    }
   1.197 +  ];
   1.198 +  for (let i = 0; i < fakeReporters2.length; i++) {
   1.199 +    mgr.registerStrongReporterEvenIfBlocked(fakeReporters2[i]);
   1.200 +  }
   1.201 +  fakeReporters = fakeReporters.concat(fakeReporters2);
   1.202 +  ]]>
   1.203 +  </script>
   1.204 +
   1.205 +  <iframe id="amFrame"  height="300" src="about:memory"></iframe>
   1.206 +  <!-- vary the capitalization to make sure that works -->
   1.207 +  <iframe id="amvFrame" height="300" src="About:Memory"></iframe>
   1.208 +
   1.209 +  <script type="application/javascript">
   1.210 +  <![CDATA[
   1.211 +  let amExpectedText =
   1.212 +"\
   1.213 +Main Process\n\
   1.214 +Explicit Allocations\n\
   1.215 +\n\
   1.216 +623.58 MB (100.0%) -- explicit\n\
   1.217 +├──232.00 MB (37.20%) -- b\n\
   1.218 +│  ├───85.00 MB (13.63%) ── a\n\
   1.219 +│  ├───75.00 MB (12.03%) ── b\n\
   1.220 +│  └───72.00 MB (11.55%) -- c\n\
   1.221 +│      ├──70.00 MB (11.23%) ── a\n\
   1.222 +│      └───2.00 MB (00.32%) ── b\n\
   1.223 +├──222.00 MB (35.60%) ── a\n\
   1.224 +├──100.00 MB (16.04%) -- c\n\
   1.225 +│  ├───77.00 MB (12.35%) ── other\n\
   1.226 +│  └───23.00 MB (03.69%) ── d [2]\n\
   1.227 +├───23.00 MB (03.69%) ── cc [2]\n\
   1.228 +├───20.00 MB (03.21%) -- f/g/h\n\
   1.229 +│   ├──10.00 MB (01.60%) ── i\n\
   1.230 +│   └──10.00 MB (01.60%) ── j\n\
   1.231 +├───15.00 MB (02.41%) ++ g\n\
   1.232 +├───11.00 MB (01.76%) ── heap-unclassified\n\
   1.233 +└────0.58 MB (00.09%) ++ (2 tiny)\n\
   1.234 +\n\
   1.235 +Other Measurements\n\
   1.236 +\n\
   1.237 +5 (100.0%) -- compartments\n\
   1.238 +├──3 (60.00%) -- user\n\
   1.239 +│  ├──1 (20.00%) ── bar\n\
   1.240 +│  ├──1 (20.00%) ── foo\n\
   1.241 +│  └──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\
   1.242 +└──2 (40.00%) -- system\n\
   1.243 +   ├──1 (20.00%) ── bar\n\
   1.244 +   └──1 (20.00%) ── foo\n\
   1.245 +\n\
   1.246 +166.00 MB (100.0%) -- other1\n\
   1.247 +├──111.00 MB (66.87%) ── a/b\n\
   1.248 +└───55.00 MB (33.13%) -- c\n\
   1.249 +    ├──33.00 MB (19.88%) ── e\n\
   1.250 +    └──22.00 MB (13.25%) ── d\n\
   1.251 +\n\
   1.252 +20.20% (100.0%) -- other3\n\
   1.253 +└──20.20% (100.0%) -- a/b/c/d\n\
   1.254 +   ├──20.00% (99.01%) ── e\n\
   1.255 +   └───0.20% (00.99%) ++ (2 tiny)\n\
   1.256 +\n\
   1.257 +100,000 (100.0%) -- other6\n\
   1.258 +├───99,999 (100.0%) ── big\n\
   1.259 +└────────1 (00.00%) ── small\n\
   1.260 +\n\
   1.261 +0.00 MB (100.0%) -- other7\n\
   1.262 +└──0.00 MB (100.0%) ── zero\n\
   1.263 +\n\
   1.264 +888.00 MB ── explicit\n\
   1.265 +500.00 MB ── heap-allocated\n\
   1.266 +100.00 MB ── heap-unallocated\n\
   1.267 +222.00 MB ── other2\n\
   1.268 +      777 ── other3\n\
   1.269 +      888 ── other4 [2]\n\
   1.270 +   45.67% ── perc1\n\
   1.271 +  100.00% ── perc2\n\
   1.272 +\n\
   1.273 +End of Main Process\n\
   1.274 +4th\n\
   1.275 +\n\
   1.276 +WARNING: the following values are negative or unreasonably large.\n\
   1.277 +\n\
   1.278 +    explicit/js/compartment(http://too-big.com/)/stuff\n\
   1.279 +    explicit/(2 tiny)\n\
   1.280 +    explicit/(2 tiny)/neg1\n\
   1.281 +    explicit/(2 tiny)/heap-unclassified\n\
   1.282 +    other1\n\
   1.283 +    other2\n\
   1.284 +    other3\n\
   1.285 +    other4\n\
   1.286 +    other5 \n\
   1.287 +\n\
   1.288 +This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
   1.289 +Explicit Allocations\n\
   1.290 +\n\
   1.291 +98.00 MB (100.0%) -- explicit\n\
   1.292 +├──150.00 MB (153.06%) ── js/compartment(http://too-big.com/)/stuff [?!]\n\
   1.293 +├───5.00 MB (05.10%) ── ok\n\
   1.294 +└──-57.00 MB (-58.16%) -- (2 tiny) [?!]\n\
   1.295 +   ├───-2.00 MB (-2.04%) ── neg1 [?!]\n\
   1.296 +   └──-55.00 MB (-56.12%) ── heap-unclassified [?!]\n\
   1.297 +\n\
   1.298 +Other Measurements\n\
   1.299 +\n\
   1.300 + 100.00 MB ── heap-allocated\n\
   1.301 +  -0.00 MB ── other1 [?!]\n\
   1.302 +-222.00 MB ── other2 [?!]\n\
   1.303 +      -333 ── other3 [?!]\n\
   1.304 +      -444 ── other4 [?!]\n\
   1.305 +    -5.55% ── other5 [?!]\n\
   1.306 +   666.66% ── other6\n\
   1.307 + 200.00 MB ── resident\n\
   1.308 +\n\
   1.309 +End of 4th\n\
   1.310 +3rd\n\
   1.311 +\n\
   1.312 +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\
   1.313 +Explicit Allocations\n\
   1.314 +\n\
   1.315 +777.00 MB (100.0%) -- explicit\n\
   1.316 +└──777.00 MB (100.0%) -- a\n\
   1.317 +   ├──444.00 MB (57.14%) ── c\n\
   1.318 +   └──333.00 MB (42.86%) ── b\n\
   1.319 +\n\
   1.320 +Other Measurements\n\
   1.321 +\n\
   1.322 +  1.00 MB ── other1\n\
   1.323 +100.00 MB ── resident\n\
   1.324 +\n\
   1.325 +End of 3rd\n\
   1.326 +2nd\n\
   1.327 +Explicit Allocations\n\
   1.328 +\n\
   1.329 +1,000.00 MB (100.0%) -- explicit\n\
   1.330 +├────499.00 MB (49.90%) ── a/b/c [3]\n\
   1.331 +├────200.00 MB (20.00%) ── compartment(compartment-url)\n\
   1.332 +├────200.00 MB (20.00%) ── flip/the/backslashes\n\
   1.333 +└────101.00 MB (10.10%) ── heap-unclassified\n\
   1.334 +\n\
   1.335 +Other Measurements\n\
   1.336 +\n\
   1.337 +1,000.00 MB ── heap-allocated\n\
   1.338 +  100.00 MB ── heap-unallocated\n\
   1.339 +  666.00 MB ── other0\n\
   1.340 +  111.00 MB ── other1\n\
   1.341 +\n\
   1.342 +End of 2nd\n\
   1.343 +5th\n\
   1.344 +\n\
   1.345 +WARNING: the following values are negative or unreasonably large.\n\
   1.346 +\n\
   1.347 +    explicit/(3 tiny)/a/neg2\n\
   1.348 +    explicit/(3 tiny)/a/neg1\n\
   1.349 +    explicit/(3 tiny)/b/c\n\
   1.350 +    explicit/(3 tiny)/b/c/d\n\
   1.351 +    explicit/(3 tiny)/b/c/d/f \n\
   1.352 +\n\
   1.353 +This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
   1.354 +Explicit Allocations\n\
   1.355 +\n\
   1.356 +99.95 MB (100.0%) -- explicit\n\
   1.357 +├──99.00 MB (99.05%) ── big\n\
   1.358 +└───0.95 MB (00.95%) -- (3 tiny)\n\
   1.359 +    ├──0.96 MB (00.96%) ── heap-unclassified\n\
   1.360 +    ├──0.01 MB (00.01%) -- a\n\
   1.361 +    │  ├──0.04 MB (00.04%) ── pos\n\
   1.362 +    │  ├──-0.01 MB (-0.01%) ── neg2 [?!]\n\
   1.363 +    │  └──-0.02 MB (-0.02%) ── neg1 [?!]\n\
   1.364 +    └──-0.02 MB (-0.02%) -- b/c [?!]\n\
   1.365 +       ├───0.01 MB (00.01%) ── g/h\n\
   1.366 +       ├───0.00 MB (00.00%) ── i/j\n\
   1.367 +       └──-0.04 MB (-0.04%) -- d [?!]\n\
   1.368 +          ├───0.02 MB (00.02%) ── e\n\
   1.369 +          └──-0.06 MB (-0.06%) ── f [?!]\n\
   1.370 +\n\
   1.371 +Other Measurements\n\
   1.372 +\n\
   1.373 +100.00 MB ── heap-allocated\n\
   1.374 +\n\
   1.375 +End of 5th\n\
   1.376 +";
   1.377 +
   1.378 +  let amvExpectedText =
   1.379 +"\
   1.380 +Main Process\n\
   1.381 +Explicit Allocations\n\
   1.382 +\n\
   1.383 +653,876,224 B (100.0%) -- explicit\n\
   1.384 +├──243,269,632 B (37.20%) -- b\n\
   1.385 +│  ├───89,128,960 B (13.63%) ── a\n\
   1.386 +│  ├───78,643,200 B (12.03%) ── b\n\
   1.387 +│  └───75,497,472 B (11.55%) -- c\n\
   1.388 +│      ├──73,400,320 B (11.23%) ── a\n\
   1.389 +│      └───2,097,152 B (00.32%) ── b\n\
   1.390 +├──232,783,872 B (35.60%) ── a\n\
   1.391 +├──104,857,600 B (16.04%) -- c\n\
   1.392 +│  ├───80,740,352 B (12.35%) ── other\n\
   1.393 +│  └───24,117,248 B (03.69%) ── d [2]\n\
   1.394 +├───24,117,248 B (03.69%) ── cc [2]\n\
   1.395 +├───20,971,520 B (03.21%) -- f/g/h\n\
   1.396 +│   ├──10,485,760 B (01.60%) ── i\n\
   1.397 +│   └──10,485,760 B (01.60%) ── j\n\
   1.398 +├───15,728,640 B (02.41%) -- g\n\
   1.399 +│   ├───6,291,456 B (00.96%) ── a\n\
   1.400 +│   ├───5,242,880 B (00.80%) ── b\n\
   1.401 +│   └───4,194,304 B (00.64%) ── other\n\
   1.402 +├───11,534,336 B (01.76%) ── heap-unclassified\n\
   1.403 +├──────510,976 B (00.08%) ── d\n\
   1.404 +└──────102,400 B (00.02%) ── e\n\
   1.405 +\n\
   1.406 +Other Measurements\n\
   1.407 +\n\
   1.408 +5 (100.0%) -- compartments\n\
   1.409 +├──3 (60.00%) -- user\n\
   1.410 +│  ├──1 (20.00%) ── bar\n\
   1.411 +│  ├──1 (20.00%) ── foo\n\
   1.412 +│  └──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\
   1.413 +└──2 (40.00%) -- system\n\
   1.414 +   ├──1 (20.00%) ── bar\n\
   1.415 +   └──1 (20.00%) ── foo\n\
   1.416 +\n\
   1.417 +174,063,616 B (100.0%) -- other1\n\
   1.418 +├──116,391,936 B (66.87%) ── a/b\n\
   1.419 +└───57,671,680 B (33.13%) -- c\n\
   1.420 +    ├──34,603,008 B (19.88%) ── e\n\
   1.421 +    └──23,068,672 B (13.25%) ── d\n\
   1.422 +\n\
   1.423 +20.20% (100.0%) -- other3\n\
   1.424 +└──20.20% (100.0%) -- a/b/c/d\n\
   1.425 +   ├──20.00% (99.01%) ── e\n\
   1.426 +   ├───0.10% (00.50%) ── f\n\
   1.427 +   └───0.10% (00.50%) ── g [2]\n\
   1.428 +\n\
   1.429 +100,000 (100.0%) -- other6\n\
   1.430 +├───99,999 (100.0%) ── big\n\
   1.431 +└────────1 (00.00%) ── small\n\
   1.432 +\n\
   1.433 +0 B (100.0%) -- other7\n\
   1.434 +└──0 B (100.0%) ── zero\n\
   1.435 +\n\
   1.436 +931,135,488 B ── explicit\n\
   1.437 +524,288,000 B ── heap-allocated\n\
   1.438 +104,857,600 B ── heap-unallocated\n\
   1.439 +232,783,872 B ── other2\n\
   1.440 +          777 ── other3\n\
   1.441 +          888 ── other4 [2]\n\
   1.442 +       45.67% ── perc1\n\
   1.443 +      100.00% ── perc2\n\
   1.444 +\n\
   1.445 +End of Main Process\n\
   1.446 +4th\n\
   1.447 +\n\
   1.448 +WARNING: the following values are negative or unreasonably large.\n\
   1.449 +\n\
   1.450 +    explicit/js/compartment(http://too-big.com/)/stuff\n\
   1.451 +    explicit/neg1\n\
   1.452 +    explicit/heap-unclassified\n\
   1.453 +    other1\n\
   1.454 +    other2\n\
   1.455 +    other3\n\
   1.456 +    other4\n\
   1.457 +    other5 \n\
   1.458 +\n\
   1.459 +This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
   1.460 +Explicit Allocations\n\
   1.461 +\n\
   1.462 +102,760,448 B (100.0%) -- explicit\n\
   1.463 +├──157,286,400 B (153.06%) ── js/compartment(http://too-big.com/)/stuff [?!]\n\
   1.464 +├────5,242,880 B (05.10%) ── ok\n\
   1.465 +├───-2,097,152 B (-2.04%) ── neg1 [?!]\n\
   1.466 +└──-57,671,680 B (-56.12%) ── heap-unclassified [?!]\n\
   1.467 +\n\
   1.468 +Other Measurements\n\
   1.469 +\n\
   1.470 + 104,857,600 B ── heap-allocated\n\
   1.471 +        -111 B ── other1 [?!]\n\
   1.472 +-232,783,872 B ── other2 [?!]\n\
   1.473 +          -333 ── other3 [?!]\n\
   1.474 +          -444 ── other4 [?!]\n\
   1.475 +        -5.55% ── other5 [?!]\n\
   1.476 +       666.66% ── other6\n\
   1.477 + 209,715,200 B ── resident\n\
   1.478 +\n\
   1.479 +End of 4th\n\
   1.480 +3rd\n\
   1.481 +\n\
   1.482 +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\
   1.483 +Explicit Allocations\n\
   1.484 +\n\
   1.485 +814,743,552 B (100.0%) -- explicit\n\
   1.486 +└──814,743,552 B (100.0%) -- a\n\
   1.487 +   ├──465,567,744 B (57.14%) ── c\n\
   1.488 +   └──349,175,808 B (42.86%) ── b\n\
   1.489 +\n\
   1.490 +Other Measurements\n\
   1.491 +\n\
   1.492 +  1,048,576 B ── other1\n\
   1.493 +104,857,600 B ── resident\n\
   1.494 +\n\
   1.495 +End of 3rd\n\
   1.496 +2nd\n\
   1.497 +Explicit Allocations\n\
   1.498 +\n\
   1.499 +1,048,576,000 B (100.0%) -- explicit\n\
   1.500 +├────523,239,424 B (49.90%) ── a/b/c [3]\n\
   1.501 +├────209,715,200 B (20.00%) ── compartment(compartment-url)\n\
   1.502 +├────209,715,200 B (20.00%) ── flip/the/backslashes\n\
   1.503 +└────105,906,176 B (10.10%) ── heap-unclassified\n\
   1.504 +\n\
   1.505 +Other Measurements\n\
   1.506 +\n\
   1.507 +1,048,576,000 B ── heap-allocated\n\
   1.508 +  104,857,600 B ── heap-unallocated\n\
   1.509 +  698,351,616 B ── other0\n\
   1.510 +  116,391,936 B ── other1\n\
   1.511 +\n\
   1.512 +End of 2nd\n\
   1.513 +5th\n\
   1.514 +\n\
   1.515 +WARNING: the following values are negative or unreasonably large.\n\
   1.516 +\n\
   1.517 +    explicit/a/neg2\n\
   1.518 +    explicit/a/neg1\n\
   1.519 +    explicit/b/c\n\
   1.520 +    explicit/b/c/d\n\
   1.521 +    explicit/b/c/d/f \n\
   1.522 +\n\
   1.523 +This indicates a defect in one or more memory reporters. The invalid values are highlighted.\n\
   1.524 +Explicit Allocations\n\
   1.525 +\n\
   1.526 +104,801,280 B (100.0%) -- explicit\n\
   1.527 +├──103,809,024 B (99.05%) ── big\n\
   1.528 +├────1,007,616 B (00.96%) ── heap-unclassified\n\
   1.529 +├───────10,240 B (00.01%) -- a\n\
   1.530 +│       ├──40,960 B (00.04%) ── pos\n\
   1.531 +│       ├──-10,240 B (-0.01%) ── neg2 [?!]\n\
   1.532 +│       └──-20,480 B (-0.02%) ── neg1 [?!]\n\
   1.533 +└──────-25,600 B (-0.02%) -- b/c [?!]\n\
   1.534 +       ├───10,240 B (00.01%) ── g/h\n\
   1.535 +       ├────5,120 B (00.00%) ── i/j\n\
   1.536 +       └──-40,960 B (-0.04%) -- d [?!]\n\
   1.537 +          ├───20,480 B (00.02%) ── e\n\
   1.538 +          └──-61,440 B (-0.06%) ── f [?!]\n\
   1.539 +\n\
   1.540 +Other Measurements\n\
   1.541 +\n\
   1.542 +104,857,600 B ── heap-allocated\n\
   1.543 +\n\
   1.544 +End of 5th\n\
   1.545 +";
   1.546 +
   1.547 +  function finish()
   1.548 +  {
   1.549 +    mgr.unblockRegistrationAndRestoreOriginalReporters();
   1.550 +    SimpleTest.finish();
   1.551 +  }
   1.552 +
   1.553 +  // Cut+paste the entire page and check that the cut text matches what we
   1.554 +  // expect.  This tests the output in general and also that the cutting and
   1.555 +  // pasting works as expected.
   1.556 +  function test(aFrameId, aVerbose, aExpected, aNext) {
   1.557 +    SimpleTest.executeSoon(function() {
   1.558 +      ok(document.title === "about:memory", "document.title is correct");
   1.559 +      let mostRecentActual;
   1.560 +      let frame = document.getElementById(aFrameId);
   1.561 +      frame.focus();
   1.562 +
   1.563 +      // Set the verbose checkbox value and click the go button.
   1.564 +      let doc = frame.contentWindow.document;
   1.565 +      let measureButton = doc.getElementById("measureButton");
   1.566 +      let verbose = doc.getElementById("verbose");
   1.567 +      verbose.checked = aVerbose;
   1.568 +      measureButton.click();
   1.569 +
   1.570 +      SimpleTest.waitForClipboard(
   1.571 +        function(aActual) {
   1.572 +          mostRecentActual = aActual;
   1.573 +          return aActual === aExpected;
   1.574 +        },
   1.575 +        function() {
   1.576 +          synthesizeKey("A", {accelKey: true});
   1.577 +          synthesizeKey("C", {accelKey: true});
   1.578 +        },
   1.579 +        aNext,
   1.580 +        function() {
   1.581 +          ok(false, "pasted text doesn't match for " + aFrameId);
   1.582 +          dump("******EXPECTED******\n");
   1.583 +          dump("<<<" + aExpected + ">>>\n");
   1.584 +          dump("*******ACTUAL*******\n");
   1.585 +          dump("<<<" + mostRecentActual + ">>>\n");
   1.586 +          dump("********************\n");
   1.587 +          finish();
   1.588 +        }
   1.589 +      );
   1.590 +    });
   1.591 +  }
   1.592 +
   1.593 +  SimpleTest.waitForFocus(function() {
   1.594 +    test(
   1.595 +      "amFrame",
   1.596 +      /* verbose = */ false,
   1.597 +      amExpectedText,
   1.598 +      function() {
   1.599 +        test(
   1.600 +          "amvFrame",
   1.601 +          /* verbose = */ true,
   1.602 +          amvExpectedText,
   1.603 +          function() {
   1.604 +            finish()
   1.605 +          }
   1.606 +        )
   1.607 +      }
   1.608 +    );
   1.609 +  });
   1.610 +  SimpleTest.waitForExplicitFinish();
   1.611 +  ]]>
   1.612 +  </script>
   1.613 +</window>

mercurial