Bug 715565 - Remove default redundant throbber from menubar / mailbar. r=sid0, a=Standard8.
authorMike Conley <mconley@mozilla.com>
Tue, 31 Jan 2012 13:27:52 -0500
changeset 10142 015e0052d398c7fc60be3a8706b52368a4ab392d
parent 10141 0dd648cb208c8e46eefbe043122542b636b14291
child 10143 2247f3164ac8bd01597e8988c8fac24144529f40
push id336
push userbugzilla@standard8.plus.com
push dateTue, 31 Jan 2012 22:15:45 +0000
treeherdercomm-beta@54945f5d278d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssid0, Standard8
bugs715565
Bug 715565 - Remove default redundant throbber from menubar / mailbar. r=sid0, a=Standard8.
mail/base/content/mailWindowOverlay.xul
mail/base/modules/mailMigrator.js
mail/test/mozmill/migration-to-rdf-ui-1/localstore.rdf
mail/test/mozmill/migration-to-rdf-ui-1/test-migrate-to-rdf-ui-1.js
mail/test/mozmill/migration-to-rdf-ui-1/wrapper.py
mail/test/mozmill/migration-to-rdf-ui-2/localstore.rdf
mail/test/mozmill/migration-to-rdf-ui-2/test-migrate-to-rdf-ui-2.js
mail/test/mozmill/migration-to-rdf-ui-2/wrapper.py
mail/test/mozmill/mozmilltests.list
--- a/mail/base/content/mailWindowOverlay.xul
+++ b/mail/base/content/mailWindowOverlay.xul
@@ -962,17 +962,17 @@
 -->
 <toolbox id="navigation-toolbox" class="toolbox-top">
   <!-- Menu -->
   <toolbar type="menubar" id="mail-toolbar-menubar2" class="chromeclass-menubar" customizable="true"
            toolboxid="mail-toolbox"
 #ifdef XP_MACOSX
            defaultset="menubar-items"
 #else
-          defaultset="menubar-items,spring,throbber-box"
+          defaultset="menubar-items,spring"
 #endif
 #ifdef XP_WIN
           toolbarname="&menubarCmd.label;"
           accesskey="&menubarCmd.accesskey;"
 #endif
           context="toolbar-context-menu" mode="icons"
           insertbefore="tabs-toolbar">
     <toolbaritem id="menubar-items" align="center">
@@ -1965,17 +1965,17 @@
            class="inline-toolbar chromeclass-toolbar"
            toolbarname="&showMessengerToolbarCmd.label;"
            accesskey="&showMessengerToolbarCmd.accesskey;"
            fullscreentoolbar="true" mode="full"
            customizable="true"
            context="toolbar-context-menu"
 #ifdef XP_MACOSX
            iconsize="small"
-           defaultset="button-getmsg,button-newmsg,button-address,spacer,button-tag,spring,gloda-search,throbber-box">
+           defaultset="button-getmsg,button-newmsg,button-address,spacer,button-tag,spring,gloda-search">
 #else
            defaultset="button-getmsg,button-newmsg,button-address,separator,button-tag,spring,gloda-search">
 #endif
   </toolbar>
 
   <toolbarset id="customToolbars" context="toolbar-context-menu"/>
 </toolbox>
 
