Bug 705808 - TestPilot first-run tab shouldn't open for Thunderbird. r=Standard8,ui-review=bwinton,a=Standard8
authorMark Banner <bugzilla@standard8.plus.com>
Thu, 15 Dec 2011 00:15:38 +0000
changeset 9229 0c9973a71788b88792d9d4934c0e57509040cb3b
parent 9228 a92b37de1cd9e03b9c54532ed48832ab892ac59b
child 9230 6a837d0eb99f6a9514c05f4879a21351d7d5319f
push id283
push userbugzilla@standard8.plus.com
push dateThu, 15 Dec 2011 00:34:43 +0000
treeherdercomm-aurora@0c9973a71788 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, Standard8
bugs705808
Bug 705808 - TestPilot first-run tab shouldn't open for Thunderbird. r=Standard8,ui-review=bwinton,a=Standard8
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/window-utils.js
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/interface.js
mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/setup.js
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/window-utils.js
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/content/window-utils.js
@@ -39,22 +39,16 @@ var TestPilotWindowUtils;
 
 (function() {
   const ALL_STUDIES_WINDOW_NAME = "TestPilotAllStudiesWindow";
   const ALL_STUDIES_WINDOW_TYPE = "extensions:testpilot:all_studies_window";
   const FENNEC_APP_ID = "{a23983c0-fd0e-11dc-95ff-0800200c9a66}";
   const THUNDERBIRD_APP_ID = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
 
   TestPilotWindowUtils = {
-    get _appID() {
-      delete this._appID;
-      return this._appID = Components.classes["@mozilla.org/xre/app-info;1"]
-        .getService(Components.interfaces.nsIXULAppInfo).ID;
-    },
-
     openAllStudiesWindow: function() {
       // If the window is not already open, open it; but if it is open,
       // focus it instead.
       let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
                  getService(Components.interfaces.nsIWindowMediator);
       let allStudiesWindow = wm.getMostRecentWindow(ALL_STUDIES_WINDOW_TYPE);
 
       if (allStudiesWindow) {
@@ -63,37 +57,39 @@ var TestPilotWindowUtils;
         allStudiesWindow = window.openDialog(
           "chrome://testpilot/content/all-studies-window.xul",
           ALL_STUDIES_WINDOW_NAME,
           "chrome,titlebar,centerscreen,dialog=no");
       }
     },
 
     openAllStudies: function() {
-      if (this._appID == FENNEC_APP_ID) { // Fennec only
+      Components.utils.import("resource://testpilot/modules/setup.js");
+      if (TestPilotSetup._appID == FENNEC_APP_ID) { // Fennec only
         // BrowserUI.newTab will focus on the content area of the new tab
         BrowserUI.newTab("chrome://testpilot/content/all-studies.html", Browser.selectedTab);
       }
     },
 
     openInTab: function(url) {
-      if (this._appID == FENNEC_APP_ID) {
+      Components.utils.import("resource://testpilot/modules/setup.js");
+      if (TestPilotSetup._appID == FENNEC_APP_ID) {
         // see if url already open in a tab:
         let browserList = Browser.browsers;
         for (let i = 0; i < browserList.length; i++) {
           if (url == browserList[i].currentURI.spec) {
             Browser.selectedTab = browserList[i];
             return;
           }
         }
 
         // if not, open it:
         Browser.addTab(url, true); // true means bring it to front
       }
-      else if (this._appID == THUNDERBIRD_APP_ID) {
+      else if (TestPilotSetup._appID == THUNDERBIRD_APP_ID) {
         openContentTab(url);
       }
       else {
         // Desktop implementation:
         let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                    .getService(Components.interfaces.nsIWindowMediator);
         let enumerator = wm.getEnumerator("navigator:browser");
 
@@ -121,17 +117,18 @@ var TestPilotWindowUtils;
           win.focus();
         } else {
           window.open(url);
         }
       }
     },
 
     getCurrentTabUrl: function() {
-      if (this._appID == THUNDERBIRD_APP_ID) {
+      Components.utils.import("resource://testpilot/modules/setup.js");
+      if (TestPilotSetup._appID == THUNDERBIRD_APP_ID) {
         return null; // TODO: not sure what to do here
       }
       else {
         let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                    .getService(Components.interfaces.nsIWindowMediator);
         let win = wm.getMostRecentWindow("navigator:browser");
         let tabbrowser = win.getBrowser();
         let currentBrowser = tabbrowser.selectedBrowser;
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/interface.js
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/interface.js
@@ -74,22 +74,16 @@ var TestPilotUIBuilder = {
   },
 
   get _appVersion() {
     delete this._appVersion;
     return this._appVersion = Cc["@mozilla.org/xre/app-info;1"]
       .getService(Ci.nsIXULAppInfo).version;
   },
 
-  get _appID() {
-    delete this._appID;
-    return this._appID = Cc["@mozilla.org/xre/app-info;1"]
-      .getService(Ci.nsIXULAppInfo).ID;
-  },
-
   buildTestPilotInterface: function(window) {
     // Don't need Feedback button: remove it
     let feedbackButton = window.document.getElementById("feedback-menu-button");
     if (!feedbackButton) {
       let toolbox = window.document.getElementById("mail-toolbox");
       let palette = toolbox.palette;
       feedbackButton = palette.getElementsByAttribute("id", "feedback-menu-button").item(0);
     }
@@ -109,18 +103,20 @@ var TestPilotUIBuilder = {
     /* If this is first run, and it's ffx4 beta version, and the feedback
      * button is not in the expected place, put it there!
      * (copied from MozReporterButtons extension) */
 
     /* Check if we've already done this customization -- if not, don't do it
      * again  (don't want to put it back in after user explicitly takes it out-
      * bug 577243 )*/
 
+    Cu.import("resource://testpilot/modules/setup.js");
+
     let mainToolbar;
-    if (this._appID == THUNDERBIRD_APP_ID)
+    if (TestPilotSetup._appID == THUNDERBIRD_APP_ID)
       mainToolbar = window.document.getElementById("mail-bar3");
     else
       mainToolbar = window.document.getElementById("nav-bar");
     let pref = "extensions.testpilot.alreadyCustomizedToolbar";
     let alreadyCustomized = this._prefs.getBoolPref(pref);
     let curSet = mainToolbar.currentSet;
 
     if (!alreadyCustomized && (-1 == curSet.indexOf("feedback-menu-button"))) {
@@ -139,17 +135,17 @@ var TestPilotUIBuilder = {
 
     /* Pref defaults for Feedback version: default to notifying user about new
      * studies starting. Note we're setting default values, not current values -- we
      * want these to be overridden by any user set values!!*/
     this._prefDefaultBranch.setBoolPref(POPUP_SHOW_ON_NEW, true);
     this._prefDefaultBranch.setIntPref(POPUP_CHECK_INTERVAL, 600000);
 
     // Change the happy/sad labels if necessary
-    if (this._appID == THUNDERBIRD_APP_ID) {
+    if (TestPilotSetup._appID == THUNDERBIRD_APP_ID) {
       let happy = window.document.getElementById("feedback-menu-happy-button");
       let sad = window.document.getElementById("feedback-menu-sad-button");
       happy.setAttribute("label", happy.getAttribute("thunderbirdLabel"));
       sad.setAttribute("label", sad.getAttribute("thunderbirdLabel"));
     }
   },
 
   channelUsesFeedback: function() {
@@ -159,34 +155,38 @@ var TestPilotUIBuilder = {
     // Beta and aurora channels use feedback interface; nightly and release channels don't.
 //    let channel = this._prefDefaultBranch.getCharPref(UPDATE_CHANNEL_PREF);
 //    return (channel == "beta") || (channel == "betatest") || (channel == "aurora");
   },
 
   hasDoorhangerNotifications: function() {
     // Thunderbird doesn't use the add-on bar (it uses the plain old status
     // bar), and so the doorhanger UI doesn't quite work.
-    if (this._appID == THUNDERBIRD_APP_ID)
+    Cu.import("resource://testpilot/modules/setup.js");
+
+    if (TestPilotSetup._appID == THUNDERBIRD_APP_ID)
       return false;
 
     try {
       let popupModule = {};
       Components.utils.import("resource://gre/modules/PopupNotifications.jsm", popupModule);
       return true;
     } catch (e) {
       return false;
     }
   },
 
   buildCorrectInterface: function(window) {
     /* Apply no overlay to Fennec: */
-    if (this._appID == FENNEC_APP_ID) {
+    Cu.import("resource://testpilot/modules/setup.js");
+
+    if (TestPilotSetup._appID == FENNEC_APP_ID) {
       return;
     }
-    else if (this._appID == THUNDERBIRD_APP_ID) {
+    else if (TestPilotSetup._appID == THUNDERBIRD_APP_ID) {
       // TODO: do something special here, probably
     }
     else {
       let firefoxnav = window.document.getElementById("nav-bar");
       /* This is sometimes called for windows that don't have a navbar - in
        * that case, do nothing. TODO maybe this should be in onWindowLoad?*/
       if (!firefoxnav) {
         return;
@@ -216,19 +216,20 @@ var TestPilotUIBuilder = {
     }
   },
 
   getNotificationManager: function() {
     // If we're on Android, use the Android notification manager!
     let ntfnModule = {};
     Cu.import("resource://testpilot/modules/notifications.js", ntfnModule);
     Components.utils.import("resource://gre/modules/Services.jsm");
+    Cu.import("resource://testpilot/modules/setup.js");
 
-    Services.console.logStringMessage("appID is " + this._appID);
-    if (this._appID == FENNEC_APP_ID) {
+    Services.console.logStringMessage("appID is " + TestPilotSetup._appID);
+    if (TestPilotSetup._appID == FENNEC_APP_ID) {
       Services.console.logStringMessage("making Android Notfn Manager..");
       return new ntfnModule.AndroidNotificationManager();
     }
 
     // Use custom notifications anchored to the Feedback button, if there is a Feedback button
     if (this.channelUsesFeedback()) {
       Services.console.logStringMessage("making Custom Notfn Manager..");
       return new ntfnModule.CustomNotificationManager(true);
--- a/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/setup.js
+++ b/mail/app/profile/extensions/tbtestpilot@labs.mozilla.com/modules/setup.js
@@ -54,16 +54,18 @@ const POPUP_SHOW_ON_FINISH = "extensions
 const POPUP_SHOW_ON_RESULTS = "extensions.testpilot.popup.showOnNewResults";
 const POPUP_CHECK_INTERVAL = "extensions.testpilot.popup.delayAfterStartup";
 const POPUP_REMINDER_INTERVAL = "extensions.testpilot.popup.timeBetweenChecks";
 const ALWAYS_SUBMIT_DATA = "extensions.testpilot.alwaysSubmitData";
 const UPDATE_CHANNEL_PREF = "app.update.channel";
 const LOG_FILE_NAME = "TestPilotErrorLog.log";
 const RANDOM_DEPLOY_PREFIX = "extensions.testpilot.deploymentRandomizer";
 
+const THUNDERBIRD_APP_ID = "{3550f703-e582-4d05-9a08-453d09bdfdc6}";
+
 Cu.import("resource://testpilot/modules/interface.js");
 
 let TestPilotSetup = {
   didReminderAfterStartup: false,
   startupComplete: false,
   _shortTimer: null,
   _longTimer: null,
   _remoteExperimentLoader: null, // TODO make this a lazy initializer too?
@@ -176,16 +178,22 @@ let TestPilotSetup = {
   __notifier: null,
   get _notifier() {
     if (this.__notifier == null) {
       this.__notifier = TestPilotUIBuilder.getNotificationManager();
     }
     return this.__notifier;
   },
 
+  get _appID() {
+    delete this._appID;
+    return this._appID = Components.classes["@mozilla.org/xre/app-info;1"]
+        .getService(Components.interfaces.nsIXULAppInfo).ID;
+  },
+
   globalStartup: function TPS__doGlobalSetup() {
     // Only ever run this stuff ONCE, on the first window restore.
     // Should get called by the Test Pilot component.
     let logger = this._logger;
     logger.trace("TestPilotSetup.globalStartup was called.");
 
     try {
     if (!this._prefs.getBoolPref(RUN_AT_ALL_PREF)) {
@@ -222,17 +230,18 @@ let TestPilotSetup = {
 	  });
       }}, this._prefs.getIntPref(POPUP_REMINDER_INTERVAL),
       Ci.nsITimer.TYPE_REPEATING_SLACK);
 
       this.getVersion(function() {
         /* Show first run page (in front window) only the first time after install;
          * Don't show first run page in Feedback UI version. */
         if (!self._prefs.prefHasUserValue(VERSION_PREF) &&
-           (!TestPilotUIBuilder.channelUsesFeedback())) {
+            (!TestPilotUIBuilder.channelUsesFeedback())
+            && self._shouldOpenTabs()) {
             self._prefs.setCharPref(VERSION_PREF, self.version);
             let browser = self._getFrontBrowserWindow().getBrowser();
             let url = self._prefs.getCharPref(FIRST_RUN_PREF);
             self._openInTab(url);
         }
 
         // Install tasks. (This requires knowing the version, so it is
         // inside the callback from getVersion.)
@@ -632,16 +641,22 @@ let TestPilotSetup = {
         return runOrNotFunc();
       }
     } catch (e) {
       logger.warn("Error in requirements check " +  e);
     }
     return true;
   },
 
+  _shouldOpenTabs: function TPS__shouldOpenTabs() {
+    // For Thunderbird, we don't want the Test Pilot tab spawning, since
+    // we're bundling Test Pilot in the release.
+    return !(this._appID == THUNDERBIRD_APP_ID);
+  },
+
   checkForTasks: function TPS_checkForTasks(callback) {
     let logger = this._logger;
     if (! this._remoteExperimentLoader ) {
       logger.trace("Now requiring remote experiment loader:");
       let remoteLoaderModule = this._loader.require("remote-experiment-loader");
       logger.trace("Now instantiating remoteExperimentLoader:");
       let rel = new remoteLoaderModule.RemoteExperimentLoader(this._logRepo);
       this._remoteExperimentLoader = rel;