Commit 66f1364b authored by Yoshi Huang's avatar Yoshi Huang
Browse files

Bug 1264231 - Part 2: skip checking for about:newtab and about:sync-tabs r=sicking

parent f9754e45
Loading
Loading
Loading
Loading
+74 −49
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "nsIBufferedStreams.h"
#include "nsIChannelEventSink.h"
#include "nsIContentSniffer.h"
#include "nsIDocument.h"
#include "nsIDownloader.h"
#include "nsIFileProtocolHandler.h"
#include "nsIFileStreams.h"
@@ -36,6 +37,7 @@
#include "nsILoadContext.h"
#include "nsIMIMEHeaderParam.h"
#include "nsIMutable.h"
#include "nsINode.h"
#include "nsIOfflineCacheUpdate.h"
#include "nsIPersistentProperties2.h"
#include "nsIPrivateBrowsingChannel.h"
@@ -2412,7 +2414,30 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)

  nsCOMPtr<nsILoadContext> loadContext;
  NS_QueryNotificationCallbacks(aChannel, loadContext);
  if (loadInfo && loadContext) {
  if (!loadInfo || !loadContext) {
    return NS_OK;
  }

  // We try to skip about:newtab and about:sync-tabs.
  // about:newtab will use SystemPrincipal to download thumbnails through
  // https:// and blob URLs.
  // about:sync-tabs will fetch icons through moz-icon://.
  bool isAboutPage = false;
  nsINode* node = loadInfo->LoadingNode();
  if (node) {
    nsIDocument* doc = node->OwnerDoc();
    if (doc) {
      nsIURI* uri = doc->GetDocumentURI();
      nsAutoCString spec;
      uri->GetSpec(spec);
      isAboutPage = spec.EqualsLiteral("about:newtab") ||
                    spec.EqualsLiteral("about:sync-tabs");
    }
  }

  if (isAboutPage) {
    return NS_OK;
  }

  uint32_t loadContextAppId = 0;
  nsresult rv = loadContext->GetAppId(&loadContextAppId);
@@ -2445,8 +2470,8 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)
       "loadContext: %d %d, %d, %d. [channel=%p]",
       originAttrsLoadInfo.mAppId, originAttrsLoadInfo.mInIsolatedMozBrowser,
       originAttrsLoadInfo.mUserContextId, loadInfoUsePB,
         loadContextAppId, loadContextUsePB,
         originAttrsLoadContext.mUserContextId, loadContextIsInBE,
       loadContextAppId, loadContextIsInBE,
       originAttrsLoadContext.mUserContextId, loadContextUsePB,
       aChannel));

  MOZ_ASSERT(originAttrsLoadInfo.mAppId == loadContextAppId,
@@ -2466,7 +2491,7 @@ NS_CompareLoadInfoAndLoadContext(nsIChannel *aChannel)
  MOZ_ASSERT(loadInfoUsePB == loadContextUsePB,
             "The value of usePrivateBrowsing in the loadContext and in the loadInfo "
             "are not the same!");
  }

  return NS_OK;
}