--- a/mail/base/modules/mailMigrator.js
+++ b/mail/base/modules/mailMigrator.js
@@ -128,54 +128,89 @@ var MailMigrator = {
 
   /**
    * Determine if the UI has been upgraded in a way that requires us to reset
    * some user configuration.  If so, performs the resets.
    */
   _migrateUI: function MailMigrator__migrateUI() {
     // The code for this was ported from
     // mozilla/browser/components/nsBrowserGlue.js
-    const UI_VERSION = 1;
+    const UI_VERSION = 2;
     const MESSENGER_DOCURL = "chrome://messenger/content/messenger.xul#";
     const UI_VERSION_PREF = "mail.ui-rdf.version";
     let currentUIVersion = 0;
 
     try {
       currentUIVersion = Services.prefs.getIntPref(UI_VERSION_PREF);
     } catch(ex) {}
 
     if (currentUIVersion >= UI_VERSION)
       return;
 
     this._rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
     this._dataSource = this._rdf.GetDataSource("rdf:local-store");
     let dirty = false;
 
-    if (currentUIVersion < 1) {
-      // We want to remove old settings that collapse the folderPaneBox
-      let fpbResource = this._rdf.GetResource(MESSENGER_DOCURL + "folderPaneBox");
-      let collapsedResource = this._rdf.GetResource("collapsed");
-      let collapsed = this._getPersist(fpbResource, collapsedResource);
+    try {
+      // Initially, we checked if currentUIVersion < 1, and stripped the
+      // persisted "collapsed" property from folderPaneBox if it wasn't.
+      // However, the inital implementation of migrateUI swallowed up
+      // exceptions, and bumped the value of UI_VERSION_PREF regardless.
+      // Now, instead, we fail to bump the UI_VERSION_PREF if something goes
+      // wrong, and we've moved the folderPaneBox operation into
+      // currentUIVersion < 2 just in case the operation failed for some of
+      // our users the first time.
+      if (currentUIVersion < 2) {
+        // We want to remove old settings that collapse the folderPaneBox
+        let fpbResource = this._rdf.GetResource(MESSENGER_DOCURL +
+                                                "folderPaneBox");
+        let collapsedResource = this._rdf.GetResource("collapsed");
+        let collapsed = this._getPersist(fpbResource, collapsedResource);
+
+        if (collapsed !== null) {
+          // We want to override this, and set it to false.  We should really
+          // be ignoring this persist attribute, anyhow.
+          dirty = true;
+          this._unAssert(fpbResource, collapsedResource);
+        }
+
+        // We want to remove the throbber from the menubar on Linux and
+        // Windows, and from the mail-toolbar on OSX.
+        let currentSetResource = this._rdf.GetResource("currentset");
+        let barResource = null;
 
-      if (collapsed !== null) {
-        // We want to override this, and set it to false.  We should really be
-        // ignoring this persist attribute, anyhow.
-        dirty = true;
-        this._unAssert(fpbResource, collapsedResource);
-      }
-    }
+        if (Services.appinfo.OS == "Darwin")
+          barResource = this._rdf.GetResource(MESSENGER_DOCURL + "mail-bar3");
+        else
+          barResource = this._rdf.GetResource(MESSENGER_DOCURL +
+                                              "mail-toolbar-menubar2");
 
-    if (dirty)
-      this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
+        if (barResource !== null) {
+          let currentSet = this._getPersist(barResource, currentSetResource);
+          if (currentSet &&
+              currentSet.indexOf("throbber-box") != -1) {
+            dirty = true;
+            currentSet = currentSet.replace(/(^|,)throbber-box($|,)/, "$1$2");
+            this._setPersist(barResource, currentSetResource, currentSet);
+          }
+        }
+      }
 
-    delete this._rdf;
-    delete this._dataSource;
+      // Update the migration version.
+      Services.prefs.setIntPref(UI_VERSION_PREF, UI_VERSION);
 
-    // Update the migration version.
-    Services.prefs.setIntPref(UI_VERSION_PREF, UI_VERSION);
+    } catch(e) {
+      Cu.reportError("Migrating from UI version " + currentUIVersion + " to "
+                     + UI_VERSION + " failed. Will reattempt on next start.");
+    } finally {
+      if (dirty)
+        this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
+      delete this._rdf;
+      delete this._dataSource;
+    }
   },
 
   /**
    * Perform any migration work that needs to occur after the Account Wizard
    * has had a chance to appear.
    */
   migratePostAccountWizard: function MailMigrator_migratePostAccountWizard() {
     this.migrateToClearTypeFonts();
@@ -202,30 +237,69 @@ var MailMigrator = {
 
     let target = this._dataSource.GetTarget(aSource, aProperty, true);
     if (target instanceof Ci.nsIRDFLiteral)
       return target.Value;
     return null;
   },
 
   /**
+   * A helper function to set the property for a resource in the localstore.rdf.
+   * This function also automatically adds the property to the list of properties
+   * being persisted for the aSource.
+   *
+   * @param aSource the resource that we want to set persistence on
+   * @param aProperty the property that we're going to set the value of
+   * @param aTarget the value that we're going to set the property to
+   */
+  _setPersist: function MailMigrator__setPersist(aSource, aProperty, aTarget) {
+    try {
+      let oldTarget = this._dataSource.GetTarget(aSource, aProperty, true);
+      if (oldTarget) {
+        if (aTarget)
+          this._dataSource.Change(aSource, aProperty, oldTarget, this._rdf.GetLiteral(aTarget));
+        else
+          this._dataSource.Unassert(aSource, aProperty, oldTarget);
+      }
+      else {
+        this._dataSource.Assert(aSource, aProperty, this._rdf.GetLiteral(aTarget), true);
+      }
+
+      // Add the entry to the persisted set for this document if it's not there.
+      // This code is mostly borrowed from nsXULDocument::Persist.
+      let docURL = aSource.ValueUTF8.split("#")[0];
+      let docResource = this._rdf.GetResource(docURL);
+      let persistResource = this._rdf.GetResource("http://home.netscape.com/NC-rdf#persist");
+      if (!this._dataSource.HasAssertion(docResource, persistResource, aSource, true)) {
+        this._dataSource.Assert(docResource, persistResource, aSource, true);
+      }
+    }
+    catch(e) {
+      // Something's gone horribly wrong - report it in the Error Console
+      Cu.reportError(e);
+      throw(e);
+    }
+  },
+
+  /**
    * A helper function to unassert a property from a resource.  This function
    * should only be called by _migrateUI.
    *
    * @param aSource the resource to remove the property from
    * @param aProperty the property to be removed
    */
   _unAssert: function MailMigrator__unAssert(aSource, aProperty) {
     try {
       let oldTarget = this._dataSource.GetTarget(aSource, aProperty, true);
       if (oldTarget)
         this._dataSource.Unassert(aSource, aProperty, oldTarget);
     }
     catch(e) {
       // If something's gone wrong here, report it in the Error Console.
       Cu.reportError(e);
+      throw(e);
     }
   },
 };
 
 XPCOMUtils.defineLazyServiceGetter(MailMigrator, "_prefBranch",
                                    "@mozilla.org/preferences-service;1",
                                    "nsIPrefBranch");
rename from mail/test/mozmill/migration-to-rdf-ui-1/localstore.rdf
rename to mail/test/mozmill/migration-to-rdf-ui-2/localstore.rdf
--- a/mail/test/mozmill/migration-to-rdf-ui-1/localstore.rdf
+++ b/mail/test/mozmill/migration-to-rdf-ui-2/localstore.rdf
@@ -15,16 +15,26 @@
                    iconsize="small"
                    labelalign="end" />
   <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#messengerWindow"
                    width="1024"
                    height="1160"
                    screenX="0"
                    screenY="0"
                    sizemode="normal" />
+  <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#mail-toolbar-menubar2"
+                   mode="full"
+                   iconsize="large"
+                   currentset="menubar-items,spring,throbber-box" />
+  <RDF:Description RDF:about="chrome://messenger/content/messenger.xul#mail-bar3"
+                   collapsed="false"
+                   mode="full"
+                   iconsize="large"
+                   currentset="button-getmsg,button-newmsg,button-address,separator,button-tag,spring,gloda-search,throbber-box" />
+
   <RDF:Description RDF:about="chrome://messenger/content/messenger.xul">
     <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#messengerWindow"/>
     <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#messagepaneboxwrapper"/>
     <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#header-view-toolbox"/>
     <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#header-view-toolbar"/>
     <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#attachment-view-toolbox"/>
     <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#attachment-view-toolbar"/>
     <NC:persist RDF:resource="chrome://messenger/content/messenger.xul#abp-hooks"/>
rename from mail/test/mozmill/migration-to-rdf-ui-1/test-migrate-to-rdf-ui-1.js
rename to mail/test/mozmill/migration-to-rdf-ui-2/test-migrate-to-rdf-ui-2.js
--- a/mail/test/mozmill/migration-to-rdf-ui-1/test-migrate-to-rdf-ui-1.js
+++ b/mail/test/mozmill/migration-to-rdf-ui-2/test-migrate-to-rdf-ui-2.js
@@ -35,17 +35,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /**
  * When moving from ui-rdf 0 to 1, we ensure that we've removed the collapsed
  * property from the folderPaneBox, but that we still persist width.
  */
 
-let MODULE_NAME = "test-migrate-to-rdf-ui-1";
+let MODULE_NAME = "test-migrate-to-rdf-ui-2";
 let RELATIVE_ROOT = "../shared-modules";
 let MODULE_REQUIRES = ["folder-display-helpers", "migration-helpers"];
 
 let Cc = Components.classes;
 let Ci = Components.interfaces;
 let Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
@@ -83,8 +83,23 @@ function test_collapsed_removed() {
  * the width defined in localstore.rdf (which, in this case, is 500px).
  */
 function test_width_persisted() {
   const EXPECTED_WIDTH = 500; // Set in localstore.rdf, found in this directory
   let fpbWidth = mc.e("folderPaneBox").width;
   assert_equals(EXPECTED_WIDTH, fpbWidth,
                 "The width of the folderPaneBox was not persisted.");
 }
+
+/**
+ * Test that the throbber in the main menu (or the mailbar on OSX) was removed.
+ */
+function test_throbber_removed() {
+  let currentSet;
+
+  if (mc.mozmillModule.isMac)
+    currentSet = mc.e("mail-bar3").getAttribute("currentset");
+  else
+    currentSet = mc.e("mail-toolbar-menubar2").getAttribute("currentset");
+
+  assert_equals(-1, currentSet.indexOf("throbber-box"),
+                "We found a throbber-box where we shouldn't have.");
+}
rename from mail/test/mozmill/migration-to-rdf-ui-1/wrapper.py
rename to mail/test/mozmill/migration-to-rdf-ui-2/wrapper.py
--- a/mail/test/mozmill/mozmilltests.list
+++ b/mail/test/mozmill/mozmilltests.list
@@ -9,16 +9,16 @@ folder-pane
 folder-tree-modes
 folder-widget
 instrumentation
 junk-commands
 message-header
 message-window
 migration
 migration-from-tb2
-migration-to-rdf-ui-1
+migration-to-rdf-ui-2
 newmailaccount
 notification
 pref-window
 quick-filter-bar
 search-window
 session-store
 tabmail