Integrate with speculation rules #808
Conversation
This upstreams the monkeypatches from https://wicg.github.io/nav-speculation/speculation-rules.html#content-security-policy. At a high level, the additions are: - A new directive, `inline-speculation-rules`, which can be used if developers want to block inline JavaScript `<script>`s but allow inline `<script type=speculationrules>`s. This is done by introducing a new script type, `script speculationrules`, to sit alongside the existing `script` and `script attribute` types; HTML passes this new value in. - Handling of the new `"speculationrules"` request destination, which is used by the `Speculation-Rules` HTTP header. It cannot be blocked by CSP.
22806ee to
4e8aad7
Compare
|
We don't need the keyword |
|
IIUC (please correct me if wrong) this PR contains a major behavior changes that would break existing websites without updates to pages' CSP : To avoid breakage, pages should e.g. add cc/ @tunetheweb @nhiroki WDYT? FYI Also see whatwg/html#11697 (comment) whatwg/html#11697 (comment) and around for previous context for direction/planning around external speculation rules. |
|
Also this PR applies |
|
Yes I thought we’d previously agreed that the HTTP Header version was out of scope? Because if you’ve the ability to set HTTP Headers then you’ve no guarantees on CSP anyway (since that is also usually set via HTTP Headers). Also can I understand which this does for |
|
CSP should apply to links in HTTP headers as well to remain consistent. |
Adds the following:
From #776:
Note: No longer need to add
inline-speculation-rulesfrom #776 because it is redundant with the addition of thespeculation-rules-srcdirective described below.New additions:
speculation-rules-srcfetch directive that restricts the sources from which speculation rules may be loaded, whether via <script> elements or the Speculation-Rules HTTP response headerspeculation-rules-src→script-src-elem→script-src→default-src, applied uniformly to both inline and external speculation rulesspeculation-rules-src(removing the previous header exemption that returned null).This reflects the agreed plan from whatwg/html#11697
Preview | Diff