Commit a01e4b71 authored by Cristian Tuns's avatar Cristian Tuns
Browse files

Backed out changeset 5a6645284357 (bug 1798986) for causing xpcshell failures

parent e8b7bce9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2073,6 +2073,10 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
      wgc->SendLoadURI(this, aLoadState, aSetNavigating);
    }
  } else if (XRE_IsParentProcess()) {
    // Strip the target query parameters before loading the URI in the parent.
    // The loading in content will be handled in nsDocShell.
    aLoadState->MaybeStripTrackerQueryStrings(this);

    if (Canonical()->LoadInParent(aLoadState, aSetNavigating)) {
      return NS_OK;
    }
+15 −13
Original line number Diff line number Diff line
@@ -9870,9 +9870,6 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
        isSrcdoc);
  }

  // Strip the target query parameters before creating the channel.
  aLoadState->MaybeStripTrackerQueryStrings(aBrowsingContext);

  OriginAttributes attrs;

  // Inherit origin attributes from PrincipalToInherit if inheritAttrs is
@@ -10543,6 +10540,19 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
  nsLoadFlags loadFlags = aLoadState->CalculateChannelLoadFlags(
      mBrowsingContext, Some(uriModified), Some(isXFOError));

  // Get the unstripped URI from the current document channel. The unstripped
  // URI will be preserved if it's a reload.
  nsCOMPtr<nsIURI> currentUnstrippedURI;
  nsCOMPtr<nsIChannel> docChannel = GetCurrentDocChannel();
  if (docChannel) {
    nsCOMPtr<nsILoadInfo> docLoadInfo = docChannel->LoadInfo();
    docLoadInfo->GetUnstrippedURI(getter_AddRefs(currentUnstrippedURI));
  }

  // Strip the target query parameters before creating the channel.
  aLoadState->MaybeStripTrackerQueryStrings(mBrowsingContext,
                                            currentUnstrippedURI);

  nsCOMPtr<nsIChannel> channel;
  if (DocumentChannel::CanUseDocumentChannel(aLoadState->URI()) &&
      !isAboutBlankLoadOntoInitialAboutBlank) {
@@ -11561,9 +11571,6 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,

    newSHEntry->SetURI(aNewURI);
    newSHEntry->SetOriginalURI(aNewURI);
    // We replaced the URI of the entry, clear the unstripped URI as it
    // shouldn't be used for reloads anymore.
    newSHEntry->SetUnstrippedURI(nullptr);
    // Setting the resultPrincipalURI to nullptr is fine here: it will cause
    // NS_GetFinalChannelURI to use the originalURI as the URI, which is aNewURI
    // in our case.  We could also set it to aNewURI, with the same result.
@@ -11791,7 +11798,6 @@ nsresult nsDocShell::AddToSessionHistory(
  nsCOMPtr<nsIInputStream> inputStream;
  nsCOMPtr<nsIURI> originalURI;
  nsCOMPtr<nsIURI> resultPrincipalURI;
  nsCOMPtr<nsIURI> unstrippedURI;
  bool loadReplace = false;
  nsCOMPtr<nsIReferrerInfo> referrerInfo;
  uint32_t cacheKey = 0;
@@ -11845,8 +11851,6 @@ nsresult nsDocShell::AddToSessionHistory(

    loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));

    loadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI));

    userActivation = loadInfo->GetHasValidUserGestureActivation();

    // For now keep storing just the principal in the SHEntry.
@@ -11916,9 +11920,8 @@ nsresult nsDocShell::AddToSessionHistory(
                triggeringPrincipal,  // Channel or provided principal
                principalToInherit, partitionedPrincipalToInherit, csp,
                HistoryID(), GetCreatedDynamically(), originalURI,
                resultPrincipalURI, unstrippedURI, loadReplace, referrerInfo,
                srcdoc, srcdocEntry, baseURI, saveLayoutState, expired,
                userActivation);
                resultPrincipalURI, loadReplace, referrerInfo, srcdoc,
                srcdocEntry, baseURI, saveLayoutState, expired, userActivation);

  if (mBrowsingContext->IsTop() && GetSessionHistory()) {
    bool shouldPersist = ShouldAddToSessionHistory(aURI, aChannel);
@@ -12003,7 +12006,6 @@ void nsDocShell::UpdateActiveEntry(
        aURI, aTriggeringPrincipal, nullptr, nullptr, aCsp, mContentTypeHint);
  }
  mActiveEntry->SetOriginalURI(aOriginalURI);
  mActiveEntry->SetUnstrippedURI(nullptr);
  mActiveEntry->SetReferrerInfo(aReferrerInfo);
  mActiveEntry->SetTitle(aTitle);
  mActiveEntry->SetStateData(static_cast<nsStructuredCloneContainer*>(aData));
