Bug 893222 - Part 4: Tests. r=njn
☠☠ backed out by e9806317bc14 ☠ ☠
authorJustin Lebar <justin.lebar@gmail.com>
Fri, 02 Aug 2013 10:02:40 -0700
changeset 153449 ea8b6ba99c0586cb55d3896ef8a10d21dc5580f3
parent 153448 ac8220cb61d512157512384b2e78deeae3abc8a4
child 153450 4b0bf28abdf2122701f105b1adbd1f717f171fa0
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs893222
milestone25.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 893222 - Part 4: Tests. r=njn
toolkit/components/aboutmemory/tests/test_memoryReporters.xul
--- a/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
+++ b/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
@@ -47,16 +47,36 @@
 
   let areJsNonWindowCompartmentsPresent = false;
   let areWindowObjectsJsCompartmentsPresent = false;
   let isSandboxLocationShown = false;
   let isPlacesPresent = false;
   let isImagesPresent = false;
   let isXptiWorkingSetPresent = false;
   let isAtomTablePresent = false;
+  let isBigStringPresent = false;
+  let isSmallString1Present = false;
+  let isSmallString2Present = false;
+
+  // Generate a long, random string.  We'll check that this string is
+  // reported in at least one of the memory reporters.
+  let bigString = "";
+  while (bigString.length < 10000) {
+    bigString += Math.random();
+  }
+  let bigStringPrefix = bigString.substring(0, 100);
+
+  // Generate many copies of two distinctive short strings, "!)(*&" and
+  // "@)(*&".  We'll check that these strings are reported in at least
+  // one of the memory reporters.
+  let shortStrings = [];
+  for (let i = 0; i < 10000; i++) {
+    let str = (Math.random() > 0.5 ? "!" : "@") + ")(*&";
+    shortStrings.push(str);
+  }
 
   let mySandbox = Components.utils.Sandbox(document.nodePrincipal,
                     { sandboxName: "this-is-a-sandbox-name" });
 
   function handleReport(aProcess, aPath, aKind, aUnits, aAmount, aDescription)
   {
     // Record the values of some notable reporters.
     if (aPath === "vsize") {
@@ -82,16 +102,22 @@
     } else if (aPath.search(/^explicit\/xpti-working-set$/) >= 0) {
       isXptiWorkingSetPresent = true;
     } else if (aPath.search(/^explicit\/atom-tables$/) >= 0) {
       isAtomTablePresent = true;
     } else if (/\[System Principal\].*this-is-a-sandbox-name/.test(aPath)) {
       // A system compartment with a location (such as a sandbox) should
       // show that location.
       isSandboxLocationShown = true;
+    } else if (aPath.contains(bigStringPrefix)) {
+      isBigStringPresent = true;
+    } else if (aPath.contains("!)(*&")) {
+      isSmallString1Present = true;
+    } else if (aPath.contains("@)(*&")) {
+      isSmallString2Present = true;
     }
   }
 
   let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
             getService(Ci.nsIMemoryReporterManager);
 
   // Access mgr.explicit and mgr.resident just to make sure they don't crash.
   // We can't check their actual values because they're non-deterministic.
@@ -143,13 +169,16 @@
 
   ok(areJsNonWindowCompartmentsPresent,     "js-non-window compartments are present");
   ok(areWindowObjectsJsCompartmentsPresent, "window-objects/.../js compartments are present");
   ok(isSandboxLocationShown,                "sandbox locations are present");
   ok(isPlacesPresent,                       "places is present");
   ok(isImagesPresent,                       "images is present");
   ok(isXptiWorkingSetPresent,               "xpti-working-set is present");
   ok(isAtomTablePresent,                    "atom-table is present");
+  ok(isBigStringPresent,                    "large string is present");
+  ok(isSmallString1Present,                 "small string 1 is present");
+  ok(isSmallString2Present,                 "small string 2 is present");
 
   ]]>
   </script>
 </window>