diff --git a/index.bs b/index.bs index a322dbda..09f14f81 100644 --- a/index.bs +++ b/index.bs @@ -137,9 +137,6 @@ spec:fetch; type:dfn; text:value indicated, the term "feature" refers to policy-controlled features. Other specifications, defining such features, should use the longer term to avoid any ambiguity. -
This spec currently only deals with features defined in - Documents. We should figure out how to word this to include the possibility - of features and feature policies in Workers and Worklets as well.

Policy-controlled features are identified by tokens, which are character strings used in policy directives.

Each policy-controlled feature has a default allowlist, @@ -184,15 +181,18 @@ spec:fetch; type:dfn; text:value

Each document in a frame tree inherits a set of policies from its parent frame, or in the case of the top-level document, from the defined defaults - for each policy-controlled feature. This inherited policy determines - the initial state ('Enabled' or 'Disabled') of each feature, and whether it - can be controlled by a declared policy in the document. + for each policy-controlled feature. For workers, the policies are + inherited from the context that created the worker. This inherited policy + determines the initial state ('Enabled' or 'Disabled') of each feature, and + whether it can be controlled by a declared policy in the document.

In a {{Document}} in a [=top-level browsing context=], the inherited policy is based on defined defaults for each feature.

In a {{Document}} in a [=nested browsing context=], the inherited policy is based on the parent document's feature policy, as well as the [=nested browsing context=]'s container policy. +

In a {{Worker}} created by a {{Document}}, the inherited policy is based + on the document's feature policy.

@@ -530,6 +530,37 @@ partial interface HTMLIFrameElement { Monkey-patching! As soon as we know that this is the direction we wish to pursue, upstream all of this. +

Integration with Workers

+
    +
  1. Worker objects have a + Feature Policy, which is initially + empty.
  2. +
  3. Using the responsible browsing context parent context from + the worker's [[script settings]], retrieve the + parent context's Feature Policy feature + policy.
  4. +
  5. Execute the algorithm on the + Worker object.
  6. +
  7. A feature policy is enforced for a + Worker by setting it as the + Worker's Feature Policy.
  8. +
  9. To determine whether a Worker object + worker is allowed to use the policy-controlled-feature + feature, run these steps: +
      +
    1. If worker's feature policy + enables feature for the + origin of worker, then return true.

    2. +
    3. Return false.

    4. +
    +
  10. +
+
+ The integration with Workers only specifies inherited policies for now. + Eventually we would want to allow worker scripts to be delivered with a + Feature-Policy header and for the owner of the worker to set the container + policy for the worker. +
@@ -780,7 +811,7 @@ partial interface HTMLIFrameElement {

Initialize document's Feature - Policy

+ Policy

Given a Document object (document), this algorithm initialises document's Feature Policy

    @@ -805,6 +836,30 @@ partial interface HTMLIFrameElement {
+
+

Initialize worker's Feature + Policy

+

Given a Worker object + (worker), this algorithm initialises worker's + Feature Policy

+
    +
  1. Let inherited policy be a new ordered map.
  2. +
  3. Let declared policy be a new ordered map.
  4. +
  5. For each feature supported, +
      +
    1. Let isInherited be the result of running on feature and + worker's browsing context.
    2. +
    3. Set inherited policy[feature] to + isInherited.
    4. +
    +
  6. +
  7. Let policy be a new feature policy, with inherited + policy inherited policy and declared policy declared + policy.
  8. +
  9. Enforce the policy policy on worker.
  10. +
+

Initialize document's Feature Policy from response

@@ -839,8 +894,9 @@ partial interface HTMLIFrameElement {

Define an inherited policy for feature

Given a feature (feature) and a browsing context - (context), this algorithm returns the inherited policy - for that feature.

+ (context), this algorithm returns the + inherited policy for that feature + .

  1. If context is a [=nested browsing context=]:
      @@ -868,18 +924,43 @@ partial interface HTMLIFrameElement {
    1. Otherwise, return 'Disabled'.
  2. +
  3. If context is a WorkerGlobalScope: +
      +
    1. + Let parent be the parent context that created the worker. +
    2. +
    3. Let origin be parent's [=origin=].
    4. +
    5. Let container policy be the parent's container + policy.
    6. +
    7. If feature is a key in container policy: +
        +
      1. If the allowlist for feature in + container policy matches origin, and + parent's inherited policy for + feature is 'Enabled', return 'Enabled'. +
      2. +
      3. Otherwise return 'Disabled'.
      4. +
      +
    8. +
    9. Otherwise, if feature is + enabled in parent for origin, return + 'Enabled'. +
    10. +
    11. Otherwise, return 'Disabled'.
    12. +
    +
  4. Otherwise, return 'Enabled'.

Is feature enabled in - document for origin?

-

Given a feature (feature), a Document object - (document), and an [=origin=] (origin), this algorithm + document or worker for origin? +

Given a feature (feature), a Document or Worker object + (context), and an [=origin=] (origin), this algorithm returns "Disabled" if feature should be considered disabled, and "Enabled" otherwise.

    -
  1. Let policy be document's Feature Policy +
  2. Let policy be context's Feature Policy
  3. If policy's inherited policy for feature is Disabled, return "Disabled".
  4. @@ -898,7 +979,7 @@ partial interface HTMLIFrameElement {
  5. If feature's default allowlist is 'self', and origin is [=same origin-domain=] - with document's origin, return "Enabled". + with context's origin, return "Enabled".
  6. Return "Disabled".
diff --git a/index.html b/index.html index 4168b0ec..6ae8130a 100644 --- a/index.html +++ b/index.html @@ -1176,9 +1176,9 @@ } } - + - +