Skip to content

Adds WorkletGlobalScope as a concept to CSP. #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ <h3 id="framework-infrastructure">Infrastructure</h3>
<h3 id="framework-policy">Policies</h3>

A <dfn export lt="content security policy object" local-lt="policy">policy</dfn> defines allowed
and restricted behaviors, and may be applied to a {{Window}} or {{WorkerGlobalScope}} as described
in [[#initialize-global-object-csp]].
and restricted behaviors, and may be applied to a {{Window}}, {{WorkerGlobalScope}, or
{{WorkletGlobalScope}} as described in [[#initialize-global-object-csp]].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to hook into https://w3c.github.io/webappsec-csp/#initialize-global-object-csp somewhere so that it's called when the Worklet is initialized. And you'll probably need to alter that algorithm as well to inherit the document's policy into the worklet (assuming that's what you need).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any worklet can currently fetch resources, so that's probably not needed. Although maybe it's nice for unsafe-inline so eval() can be made to throw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created w3c/css-houdini-drafts#467 which does this. And modified the algorithm below which copies the owner document's policy.


Each policy has an associated <dfn for="policy" export>directive set</dfn>, which is an <a>ordered
set</a> of <a>directives</a> that define the policy's implications when applied.
Expand Down Expand Up @@ -1084,7 +1084,7 @@ <h3 id="html-integration">
Integration with HTML
</h3>

1. The {{Document}} and {{WorkerGlobalScope}} objects have a
1. The {{Document}}, {{WorkerGlobalScope}}, and {{WorkletGlobalScope}} objects have a
<dfn for="global object" id="global-object-csp-list">CSP list</dfn>,
which holds all the <a for="/">policy</a> objects which are active for a given
context. This list is empty unless otherwise specified, and is populated
Expand Down Expand Up @@ -1223,6 +1223,14 @@ <h4 id="initialize-global-object-csp" algorithm>
<a for="response">CSP list</a>, insert |policy| into
|global|'s <a for="global object">CSP list</a>.

3. If |global| is a {{WorkletGlobalScope}}:

1. Let |owner| be |global|'s [=WorkletGlobalScope/owner document=].

2. For each |policy| in |owner|'s <a for="global object">CSP list</a>:

1. Insert an alias to |policy| in |global|'s <a for="global object">CSP list</a>.

<h4 id="should-block-inline" algorithm>
Should |element|'s inline |type| behavior be blocked by Content Security Policy?
</h4>
Expand Down