Bug 1376973 - Part 1: Making the favicon of the allTabs menu obeys originAttributes and rename attribute 'iconLoadingPrincipal' to 'iconloadingprincipal'. r?dao,arthuredelstein draft
authorTim Huang <tihuang@mozilla.com>
Fri, 20 Oct 2017 09:19:57 +0800
changeset 683673 0a64e07837da8f3a921bc81c2eaf12ef5d472c87
parent 683653 b6ba3e919f561bfabbf4bec7f0f53a23c360adee
child 683674 9ed411afa651b88684e6c5fd2e47981547e78562
push id85430
push userbmo:tihuang@mozilla.com
push dateFri, 20 Oct 2017 01:49:06 +0000
reviewersdao, arthuredelstein
bugs1376973
milestone58.0a1
Bug 1376973 - Part 1: Making the favicon of the allTabs menu obeys originAttributes and rename attribute 'iconLoadingPrincipal' to 'iconloadingprincipal'. r?dao,arthuredelstein MozReview-Commit-ID: AqjIr7xkXs9
browser/base/content/tabbrowser.xml
browser/components/sessionstore/TabAttributes.jsm
browser/components/sessionstore/test/browser_attributes.js
browser/components/sessionstore/test/browser_label_and_icon.js
toolkit/content/widgets/menu.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1009,24 +1009,24 @@
             let loadingPrincipal = aLoadingPrincipal ||
                                    Services.scriptSecurityManager.getSystemPrincipal();
             let requestContextID = aRequestContextID || 0;
             let sizedIconUrl = browser.mIconURL || "";
             if (sizedIconUrl != aTab.getAttribute("image")) {
               if (sizedIconUrl) {
                 if (!browser.mIconLoadingPrincipal ||
                     !browser.mIconLoadingPrincipal.equals(loadingPrincipal)) {
-                  aTab.setAttribute("iconLoadingPrincipal",
+                  aTab.setAttribute("iconloadingprincipal",
                     this.serializationHelper.serializeToString(loadingPrincipal));
                   aTab.setAttribute("requestcontextid", requestContextID);
                   browser.mIconLoadingPrincipal = loadingPrincipal;
                 }
                 aTab.setAttribute("image", sizedIconUrl);
               } else {
-                aTab.removeAttribute("iconLoadingPrincipal");
+                aTab.removeAttribute("iconloadingprincipal");
                 delete browser.mIconLoadingPrincipal;
                 aTab.removeAttribute("image");
               }
               this._tabAttrModified(aTab, ["image"]);
             }
 
             this._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]);
           ]]>
@@ -7760,17 +7760,17 @@
                   anonid="tab-loading-burst"
                   class="tab-loading-burst"/>
         <xul:hbox xbl:inherits="pinned,selected=visuallyselected,titlechanged,attention"
                   class="tab-content" align="center">
           <xul:hbox xbl:inherits="fadein,pinned,busy,progress,selected=visuallyselected"
                     anonid="tab-throbber"
                     class="tab-throbber"
                     layer="true"/>
-          <xul:image xbl:inherits="src=image,loadingprincipal=iconLoadingPrincipal,requestcontextid,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
+          <xul:image xbl:inherits="src=image,loadingprincipal=iconloadingprincipal,requestcontextid,fadein,pinned,selected=visuallyselected,busy,crashed,sharing"
                      anonid="tab-icon-image"
                      class="tab-icon-image"
                      validate="never"
                      role="presentation"/>
           <xul:image xbl:inherits="sharing,selected=visuallyselected,pinned"
                      anonid="sharing-icon"
                      class="tab-sharing-icon-overlay"
                      role="presentation"/>
