Bug 1364516 - Move gCustomizeMode.setTab call out of updateTabLabelAndIcon. r=mikedeboer draft
authorDão Gottwald <dao@mozilla.com>
Mon, 15 May 2017 18:52:34 +0200
changeset 577925 7406be1314e50665b2a4aa612916e93846ac32f1
parent 577862 0f4df67c5f162e00d6f52825badf468aefbfba19
child 628630 9f1a58f59f654f191ee55a1d73dcf626a7069c36
push id58830
push userdgottwald@mozilla.com
push dateMon, 15 May 2017 16:53:00 +0000
reviewersmikedeboer
bugs1364516
milestone55.0a1
Bug 1364516 - Move gCustomizeMode.setTab call out of updateTabLabelAndIcon. r=mikedeboer While setTab does end up setting the label and icon, it also does completely different and more crucial things. This call really doesn't belong in updateTabLabelAndIcon. MozReview-Commit-ID: 1ZSY17ThNx
browser/components/sessionstore/SessionStore.jsm
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -2613,27 +2613,29 @@ var SessionStoreInternal = {
     }
 
     // Neither a tab nor a window was found, return undefined and let the caller decide what to do about it.
     return undefined;
   },
 
   /**
    * Updates the label and icon for a <xul:tab> using the data from
-   * tabData. If the tab being updated happens to be the
-   * customization mode tab, this function will tell the window's
-   * CustomizeMode instance about it.
+   * tabData.
    *
    * @param tab
    *        The <xul:tab> to update.
    * @param tabData (optional)
    *        The tabData to use to update the tab. If the argument is
    *        not supplied, the data will be retrieved from the cache.
    */
   updateTabLabelAndIcon(tab, tabData = null) {
+    if (tab.hasAttribute("customizemode")) {
+      return;
+    }
+
     let browser = tab.linkedBrowser;
     let win = browser.ownerGlobal;
 
     if (!tabData) {
       tabData = TabState.collect(tab);
       if (!tabData) {
         throw new Error("tabData not found for given tab");
       }
@@ -2643,18 +2645,16 @@ var SessionStoreInternal = {
 
     // If the page has a title, set it.
     if (activePageData) {
       if (activePageData.title) {
         win.gBrowser.setInitialTabTitle(tab, activePageData.title);
       } else if (activePageData.url != "about:blank") {
         win.gBrowser.setInitialTabTitle(tab, activePageData.url);
       }
-    } else if (tab.hasAttribute("customizemode")) {
-      win.gCustomizeMode.setTab(tab);
     }
 
     // Restore the tab icon.
     if ("image" in tabData) {
       // Use the serialized contentPrincipal with the new icon load.
       let loadingPrincipal = Utils.deserializePrincipal(tabData.iconLoadingPrincipal);
       win.gBrowser.setIcon(tab, tabData.image, loadingPrincipal);
       TabStateCache.update(browser, { image: null, iconLoadingPrincipal: null });
@@ -3687,16 +3687,20 @@ var SessionStoreInternal = {
       tab.__SS_lazyData = {
         url,
         title,
         userTypedValue: tabData.userTypedValue || "",
         userTypedClear: tabData.userTypedClear || 0
       };
     }
 
+    if (tab.hasAttribute("customizemode")) {
+      window.gCustomizeMode.setTab(tab);
+    }
+
     // Update tab label and icon to show something
     // while we wait for the messages to be processed.
     this.updateTabLabelAndIcon(tab, tabData);
 
     // Decrease the busy state counter after we're done.
     this._setWindowStateReady(window);
   },