Verified Commit 13ae5d38 authored by Simon Friedberger's avatar Simon Friedberger Committed by ma1
Browse files

Bug 1984940: Make sec-fetch user-triggered check default to secure r=ckerschb

parent a3c1e20c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -232,6 +232,8 @@ bool IsSameSite(nsIChannel* aHTTPChannel) {

// Helper function to determine whether a request was triggered
// by the end user in the context of SecFetch.
// The more secure/closed state to return for this function is "false".
// A user triggered action is less restricted because it is not cross-origin.
bool IsUserTriggeredForSecFetchSite(nsIHttpChannel* aHTTPChannel) {
  /*
   * The goal is to distinguish between "webby" navigations that are controlled
@@ -243,8 +245,7 @@ bool IsUserTriggeredForSecFetchSite(nsIHttpChannel* aHTTPChannel) {
  ExtContentPolicyType contentType = loadInfo->GetExternalContentPolicyType();

  // A request issued by the browser is always user initiated.
  if (loadInfo->TriggeringPrincipal()->IsSystemPrincipal() &&
      contentType == ExtContentPolicy::TYPE_OTHER) {
  if (loadInfo->TriggeringPrincipal()->IsSystemPrincipal()) {
    return true;
  }

@@ -279,12 +280,12 @@ bool IsUserTriggeredForSecFetchSite(nsIHttpChannel* aHTTPChannel) {
  if (referrerInfo) {
    nsCOMPtr<nsIURI> originalReferrer;
    referrerInfo->GetOriginalReferrer(getter_AddRefs(originalReferrer));
    if (originalReferrer) {
      return false;
    if (!originalReferrer) {
      return true;
    }
  }

  return true;
  return false;
}

void mozilla::dom::SecFetch::AddSecFetchDest(nsIHttpChannel* aHTTPChannel) {