@@ -8249,18 +8249,20 @@
         <parameter name="aMenuitem"/>
         <parameter name="aTab"/>
         <body><![CDATA[
           aMenuitem.setAttribute("label", aTab.label);
           aMenuitem.setAttribute("crop", "end");
 
           if (aTab.hasAttribute("busy")) {
             aMenuitem.setAttribute("busy", aTab.getAttribute("busy"));
+            aMenuitem.removeAttribute("iconloadingprincipal");
             aMenuitem.removeAttribute("image");
           } else {
+            aMenuitem.setAttribute("iconloadingprincipal", aTab.getAttribute("iconloadingprincipal"));
             aMenuitem.setAttribute("image", aTab.getAttribute("image"));
             aMenuitem.removeAttribute("busy");
           }
 
           if (aTab.hasAttribute("pending"))
             aMenuitem.setAttribute("pending", aTab.getAttribute("pending"));
           else
             aMenuitem.removeAttribute("pending");
--- a/browser/components/sessionstore/TabAttributes.jsm
+++ b/browser/components/sessionstore/TabAttributes.jsm
@@ -7,22 +7,22 @@
 this.EXPORTED_SYMBOLS = ["TabAttributes"];
 
 // We never want to directly read or write these attributes.
 // 'image' should not be accessed directly but handled by using the
 //         gBrowser.getIcon()/setIcon() methods.
 // 'muted' should not be accessed directly but handled by using the
 //         tab.linkedBrowser.audioMuted/toggleMuteAudio methods.
 // 'pending' is used internal by sessionstore and managed accordingly.
-// 'iconLoadingPrincipal' is same as 'image' that it should be handled by
+// 'iconloadingprincipal' is same as 'image' that it should be handled by
 //                        using the gBrowser.getIcon()/setIcon() methods.
 // 'activemedia-blocked' should not be accessed directly but handled by using
 //                       tab's toggleMuteAudio() or linkedBrowser's methods
 //                       activeMediaBlockStarted()/activeMediaBlockBlockStopped().
-const ATTRIBUTES_TO_SKIP = new Set(["image", "muted", "pending", "iconLoadingPrincipal",
+const ATTRIBUTES_TO_SKIP = new Set(["image", "muted", "pending", "iconloadingprincipal",
                                     "skipbackgroundnotify", "activemedia-blocked"]);
 
 // A set of tab attributes to persist. We will read a given list of tab
 // attributes when collecting tab data and will re-set those attributes when
 // the given tab data is restored to a new tab.
 this.TabAttributes = Object.freeze({
   persist(name) {
     return TabAttributesInternal.persist(name);
--- a/browser/components/sessionstore/test/browser_attributes.js
+++ b/browser/components/sessionstore/test/browser_attributes.js
@@ -25,36 +25,36 @@ add_task(async function test() {
 
   // Because there is debounce logic in ContentLinkHandler.jsm to reduce the
   // favicon loads, we have to wait some time before checking that icon was
   // stored properly.
   await BrowserTestUtils.waitForCondition(() => {
     return gBrowser.getIcon(tab) != null;
   }, "wait for favicon load to finish", 100, 5);
 
-  // Check that the tab has 'image' and 'iconLoadingPrincipal' attributes.
+  // Check that the tab has 'image' and 'iconloadingprincipal' attributes.
   ok(tab.hasAttribute("image"), "tab.image exists");
-  ok(tab.hasAttribute("iconLoadingPrincipal"), "tab.iconLoadingPrincipal exists");
+  ok(tab.hasAttribute("iconloadingprincipal"), "tab.iconloadingprincipal exists");
 
   tab.toggleMuteAudio();
   // Check that the tab has a 'muted' attribute.
   ok(tab.hasAttribute("muted"), "tab.muted exists");
 
   // Pretend to start autoplay media in tab, tab should get the notification.
   tab.linkedBrowser.activeMediaBlockStarted();
   ok(tab.hasAttribute("activemedia-blocked"), "tab.activemedia-blocked exists");
 
   // Make sure we do not persist 'image','muted' and 'activemedia-blocked' attributes.
   ss.persistTabAttribute("image");
   ss.persistTabAttribute("muted");
-  ss.persistTabAttribute("iconLoadingPrincipal");
+  ss.persistTabAttribute("iconloadingprincipal");
   ss.persistTabAttribute("activemedia-blocked");
   let {attributes} = JSON.parse(ss.getTabState(tab));
   ok(!("image" in attributes), "'image' attribute not saved");
-  ok(!("iconLoadingPrincipal" in attributes), "'iconLoadingPrincipal' attribute not saved");
+  ok(!("iconloadingprincipal" in attributes), "'iconloadingprincipal' attribute not saved");
   ok(!("muted" in attributes), "'muted' attribute not saved");
   ok(!("custom" in attributes), "'custom' attribute not saved");
   ok(!("activemedia-blocked" in attributes), "'activemedia-blocked' attribute not saved");
 
   // Test persisting a custom attribute.
   tab.setAttribute("custom", "foobar");
   ss.persistTabAttribute("custom");
 
--- a/browser/components/sessionstore/test/browser_label_and_icon.js
+++ b/browser/components/sessionstore/test/browser_label_and_icon.js
@@ -36,16 +36,16 @@ add_task(async function test_label_and_i
   await promiseTabRestoring(tab);
 
   // Check that label and icon are set for the restoring tab.
   is(gBrowser.getIcon(tab), "chrome://browser/content/robot.ico", "icon is set");
   is(tab.label, "Gort! Klaatu barada nikto!", "label is set");
 
   let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
                     .getService(Ci.nsISerializationHelper);
-  let serializedPrincipal = tab.getAttribute("iconLoadingPrincipal");
+  let serializedPrincipal = tab.getAttribute("iconloadingprincipal");
   let iconLoadingPrincipal = serhelper.deserializeObject(serializedPrincipal)
                                       .QueryInterface(Ci.nsIPrincipal);
   is(iconLoadingPrincipal.origin, "about:robots", "correct loadingPrincipal used");
 
   // Cleanup.
   await promiseRemoveTab(tab);
 });
--- a/toolkit/content/widgets/menu.xml
+++ b/toolkit/content/widgets/menu.xml
@@ -209,17 +209,17 @@
       <children includes="menupopup"/>
     </content>
   </binding>
 
   <binding id="menuitem-iconic" extends="chrome://global/content/bindings/menu.xml#menuitem">
     <content>
       <xul:hbox class="menu-iconic-left" align="center" pack="center"
                 xbl:inherits="selected,_moz-menuactive,disabled,checked">
-        <xul:image class="menu-iconic-icon" xbl:inherits="src=image,validate,src"/>
+        <xul:image class="menu-iconic-icon" xbl:inherits="src=image,loadingprincipal=iconloadingprincipal,validate,src"/>
       </xul:hbox>
       <xul:label class="menu-iconic-text" flex="1" xbl:inherits="value=label,accesskey,crop,highlightable" crop="right"/>
       <xul:label class="menu-iconic-highlightable-text" xbl:inherits="xbl:text=label,crop,accesskey,highlightable" crop="right"/>
       <children/>
       <xul:hbox class="menu-accel-container" anonid="accel">
         <xul:label class="menu-iconic-accel" xbl:inherits="value=acceltext"/>
       </xul:hbox>
     </content>