From 0e2bdcfc93019cb56eaa6df9793910d8090eda64 Mon Sep 17 00:00:00 2001 From: Antonio Sartori Date: Mon, 31 May 2021 13:28:39 +0200 Subject: [PATCH] Move referrer policy into policy container This change moves referrer policy from Document/WorkerGlobalScope into policy container. This allows us to simplify several steps (initializing for new empty documents, populating from the response headers, inheriting for local scheme documents), since they are handled centrally via the policy container mechanisms. Companion PRs: * https://github.com/whatwg/fetch/pull/1233 * https://github.com/w3c/ServiceWorker/pull/1593 (removes referrer policy from service workers as that comes for free with policy container) * https://github.com/w3c/webappsec-referrer-policy/pull/152 The change is mostly a refactoring and should have no significant behavioral changes, apart from simplifying the referrer policy inheritance mechanism. The most visible behavioral change of this is that referrer policy of a srcdoc iframe will be now copied from the parent document at creation time instead of referencing the parent document referrer policy. --- source | 85 +++++++++++++--------------------------------------------- 1 file changed, 18 insertions(+), 67 deletions(-) diff --git a/source b/source index 43afe6641ff..a92a00a0afb 100644 --- a/source +++ b/source @@ -9202,11 +9202,6 @@ partial interface Document { for="Document">policy container (a policy container), initially a new policy container, which contains policies which apply to the Document.

-

The Document has a referrer policy (a referrer policy), initially the empty string, - which represents the default referrer policy used by fetches initiated by the Document.

-

The Document has an embedder policy (an embedder policy).

@@ -14348,8 +14343,9 @@ interface HTMLMetaElement : HTMLElement {
  • If value is a referrer policy, then set element's - node document's referrer - policy to policy.

  • + node document's policy + container's referrer policy to + policy.

    The fact that these steps are applied for each element enables document's referrer to the serialization of it.

    -
  • If creator is non-null, then set document's - referrer policy to creator's - referrer policy.

  • -
  • If creator is non-null, then set document's embedder policy to creator's embedder policy.

  • @@ -80820,23 +80812,6 @@ interface BarProp { Document.

    -
    The referrer policy
    -
    -
      -
    1. Let document be window's associated Document.

    2. - -
    3. While document is an iframe - srcdoc document and document's - referrer policy is the empty - string, set document to document's - browsing context's - container document.

    4. - -
    5. Return document's referrer - policy.

    6. -
    -
    The embedder policy

    Return window's associated Document's embedder @@ -83504,6 +83479,10 @@ interface BarProp {

    • A CSP list, which is a CSP list. It is initially empty.

    • + +
    • A referrer + policy, which is a referrer policy. It is initially the default referrer + policy.

    Move other policies into the policy container.

    @@ -83519,6 +83498,10 @@ interface BarProp { data-x="list append">append a copy of policy into clone's CSP list.

    +
  • Set clone's referrer + policy to policyContainer's referrer policy.

  • +
  • Return clone.

  • @@ -83560,6 +83543,11 @@ interface BarProp { result of parsing a response's Content Security Policies given response.

    +
  • Set result's referrer + policy to the result of parsing the + `Referrer-Policy` header given response.

  • +
  • Return result.

  • @@ -86324,10 +86312,8 @@ interface Location { // but see also
    Type(result) is String, then set response to a response whose header list consists of - `Content-Type`/`text/html` and `Referrer-Policy`/settings's referrer - policy, and whose body is - result.

    + `Content-Type`/`text/html`, and whose body is result.

    The exact conversion between the string result and the bytes that comprise a response body is not yet specified, @@ -86503,11 +86489,6 @@ interface Location { // but see also loading".

    -
  • Set document's referrer - policy to the result of parsing the - `Referrer-Policy` header of navigationParams's response.

  • -
  • If navigationParam's reserved environment is non-null, then set document's embedder policy to @@ -88716,13 +88697,6 @@ interface BeforeUnloadEvent : Event {

    A policy container containing policies used for security checks.

  • -
    A referrer policy
    - -

    The default referrer policy for fetches - performed using this environment settings object as a request client. -

    An embedder policy
    @@ -100027,10 +100001,6 @@ interface WorkerGlobalScope : EventTarget { data-x="concept-WorkerGlobalScope-policy-container">policy container (a policy container). It is initially a new policy container.

    -

    A WorkerGlobalScope object has an associated referrer policy (a referrer - policy). It is initially the empty string.

    -

    A WorkerGlobalScope object has an associated embedder policy (an embedder policy).

    @@ -100470,11 +100440,6 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope { data-x="">Blocked" when executed upon worker global scope, set response to a network error.

    -
  • Set worker global scope's referrer policy to the result of - parsing the `Referrer-Policy` - header of response.

  • -
  • If response's url's scheme is a local scheme, then set worker global scope's SharedWorkerGlobalScope : WorkerGlobalScope { data-x="concept-WorkerGlobalScope-policy-container">policy container.

    -
    The referrer policy
    -
    -

    Return worker global scope's referrer policy.

    -
    -
    The embedder policy

    Return worker global scope's WorkletGlobalScope {}; container">clone of outsideSettings's policy container.

  • -
  • Let inheritedReferrerPolicy be outsideSettings's referrer policy.

  • -
  • Let inheritedEmbedderPolicy be outsideSettings's embedder policy.

  • @@ -102004,11 +101960,6 @@ interface WorkletGlobalScope {};

    Return inheritedPolicyContainer.

    -
    The referrer policy
    -
    -

    Return inheritedReferrerPolicy.

    -
    -
    The embedder policy

    Return inheritedEmbedderPolicy.