Skip to content

Integrate with speculation rules #808

Open
vickiez wants to merge 3 commits intow3c:mainfrom
vickiez:external-spec-rules
Open

Integrate with speculation rules #808
vickiez wants to merge 3 commits intow3c:mainfrom
vickiez:external-spec-rules

Conversation

@vickiez
Copy link
Copy Markdown

@vickiez vickiez commented Mar 13, 2026

Adds the following:

From #776:

  • New directive inline-speculation-rules to be used if developers want to block inline JavaScript <script>s but allow inline <script type="speculationrules">. Uses a new script type, script speculationrules, passed by the HTML
  • Handling of the new "speculationrules" request destination, which is used by the Speculation-Rules HTTP header

New additions:

  • New speculation-rules-src fetch directive that restricts the sources from which speculation rules may be loaded, whether via <script> elements or the Speculation-Rules HTTP response header
  • Fallback chain: speculation-rules-srcscript-src-elemscript-srcdefault-src, applied uniformly to both inline and external speculation rules
  • Handling of the "speculationrules" request destination now returns speculation-rules-src (removing the previous header exemption that returned null).

This reflects the agreed plan from whatwg/html#11697


Preview | Diff

domenic and others added 3 commits April 1, 2026 14:03
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.
@vickiez vickiez force-pushed the external-spec-rules branch from 22806ee to 4e8aad7 Compare April 1, 2026 21:05
@vickiez vickiez marked this pull request as ready for review April 1, 2026 21:05
@antosart
Copy link
Copy Markdown
Member

antosart commented Apr 2, 2026

We don't need the keyword inline-speculation-rules if we have speculation-rules-src, no? Developers will just be able to specify speculation-rules src 'unafe-inline'; script-src 'none' or something. I think having both is just confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants