Bug 702300 (part 3) - Tweak the about:memory tests. r=jlebar.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 16 Feb 2012 22:10:39 -0800
changeset 87259 397de2686f8890896a525d7e0f8e4cbb98ffe839
parent 87258 49bae78a33a79c03928903a2d4c9db0dbec91191
child 87260 0642fc24dacb237b4547a2033c2fcc70da3ae464
push id22103
push userbmo@edmorley.co.uk
push dateTue, 21 Feb 2012 12:01:45 +0000
treeherdermozilla-central@4038ffaa5d82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs702300
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 702300 (part 3) - Tweak the about:memory tests. r=jlebar.
toolkit/components/aboutmemory/tests/test_aboutmemory.xul
toolkit/components/aboutmemory/tests/test_aboutmemory2.xul
--- a/toolkit/components/aboutmemory/tests/test_aboutmemory.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutmemory.xul
@@ -88,43 +88,49 @@
     f("", "explicit/g/a",       HEAP,      6 * MB),
     f("", "explicit/g/b",       HEAP,      5 * MB),
     f("", "explicit/g/other",   HEAP,      4 * MB),
     f("", "other1",             OTHER,   111 * MB),
     f2("", "other4",            OTHER,   COUNT_CUMULATIVE, 888)
   ];
   let fakeMultiReporters = [
     { name: "fake1",
-      collectReports: function(cbObj, closure) {
-        function f(p, k, u, a) { cbObj.callback("", p, k, u, a, "(desc)", closure); }
+      collectReports: function(aCbObj, aClosure) {
+        function f(aP, aK, aU, aA) {
+          aCbObj.callback("", aP, aK, aU, aA, "(desc)", aClosure);
+        }
         f("explicit/c/d",     NONHEAP, BYTES,  13 * MB),
         f("explicit/c/d",     NONHEAP, BYTES,  10 * MB), // dup
         f("explicit/c/other", NONHEAP, BYTES,  77 * MB),
         f("explicit/cc",      NONHEAP, BYTES,  13 * MB);
         f("explicit/cc",      NONHEAP, BYTES,  10 * MB); // dup
         f("explicit/d",       NONHEAP, BYTES, 499 * KB); // omitted
         f("explicit/e",       NONHEAP, BYTES, 100 * KB); // omitted
         f("explicit/f/g/h/i", HEAP,    BYTES,  20 * MB);
       },
       explicitNonHeap: (100 + 13 + 10)*MB + (499 + 100)*KB
     },
     { name: "fake2",
-      collectReports: function(cbObj, closure) {
-        function f(p, k, u, a) { cbObj.callback("", p, k, u, a, "(desc)", closure); }
+      collectReports: function(aCbObj, aClosure) {
+        function f(aP, aK, aU, aA) {
+          aCbObj.callback("", aP, aK, aU, aA, "(desc)", aClosure);
+        }
         f("other3",           OTHER,   COUNT, 777);
         f("other2",           OTHER,   BYTES, 222 * MB);
         f("perc2",            OTHER,   PERCENTAGE, 10000);
         f("perc1",            OTHER,   PERCENTAGE, 4567);
       },
       explicitNonHeap: 0
     },
     { name: "smaps",
-      collectReports: function(cbObj, closure) {
+      collectReports: function(aCbObj, aClosure) {
         // The amounts are given in pages, so multiply here by 4kb.
-        function f(p, a) { cbObj.callback("", p, NONHEAP, BYTES, a * 4 * KB, "(desc)", closure); }
+        function f(aP, aA) {
+          aCbObj.callback("", aP, NONHEAP, BYTES, aA * 4 * KB, "(desc)", aClosure);
+        }
         f("smaps/vsize/a",     24);
         f("smaps/swap/a",       1);
         f("smaps/swap/a",       2);
         f("smaps/vsize/a",      19);
         f("smaps/swap/b/c",     10);
         f("smaps/resident/a",   42);
         f("smaps/pss/a",        43);
       },
@@ -205,21 +211,23 @@
     f("5th", "explicit/b/c/g/h", NONHEAP,  10 * KB),
     f("5th", "explicit/b/c/i/j", NONHEAP,   5 * KB)
   ];
   let fakeMultiReporters2 = [
     // Because this multi-reporter is in a child process, the fact that we
     // skip the "smaps" multi-reporter in the parent process won't cause
     // these to be skipped;  the fall-back skipping will be hit instead.
     { name: "smaps",
-      collectReports: function(cbObj, closure) {
+      collectReports: function(aCbObj, aClosure) {
         // The amounts are given in pages, so multiply here by 4kb.
-        function f(p, a) { cbObj.callback("2nd", p, NONHEAP, BYTES, a * 4 * KB, "(desc)", closure); }
-        f("smaps/vsize/a",     24);
-        f("smaps/vsize/b",     24);
+        function f(aP, aA) {
+          aCbObj.callback("2nd", aP, NONHEAP, BYTES, aA * 4 * KB, "(desc)", aClosure);
+        }
+        f("smaps/vsize/a", 24);
+        f("smaps/vsize/b", 24);
       },
       explicitNonHeap: 0
     }
   ];
   for (let i = 0; i < fakeReporters2.length; i++) {
     mgr.registerReporter(fakeReporters2[i]);
   }
   for (let i = 0; i < fakeMultiReporters2.length; i++) {
@@ -549,55 +557,47 @@ 104,857,600 B ── heap-allocated\n\
       mgr.registerReporter(realReporters[i]);
     }
     for (let i = 0; i < realMultiReporters.length; i++) {
       mgr.registerMultiReporter(realMultiReporters[i]);
     }
     SimpleTest.finish();
   }
 
-  let gHaveDumped = false;
-
-  function checkClipboard(actual, expected) {
-    if (actual != expected) {
-      if (!gHaveDumped) {
-        dump("******EXPECTED******\n");
-        dump(expected);
-        dump("*******ACTUAL*******\n");
-        dump(actual);
-        dump("********************\n");
-        gHaveDumped = true;
-      }
-      return false;
-    }
-    return true;
-  }
-
   // 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) {
+  function test(aFrame, aExpected, aNext) {
     SimpleTest.executeSoon(function() {
+      let mostRecentActual;
       document.getElementById(aFrame).focus();
       SimpleTest.waitForClipboard(
-        function(actual) { return checkClipboard(actual, aExpectedText) },
+        function(aActual) {
+          mostRecentActual = aActual;
+          return aActual === aExpected;
+        },
         function() {
           synthesizeKey("A", {accelKey: true});
           synthesizeKey("C", {accelKey: true});
         },
         aNext,
         function() {
           ok(false, "pasted text doesn't match for " + aFrame);
+          dump("******EXPECTED******\n");
+          dump(aExpected);
+          dump("*******ACTUAL*******\n");
+          dump(mostRecentActual);
+          dump("********************\n");
           finish();
         }
       );
     });
   }
 
-  addLoadEvent(function() {
+  SimpleTest.waitForFocus(function() {
     test(
       "amFrame",
       amExpectedText,
       function() {
         test(
           "amvFrame",
           amvExpectedText,
           function() {
--- a/toolkit/components/aboutmemory/tests/test_aboutmemory2.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutmemory2.xul
@@ -87,69 +87,61 @@
       mgr.registerReporter(realReporters[i]);
     }
     for (let i = 0; i < realMultiReporters.length; i++) {
       mgr.registerMultiReporter(realMultiReporters[i]);
     }
     SimpleTest.finish();
   }
 
-  let gHaveDumped = false;
-
-  function checkClipboard(actual, expected) {
-    if (actual != expected) {
-      if (!gHaveDumped) {
-        dump("******EXPECTED******\n");
-        dump(expected);
-        dump("*******ACTUAL*******\n");
-        dump(actual);
-        dump("********************\n");
-        gHaveDumped = true;
-      }
-      return false;
-    }
-    return true;
-  }
-
   // Click on the identified element, then cut+paste the entire page and
   // check that the cut text matches what we expect.
-  function test(aId, aExpectedText, aNext) {
+  function test(aId, aExpected, aNext) {
     let win = document.getElementById("amFrame").contentWindow;
     let node = win.document.getElementById(aId);
 
     // Yuk:  clicking a button is easy;  but for tree entries we need to
     // click on a child of the span identified via |id|.
     if (node.nodeName === "button") {
       node.click();
     } else {
       node.childNodes[0].click();
     }
 
     SimpleTest.executeSoon(function() {
+      let mostRecentActual;
       document.getElementById("amFrame").focus();
       SimpleTest.waitForClipboard(
-        function(actual) { return checkClipboard(actual, aExpectedText) },
+        function(aActual) {
+          mostRecentActual = aActual;
+          return aActual === aExpected;
+        },
         function() {
           synthesizeKey("A", {accelKey: true});
           synthesizeKey("C", {accelKey: true});
         },
         aNext,
         function() {
           ok(false, "pasted text doesn't match");
+          dump("******EXPECTED******\n");
+          dump(aExpected);
+          dump("*******ACTUAL*******\n");
+          dump(mostRecentActual);
+          dump("********************\n");
           finish();
         }
       );
     });
   }
 
   // Returns a function that chains together one test() call per id.
-  function chain(ids) {
-    let x = ids.shift();
+  function chain(aIds) {
+    let x = aIds.shift();
     if (x) {
-      return function() { test(x.id, x.expected, chain(ids)); }
+      return function() { test(x.id, x.expected, chain(aIds)); }
     } else {
       return function() { finish(); };
     }
   }
 
   let openExpected =
 "\
 Main Process\n\
@@ -208,14 +200,14 @@ 250.00 MB ── heap-allocated\n\
   let idsToClick = [
     { id: "Main:explicit/a/c", expected: cClosedExpected },
     { id: "Main:explicit/a",   expected: aClosedExpected },
     { id: "updateButton",      expected: aClosedExpected },
     { id: "Main:explicit/a",   expected: cClosedExpected },
     { id: "Main:explicit/a/c", expected: openExpected }
   ];
 
-  addLoadEvent(chain(idsToClick));
+  SimpleTest.waitForFocus(chain(idsToClick));
 
   SimpleTest.waitForExplicitFinish();
   ]]>
   </script>
 </window>