Part of Bug 428398, improve stability of bloat tests. r=bienvenu
authorMark Banner <bugzilla@standard8.plus.com>
Wed, 29 Oct 2008 14:21:21 +0000
changeset 763 a55e8ebd7ec65fcce70566fb74b248789a339a2c
parent 762 2086f5b7fb2a1adaf7cc0c159c74d6307dee908d
child 764 d00fb8da1b025d4b13f48efaf0d929d951107416
push idunknown
push userunknown
push dateunknown
reviewersbienvenu
bugs428398
Part of Bug 428398, improve stability of bloat tests. r=bienvenu
mailnews/test/performance/bloat/bloatComposeOverlay.js
mailnews/test/performance/bloat/bloatMainOverlay.js
--- a/mailnews/test/performance/bloat/bloatComposeOverlay.js
+++ b/mailnews/test/performance/bloat/bloatComposeOverlay.js
@@ -50,14 +50,14 @@ function startComposeTest()
   // load gets called before we've finished displaying/really loading, so we
   // have to have a bit of a timeout to allow it to get to that stage.
   gCurrentTimeout = setTimeout(handleComposeTest, kComposeStartup);
 }
 
 function handleComposeTest()
 {
   // Call the correct close compose window function, this also skips the
-  // are you sure you want to close it prompt.
+  // are you sure you want to close it prompt (bug 321783).
   MsgComposeCloseWindow(true);
 }
 
 // Add the startBloatTest call to the load event for the window.
 addEventListener("load", startComposeTest, false);
--- a/mailnews/test/performance/bloat/bloatMainOverlay.js
+++ b/mailnews/test/performance/bloat/bloatMainOverlay.js
@@ -43,33 +43,45 @@ const kMailStartup = 4000;
 // The other two windows (compose + addrbook) are closed after 3 seconds,
 // well close after 8 to allow a little extra time - if they get delayed, then
 // well get a prompt for closing the compose window that we don't want.
 // See bug 321783.
 const kMailClose = 8000;
 
 const kMailWaitTotal = kMailStartup + kMailClose;
 
-var gCurrentTimeout;
-
 function startMainTest()
 {
   removeEventListener("load", startMainTest, false);
 
-  gCurrentTimeout = setTimeout(shutdownMainWindow, kMailWaitTotal);
+  setTimeout(shutdownMainWindow, kMailWaitTotal);
 
   // First thing to do is to start the address book and compose windows
   toOpenWindowByType("mail:addressbook",
                      "chrome://messenger/content/addressbook/addressbook.xul");
 
   startComposeWindow();
 }
 
 function shutdownMainWindow()
 {
+  var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+                     .getService(Components.interfaces.nsIWindowMediator);
+
+  var window = wm.getMostRecentWindow("msgcompose");
+
+  // Double-check because of bug 321783
+  if (window)
+  {
+    // It hasn't shutdown yet, reset the timeout
+    dump("XXX Trying to quit too early, delaying shutdown to stop bug 321783 affecting us\n");
+    setTimeout(shutdownMainWindow, kMailWaitTotal);
+    return;
+  }
+
   goQuitApplication();
 }
 
 function startComposeWindow()
 {
   var msgComposeService =
     Components.classes["@mozilla.org/messengercompose;1"]
               .getService(Components.interfaces.nsIMsgComposeService);