Commit 2524bb9a authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Georg Koppen
Browse files

Bug #13670.1: Isolate favicon requests by first party

parent ec08f989
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -972,6 +972,7 @@ var PageInfoListener = {
    catch (exception) { }

    windowInfo.hostName = hostName;
    windowInfo.firstParty = window.top.location.href;
    return windowInfo;
  },

+7 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ pageInfoTreeView.prototype = {
// mmm, yummy. global variables.
var gDocInfo = null;
var gImageElement = null;
var gFirstParty = null;

// column number to help using the data array
const COL_IMAGE_ADDRESS = 0;
@@ -378,6 +379,8 @@ function loadPageInfo(frameOuterWindowID, imageElement)

    gImageElement = pageInfoData.imageInfo;

    gFirstParty = windowInfo.firstParty;

    var titleFormat = windowInfo.isTopWindow ? "pageInfo.page.title"
                                             : "pageInfo.frame.title";
    document.title = gBundle.getFormattedString(titleFormat, [docInfo.location]);
@@ -880,6 +883,8 @@ function makePreview(row)

    var newImage = new Image;
    newImage.id = "thepreviewimage";
    // Ensure "Media" items are fetched over the first-party domain.
    newImage.setAttribute("firstparty", gFirstParty);
    var physWidth = 0, physHeight = 0;
    var width = 0, height = 0;

@@ -927,6 +932,7 @@ function makePreview(row)
    else if (item.HTMLVideoElement && isProtocolAllowed) {
      newImage = document.createElementNS("http://www.w3.org/1999/xhtml", "video");
      newImage.id = "thepreviewimage";
      newImage.setAttribute("firstparty", gFirstParty);
      newImage.src = url;
      newImage.controls = true;
      width = physWidth = item.videoWidth;
@@ -938,6 +944,7 @@ function makePreview(row)
    else if (item.HTMLAudioElement && isProtocolAllowed) {
      newImage = new Audio;
      newImage.id = "thepreviewimage";
      newImage.setAttribute("firstparty", gFirstParty);
      newImage.src = url;
      newImage.controls = true;
      isAudio = true;
+8 −2
Original line number Diff line number Diff line
@@ -871,7 +871,12 @@
            }

            let sizedIconUrl = browser.mIconURL || "";
            if (sizedIconUrl != aTab.getAttribute("image")) {
            let firstPartyURI = browser.currentURI.spec;
            if (sizedIconUrl !== aTab.getAttribute("image") || firstPartyURI !== aTab.getAttribute("firstparty")) {
              if (firstPartyURI)
                aTab.setAttribute("firstparty", firstPartyURI);
              else
                aTab.removeAttribute("firstparty");
              if (sizedIconUrl)
                aTab.setAttribute("image", sizedIconUrl);
              else
@@ -5908,7 +5913,7 @@
                     class="tab-throbber"
                     role="presentation"
                     layer="true" />
          <xul:image xbl:inherits="src=image,fadein,pinned,selected,visuallyselected,busy,crashed"
          <xul:image xbl:inherits="src=image,fadein,pinned,selected,visuallyselected,busy,crashed,firstparty"
                     anonid="tab-icon-image"
                     class="tab-icon-image"
                     validate="never"
@@ -6253,6 +6258,7 @@
            aMenuitem.setAttribute("busy", aTab.getAttribute("busy"));
            aMenuitem.removeAttribute("image");
          } else {
            aMenuitem.setAttribute("firstparty", aTab.getAttribute("firstparty"));
            aMenuitem.setAttribute("image", aTab.getAttribute("image"));
            aMenuitem.removeAttribute("busy");
          }
+11 −3
Original line number Diff line number Diff line
@@ -3123,7 +3123,7 @@ nsContentUtils::IsImageInCache(nsIURI* aURI, nsIDocument* aDocument)

// static
nsresult
nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
nsContentUtils::LoadImage(nsIURI* aURI, nsINode* aLoadingNode,
                          nsIPrincipal* aLoadingPrincipal, nsIURI* aReferrer,
                          net::ReferrerPolicy aReferrerPolicy,
                          imgINotificationObserver* aObserver, int32_t aLoadFlags,
@@ -3132,10 +3132,11 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
                          uint32_t aContentPolicyType)
{
  NS_PRECONDITION(aURI, "Must have a URI");
  NS_PRECONDITION(aLoadingDocument, "Must have a document");
  NS_PRECONDITION(aLoadingPrincipal, "Must have a principal");
  NS_PRECONDITION(aRequest, "Null out param");

  nsCOMPtr<nsIDocument> aLoadingDocument(aLoadingNode ? aLoadingNode->OwnerDoc() : nullptr);

  imgLoader* imgLoader = GetImgLoaderForDocument(aLoadingDocument);
  if (!imgLoader) {
    // nothing we can do here
@@ -3161,7 +3162,7 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
                              aLoadingPrincipal,    /* loading principal */
                              loadGroup,            /* loadgroup */
                              aObserver,            /* imgINotificationObserver */
                              aLoadingDocument,     /* uniquification key */
                              aLoadingNode,         /* uniquification key */
                              aLoadFlags,           /* load flags */
                              nullptr,              /* cache key */
                              aContentPolicyType,   /* content policy type */
@@ -7332,6 +7333,13 @@ nsContentUtils::CallOnAllRemoteChildren(nsIDOMWindow* aWindow,
  }
}

bool
nsContentUtils::IsChromeWindow(nsIDOMWindow* aWindow)
{
  nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(aWindow));
  return chromeWindow ? true : false;
}

void
nsContentUtils::TransferablesToIPCTransferables(nsISupportsArray* aTransferables,
                                                nsTArray<IPCDataTransfer>& aIPC,
+7 −2
Original line number Diff line number Diff line
@@ -687,7 +687,7 @@ public:
   * keep a mutable version around should pass in a clone.
   *
   * @param aURI uri of the image to be loaded
   * @param aLoadingDocument the document we belong to
   * @param aLoadingNode the node we belong to
   * @param aLoadingPrincipal the principal doing the load
   * @param aReferrer the referrer URI
   * @param aReferrerPolicy the referrer-sending policy to use on channel
@@ -699,7 +699,7 @@ public:
   * @return the imgIRequest for the image load
   */
  static nsresult LoadImage(nsIURI* aURI,
                            nsIDocument* aLoadingDocument,
                            nsINode* aLoadingNode,
                            nsIPrincipal* aLoadingPrincipal,
                            nsIURI* aReferrer,
                            mozilla::net::ReferrerPolicy aReferrerPolicy,
@@ -2592,6 +2592,11 @@ public:
                                    bool aDescendentsOnly,
                                    nsAString& aOut);

  /*
   * Returns true iff an nsIDOMWindow is a chrome window.
   */
  static bool IsChromeWindow(nsIDOMWindow* aWindow);

private:
  static bool InitializeEventTable();

Loading