+7 −8
Original line number Diff line number Diff line
@@ -578,7 +578,7 @@ bool nsDocShellLoadState::LoadIsFromSessionHistory() const {
}

void nsDocShellLoadState::MaybeStripTrackerQueryStrings(
    BrowsingContext* aContext) {
    BrowsingContext* aContext, nsIURI* aCurrentUnstrippedURI) {
  MOZ_ASSERT(aContext);

  // Return early if the triggering principal doesn't exist. This could happen
@@ -619,14 +619,17 @@ void nsDocShellLoadState::MaybeStripTrackerQueryStrings(
  uint32_t numStripped = URLQueryStringStripper::Strip(
      URI(), aContext->UsePrivateBrowsing(), strippedURI);
  if (numStripped) {
    if (!mUnstrippedURI) {
    mUnstrippedURI = URI();
    }
    SetURI(strippedURI);

    Telemetry::AccumulateCategorical(
        Telemetry::LABELS_QUERY_STRIPPING_COUNT::StripForNavigation);
    Telemetry::Accumulate(Telemetry::QUERY_STRIPPING_PARAM_COUNT, numStripped);
  } else if (LoadType() & nsIDocShell::LOAD_CMD_RELOAD) {
    // Preserve the Unstripped URI if it's a reload. By doing this, we can
    // restore the stripped query parameters once the ETP has been toggled to
    // off.
    mUnstrippedURI = aCurrentUnstrippedURI;
  }

#ifdef DEBUG
@@ -1073,7 +1076,3 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize() {
}

nsIURI* nsDocShellLoadState::GetUnstrippedURI() const { return mUnstrippedURI; }

void nsDocShellLoadState::SetUnstrippedURI(nsIURI* aUnstrippedURI) {
  mUnstrippedURI = aUnstrippedURI;
}
+2 −3
Original line number Diff line number Diff line
@@ -249,8 +249,6 @@ class nsDocShellLoadState final {

  nsIURI* GetUnstrippedURI() const;

  void SetUnstrippedURI(nsIURI* aUnstrippedURI);

  // Give the type of DocShell we're loading into (chrome/content/etc) and
  // origin attributes for the URI we're loading, figure out if we should
  // inherit our principal from the document the load was requested from, or
@@ -331,7 +329,8 @@ class nsDocShellLoadState final {
  void SetLoadIsFromSessionHistory(int32_t aOffset, bool aLoadingCurrentEntry);
  void ClearLoadIsFromSessionHistory();

  void MaybeStripTrackerQueryStrings(mozilla::dom::BrowsingContext* aContext);
  void MaybeStripTrackerQueryStrings(mozilla::dom::BrowsingContext* aContext,
                                     nsIURI* aCurrentUnstrippedURI = nullptr);

 protected:
  // Destructor can't be defaulted or inlined, as header doesn't have all type
+3 −22
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ SessionHistoryInfo::SessionHistoryInfo(nsDocShellLoadState* aLoadState,
    : mURI(aLoadState->URI()),
      mOriginalURI(aLoadState->OriginalURI()),
      mResultPrincipalURI(aLoadState->ResultPrincipalURI()),
      mUnstrippedURI(aLoadState->GetUnstrippedURI()),
      mLoadType(aLoadState->LoadType()),
      mSrcdocData(aLoadState->SrcdocData().IsVoid()
                      ? Nothing()
@@ -104,7 +103,6 @@ SessionHistoryInfo::SessionHistoryInfo(
  aChannel->GetLoadInfo(getter_AddRefs(loadInfo));

  loadInfo->GetResultPrincipalURI(getter_AddRefs(mResultPrincipalURI));
  loadInfo->GetUnstrippedURI(getter_AddRefs(mUnstrippedURI));
  loadInfo->GetTriggeringPrincipal(
      getter_AddRefs(mSharedState.Get()->mTriggeringPrincipal));
  loadInfo->GetPrincipalToInherit(
@@ -137,7 +135,6 @@ void SessionHistoryInfo::Reset(nsIURI* aURI, const nsID& aDocShellID,
  mURI = aURI;
  mOriginalURI = nullptr;
  mResultPrincipalURI = nullptr;
  mUnstrippedURI = nullptr;
  mReferrerInfo = nullptr;
  // Default title is the URL.
  nsAutoCString spec;
@@ -248,7 +245,6 @@ void SessionHistoryInfo::SetSaveLayoutStateFlag(bool aSaveLayoutStateFlag) {
void SessionHistoryInfo::FillLoadInfo(nsDocShellLoadState& aLoadState) const {
  aLoadState.SetOriginalURI(mOriginalURI);
  aLoadState.SetMaybeResultPrincipalURI(Some(mResultPrincipalURI));
  aLoadState.SetUnstrippedURI(mUnstrippedURI);
  aLoadState.SetLoadReplace(mLoadReplace);
  nsCOMPtr<nsIInputStream> postData = GetPostData();
  aLoadState.SetPostDataStream(postData);
@@ -532,19 +528,6 @@ SessionHistoryEntry::SetResultPrincipalURI(nsIURI* aResultPrincipalURI) {
  return NS_OK;
}

NS_IMETHODIMP
SessionHistoryEntry::GetUnstrippedURI(nsIURI** aUnstrippedURI) {
  nsCOMPtr<nsIURI> unstrippedURI = mInfo->mUnstrippedURI;
  unstrippedURI.forget(aUnstrippedURI);
  return NS_OK;
}

NS_IMETHODIMP
SessionHistoryEntry::SetUnstrippedURI(nsIURI* aUnstrippedURI) {
  mInfo->mUnstrippedURI = aUnstrippedURI;
  return NS_OK;
}

NS_IMETHODIMP
SessionHistoryEntry::GetLoadReplace(bool* aLoadReplace) {
  *aLoadReplace = mInfo->mLoadReplace;
@@ -1066,9 +1049,9 @@ SessionHistoryEntry::Create(
    nsIPrincipal* aPartitionedPrincipalToInherit,
    nsIContentSecurityPolicy* aCsp, const nsID& aDocshellID,
    bool aDynamicCreation, nsIURI* aOriginalURI, nsIURI* aResultPrincipalURI,
    nsIURI* aUnstrippedURI, bool aLoadReplace, nsIReferrerInfo* aReferrerInfo,
    const nsAString& aSrcdoc, bool aSrcdocEntry, nsIURI* aBaseURI,
    bool aSaveLayoutState, bool aExpired, bool aUserActivation) {
    bool aLoadReplace, nsIReferrerInfo* aReferrerInfo, const nsAString& aSrcdoc,
    bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState, bool aExpired,
    bool aUserActivation) {
  MOZ_CRASH("Might need to implement this");
  return NS_ERROR_NOT_IMPLEMENTED;
}
@@ -1530,7 +1513,6 @@ void IPDLParamTraits<dom::SessionHistoryInfo>::Write(
  WriteIPDLParam(aWriter, aActor, aParam.mURI);
  WriteIPDLParam(aWriter, aActor, aParam.mOriginalURI);
  WriteIPDLParam(aWriter, aActor, aParam.mResultPrincipalURI);
  WriteIPDLParam(aWriter, aActor, aParam.mUnstrippedURI);
  WriteIPDLParam(aWriter, aActor, aParam.mReferrerInfo);
  WriteIPDLParam(aWriter, aActor, aParam.mTitle);
  WriteIPDLParam(aWriter, aActor, aParam.mName);
@@ -1572,7 +1554,6 @@ bool IPDLParamTraits<dom::SessionHistoryInfo>::Read(
  if (!ReadIPDLParam(aReader, aActor, &aResult->mURI) ||
      !ReadIPDLParam(aReader, aActor, &aResult->mOriginalURI) ||
      !ReadIPDLParam(aReader, aActor, &aResult->mResultPrincipalURI) ||
      !ReadIPDLParam(aReader, aActor, &aResult->mUnstrippedURI) ||
      !ReadIPDLParam(aReader, aActor, &aResult->mReferrerInfo) ||
      !ReadIPDLParam(aReader, aActor, &aResult->mTitle) ||
      !ReadIPDLParam(aReader, aActor, &aResult->mName) ||
Loading