Bug 729018 - Attempt to de-orange test_aboutcompartments.xul. r=jlebar.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 27 Feb 2012 19:56:10 -0800
changeset 87890 32397978a3424fac2c6987cd6d111ebae69da8f3
parent 87889 d913e27b169bf432b3f7d31ddec50903208c885c
child 87891 79099c15533329b832896aae4d3cb5699290b1bd
push id6557
push usernnethercote@mozilla.com
push dateTue, 28 Feb 2012 03:57:48 +0000
treeherdermozilla-inbound@32397978a342 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs729018
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 729018 - Attempt to de-orange test_aboutcompartments.xul. r=jlebar.
toolkit/components/aboutmemory/content/aboutMemory.js
toolkit/components/aboutmemory/tests/test_aboutcompartments.xul
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -1463,18 +1463,22 @@ function appendSectionHeader(aP, aText)
 }
 
 //-----------------------------------------------------------------------------
 // Code specific to about:compartments
 //-----------------------------------------------------------------------------
 
 function onLoadAboutCompartments()
 {
-  // Minimize memory usage before generating the page in an attempt to collect
-  // any dead compartments.
+  // First generate the page, then minimize memory usage to collect any dead
+  // compartments, then update the page.  The first generation step may sound
+  // unnecessary, but it avoids a short delay in showing content when the page
+  // is loaded, which makes test_aboutcompartments.xul more reliable (see bug
+  // 729018 for details).
+  updateAboutCompartments();
   minimizeMemoryUsage3x(
     function() { addChildObserversAndUpdate(updateAboutCompartments); });
 }
 
 /**
  * Top-level function that does the work of generating the page.
  */
 function updateAboutCompartments()
@@ -1505,22 +1509,16 @@ function updateAboutCompartments()
   let a;
   if (gVerbose) {
     let a = appendElementWithText(div1, "a", "option", "Less verbose");
     a.href = "about:compartments";
   } else {
     let a = appendElementWithText(div1, "a", "option", "More verbose");
     a.href = "about:compartments?verbose";
   }
-
-  // Dispatch a "bodygenerated" event to indicate that the DOM has finished
-  // generating.  This is used by tests.
-  let e = document.createEvent("Event");
-  e.initEvent("bodygenerated", false, false);
-  document.dispatchEvent(e);
 }
 
 //---------------------------------------------------------------------------
 
 function Compartment(aUnsafeName, aIsSystemCompartment)
 {
   this._unsafeName          = aUnsafeName;
   this._isSystemCompartment = aIsSystemCompartment;
--- a/toolkit/components/aboutmemory/tests/test_aboutcompartments.xul
+++ b/toolkit/components/aboutmemory/tests/test_aboutcompartments.xul
@@ -174,17 +174,17 @@ child-system-compartment\n\
     SimpleTest.finish();
   }
 
   // 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(aFrameId, aExpected, aNext) {
     let frame = document.getElementById(aFrameId);
-    let handler = function() {
+    SimpleTest.executeSoon(function() {
       frame.focus();
       SimpleTest.waitForClipboard(
         function(aActual) {
           mostRecentActual = aActual;
           return aActual === aExpected;
         },
         function() {
           synthesizeKey("A", {accelKey: true});
@@ -196,21 +196,17 @@ child-system-compartment\n\
           dump("******EXPECTED******\n");
           dump(aExpected);
           dump("*******ACTUAL*******\n");
           dump(mostRecentActual);
           dump("********************\n");
           finish();
         }
       );
-    };
-    // about:compartment dispatches a "bodygenerated" event to the document
-    // when it's finished generating its DOM.  If we don't wait for that we end
-    // up copying an empty page.
-    frame.contentDocument.addEventListener("bodygenerated", handler, false);
+    });
   }
 
   SimpleTest.waitForFocus(function() {
     test(
       "acFrame",
       acExpectedText,
       function() {
         test(