Bug 674794 - favicons of app tabs aren't updated on Panorama r=tim
authorRaymond Lee <raymond@raysquare.com>
Tue, 23 Aug 2011 22:48:53 +0800
changeset 75882 aa126a9aebbd04db8d02229b1a294d28f2a1e05c
parent 75881 e138c3a22a655ca873d1f6813f790b30ec9609ef
child 75883 6fd779fb622ddce22fdec79b1129866804c127c6
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerstim
bugs674794
milestone9.0a1
Bug 674794 - favicons of app tabs aren't updated on Panorama r=tim
browser/base/content/tabview/ui.js
browser/base/content/test/tabview/browser_tabview_bug600645.js
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -1618,21 +1618,25 @@ let UI = {
   },
 
   // ----------
   // Function: getFavIconUrlForTab
   // Gets fav icon url for the given xul:tab.
   getFavIconUrlForTab: function UI_getFavIconUrlForTab(tab) {
     let url;
 
-    // use the tab image if it doesn't start with http e.g. data:image/png, chrome://
-    if (tab.image && !(/^https?:/.test(tab.image)))
-      url = tab.image;
-    else
+    if (tab.image) {
+      // if starts with http/https, fetch icon from favicon service via the moz-anno protocal
+      if (/^https?:/.test(tab.image))
+        url = gFavIconService.getFaviconLinkForIcon(gWindow.makeURI(tab.image)).spec;
+      else
+        url = tab.image;
+    } else {
       url = gFavIconService.getFaviconImageForPage(tab.linkedBrowser.currentURI).spec;
+    }
 
     return url;
   },
 
   // ----------
   // Function: notifySessionRestoreEnabled
   // Notify the user that session restore has been automatically enabled
   // by showing a banner that expects no user interaction. It fades out after
--- a/browser/base/content/test/tabview/browser_tabview_bug600645.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug600645.js
@@ -35,18 +35,28 @@ function onTabViewWindowLoaded() {
 
   let errorHandler = function(event) {
     newTab.removeEventListener("error", errorHandler, false);
 
     // since the browser code and test code are invoked when an error event is 
     // fired, a delay is used here to avoid the test code run before the browser 
     // code.
     executeSoon(function() {
-      is($icon.attr("src"), fi.defaultFavicon.spec,
-         "The icon is showing the default fav icon");
+      let iconSrc = $icon.attr("src");
+      let hasData = true;
+      try {
+        fi.getFaviconDataAsDataURL(iconSrc);
+      } catch(e) {
+        hasData = false;
+      }
+      ok(!hasData, "The icon src doesn't return any data");
+      // with moz-anno:favicon automatically redirects to the default favIcon 
+      // if the given url is invalid
+      ok(/^moz-anno:favicon:/.test(iconSrc),
+         "The icon url starts with moz-anno:favicon so the default fav icon would be displayed");
 
       // clean up
       gBrowser.removeTab(newTab);
       let endGame = function() {
         window.removeEventListener("tabviewhidden", endGame, false);
 
         ok(!TabView.isVisible(), "Tab View is hidden");
         finish();