Bug 723583 - test pilot thunderbird 'all your user studies' shows each more than once. r=squib,a=Standard8
authorGregg Lind <glind@mozilla.com>
Mon, 13 Feb 2012 14:19:01 +0000
changeset 10172 b6fad7040c8eedebf0bb07303fab39435193300c
parent 10171 66d01c6ae24489154dc693e5d18290a4edf985e0
child 10173 1257dccef3801a8b29f12dd1cd07937f6e01cd8e
push idunknown
push userunknown
push dateunknown
reviewerssquib, Standard8
bugs723583
Bug 723583 - test pilot thunderbird 'all your user studies' shows each more than once. r=squib,a=Standard8
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/chrome.manifest
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/components/TestPilot.js
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/browser.js
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/chrome.manifest
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/chrome.manifest
@@ -11,15 +11,14 @@ overlay chrome://browser/content/macBrow
 overlay chrome://browser/content/browser.xul chrome://testpilot/content/browser.xul
 overlay chrome://messenger/content/mailWindowOverlay.xul chrome://testpilot/content/browser.xul
 
 style	chrome://global/content/customizeToolbar.xul	chrome://testpilot/content/browser.css
 # For the menubar on Mac
 overlay chrome://testpilot/content/all-studies-window.xul chrome://browser/content/macBrowserOverlay.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384} os=Darwin
 
 
-# Remove the component for the Fennec version - don't think I need it:
-# component {e6e5e58f-7977-485a-b076-2f74bee2677b} components/TestPilot.js
-# contract @mozilla.org/testpilot/service;1 {e6e5e58f-7977-485a-b076-2f74bee2677b}
-# category profile-after-change testpilot @mozilla.org/testpilot/service;1
+component {e6e5e58f-7977-485a-b076-2f74bee2677b} components/TestPilot.js
+contract @mozilla.org/testpilot/service;1 {e6e5e58f-7977-485a-b076-2f74bee2677b}
+category profile-after-change testpilot @mozilla.org/testpilot/service;1
 
 # For the options on Fennec
 override chrome://testpilot/content/options.xul chrome://testpilot/content/fennec-options.xul application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/components/TestPilot.js
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/components/TestPilot.js
@@ -48,38 +48,42 @@ TestPilotComponent.prototype = {
   classID: Components.ID("{e6e5e58f-7977-485a-b076-2f74bee2677b}"),
   _xpcom_categories: [{ category: "profile-after-change" }],
   _startupTimer: null,
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference]),
 
   observe: function TPC__observe(subject, topic, data) {
+    dump(subject +":" + topic + "\n");
     let os = Cc["@mozilla.org/observer-service;1"].
         getService(Ci.nsIObserverService);
     switch (topic) {
     case "profile-after-change":
-      Services.console.logStringMessage("Test Pilot Component Sessionstore\n");
+      //Services.console.logStringMessage("Test Pilot Component Sessionstore\n");
+      os.addObserver(this, "mail-startup-done", true);
+      dump("added\n");
       os.addObserver(this, "sessionstore-windows-restored", true);
+      dump("added\n");
       break;
     case "sessionstore-windows-restored":
-      Services.console.logStringMessage("Test Pilot Component Restored\n");
+    case "mail-startup-done":
       /* Stop oberver, to ensure that globalStartup doesn't get
        * called more than once. */
-      os.removeObserver(this, "sessionstore-windows-restored", false);
+      os.removeObserver(this, topic, false);
       /* Call global startup on a timer so that it's off of the main
        * thread... delay a few seconds to give firefox time to finish
        * starting up.
        */
       this._startupTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
       this._startupTimer.initWithCallback(
         {notify: function(timer) {
            Cu.import("resource://testpilot/modules/setup.js");
            TestPilotSetup.globalStartup();
-         }}, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
+         }}, 3000, Ci.nsITimer.TYPE_ONE_SHOT);
       break;
     }
   }
 };
 
 const components = [TestPilotComponent];
 var NSGetFactory, NSGetModule;
 if (XPCOMUtils.generateNSGetFactory)
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/browser.js
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/browser.js
@@ -162,42 +162,26 @@ var TestPilotMenuUtils;
       TestPilotUIBuilder.buildCorrectInterface(window);
 
       /* "Hold" window load events for TestPilotSetup, passing them along only
        * after startup is complete.  It's hacky, but the benefit is that
        * TestPilotSetup.onWindowLoad can treat all windows the same no matter
        * whether they opened with Firefox on startup or were opened later. */
 
       if (("TestPilotSetup" in window) && TestPilotSetup.startupComplete) {
-        Services.console.logStringMessage("Startup complete, that's funny.\n");
         TestPilotSetup.onWindowLoad(window);
       } else {
-        Services.console.logStringMessage("Initializing timer.\n");
-        // TODO only want to start this timer ONCE so we need some global state to
-        // remember whether we already started it (only a problem on multi-window systems)
-        // (that's essentially the problem the component solved) deal with this later.
-        window.setTimeout(function() {
-           Services.console.logStringMessage("Timer got called back!.\n");
-             Services.console.logStringMessage("Impoting setup");
-             Cu.import("resource://testpilot/modules/setup.js");
-             Services.console.logStringMessage("globally globalStartuping");
-             TestPilotSetup.globalStartup();
-             Services.console.logStringMessage("Did it.");
-        }, 10000);
-        Services.console.logStringMessage("Timer made.\n");
-
         let observerSvc = Cc["@mozilla.org/observer-service;1"]
                              .getService(Ci.nsIObserverService);
         let observer = {
           observe: function(subject, topic, data) {
             observerSvc.removeObserver(this, "testpilot:startup:complete");
             TestPilotSetup.onWindowLoad(window);
           }
         };
-        Services.console.logStringMessage("Registering observer for startup completion.\n");
         observerSvc.addObserver(observer, "testpilot:startup:complete", false);
       }
 
       } catch (e) {
         Services.console.logStringMessage(e.toString());
       }
     },