Bug 430792 - Site's favicon is replaced if browser error page is shown (for ehsan.akhgari@gmail.com, r=dietrich, a=beltzner)
Wed, 07 May 2008 21:35:08 -0700
changeset 15041 93439a24b5ea3d44c8b176e088171758ac62b586
parent 15040 fe9c48a14bb3977d21d74bd664949b8f045bb9c6
child 15042 be543a54204958fbe961d9048963a7021715bed9
push id27
push userjorendorff@mozilla.com
push dateTue, 13 May 2008 14:57:59 +0000
treeherdermozilla-central@fbb8cd8a9f55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdietrich, beltzner
Bug 430792 - Site's favicon is replaced if browser error page is shown (for ehsan.akhgari@gmail.com, r=dietrich, a=beltzner)
--- a/docshell/resources/content/netError.xhtml
+++ b/docshell/resources/content/netError.xhtml
@@ -54,16 +54,18 @@
    - the terms of any one of the MPL, the GPL or the LGPL.
    - ***** END LICENSE BLOCK ***** -->
 <html xmlns="http://www.w3.org/1999/xhtml">
     <link rel="stylesheet" href="chrome://global/skin/netError.css" type="text/css" media="all" />
+    <!-- If the location of the favicon is changed here, the FAVICON_ERRORPAGE_URL symbol in
+         toolkit/components/places/src/nsFaviconService.h should be updated. -->
     <link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
     <script type="application/x-javascript"><![CDATA[
       // Error url MUST be formatted like this:
       //   moz-neterror:page?e=error&u=url&d=desc
       // or optionally, to specify an alternate CSS class to allow for
       // custom styling and favicon:
--- a/toolkit/components/places/src/nsFaviconService.cpp
+++ b/toolkit/components/places/src/nsFaviconService.cpp
@@ -16,16 +16,17 @@
  * The Initial Developer of the Original Code is
  * Google Inc.
  * Portions created by the Initial Developer are Copyright (C) 2005
  * the Initial Developer. All Rights Reserved.
  * Contributor(s):
  *   Brett Wilson <brettw@gmail.com> (original author)
+ *   Ehsan Akhgari <ehsan.akhgari@gmail.com>
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -475,23 +476,25 @@ nsFaviconService::DoSetAndLoadFaviconFor
   // but that's prohibitive for now. This workaround just refuses to save the
   // favicon in this case.
   PRBool pageEqualsFavicon;
   rv = page->Equals(aFaviconURI, &pageEqualsFavicon);
   if (pageEqualsFavicon)
     return NS_OK;
-  // ignore data URL favicons. The main case here is the error page, which uses
-  // a data URL as the favicon. The result is that we get the data URL in the
-  // favicon table associated with the decoded version of the data URL.
-  PRBool isDataURL;
-  rv = aFaviconURI->SchemeIs("data", &isDataURL);
+  // ignore error page favicons.
+  nsCOMPtr<nsIURI> errorPageFavicon;
+  rv = NS_NewURI(getter_AddRefs(errorPageFavicon),
-  if (isDataURL)
+  PRBool isErrorPage;
+  rv = aFaviconURI->Equals(errorPageFavicon, &isErrorPage);
+  if (isErrorPage)
     return NS_OK;
   // See if we have data and get the expiration time for this favicon. It might
   // be nice to say SetFaviconUrlForPageInternal here but we DON'T want to set
   // the favicon for the page unless we know we have it. For example, if I go
   // to random site x.com, the browser will still tell us that the favicon is
   // x.com/favicon.ico even if there is no such file. We don't want to pollute
   // our tables with this useless data.
--- a/toolkit/components/places/src/nsFaviconService.h
+++ b/toolkit/components/places/src/nsFaviconService.h
@@ -124,9 +124,10 @@ private:
   nsresult UpdateBookmarkRedirectFavicon(nsIURI* aPage, nsIURI* aFavicon);
   void SendFaviconNotifications(nsIURI* aPage, nsIURI* aFaviconURI);
   friend class FaviconLoadListener;
 #define FAVICON_DEFAULT_URL "chrome://mozapps/skin/places/defaultFavicon.png"
+#define FAVICON_ERRORPAGE_URL "chrome://global/skin/icons/warning-16.png"
 #define FAVICON_ANNOTATION_NAME "favicon"