Skip to content
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

Flag ServiceWorkerGlobalScope as SecureContext #1704

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

tidoust
Copy link
Member

@tidoust tidoust commented Feb 7, 2024

Context for this is Open Web Docs people looking into automating the handling of "this feature is available only in secure contexts" banners in MDN pages. This led to the discussion with @annevk in w3c/webref#1142 (comment)

When it is set, the [SecureContext] IDL extended attribute explicitly gives the information. That said, to avoid redundancies, that attribute is usually not set on interfaces that are exposed (through [Exposed=xxx]) to globals that are already restricted to secure contexts.

The Service workers spec is clear that service workers must execute in secure contexts. However, it does not fully say so in the IDL itself. More specifically, when an interface defined in another spec has [Exposed=ServiceWorker], that's a reference to the ServiceWorkerGlobalScope interface, and that interface does not have a [SecureContext] attribute.

This PR proposes to add a [SecureContext] attribute to ServiceWorkerGlobalScope to make it possible to derive the fact that service workers must execute in secure contexts automatically.

This approach is consistent with the way WorkletGlobalScope, from which a number of other globals inherit, is defined.


Preview | Diff

Context for this is Open Web Docs people looking into automating the handling
of "this feature is available only in secure contexts" banners in MDN pages.
This led to the discussion in:
w3c/webref#1142 (comment)

When it is set, the `[SecureContext]` IDL extended attribute explicitly gives
the information. That said, to avoid redundancies, that attribute is not set on
interfaces that are exposed (through `[Exposed=xxx]`) on globals that are
already restricted to secure contexts/

The Service workers spec is clear that service workers must execute in secure
contexts:
https://w3c.github.io/ServiceWorker/#secure-context

However, it does not fully say so in the IDL itself. More specifically, when
an interface defined in another spec has `[Exposed=ServiceWorker]`, that's a
reference to the `ServiceWorkerGlobalScope` interface, and that interface does
not have a `[SecureContext]` attribute.

This commit adds the `[SecureContext]` attribute to `ServiceWorkerGlobalScope`.

This approach is consistent with the way `WorkletGlobalScope`, from which a
number of other globals inherit, is defined:
https://html.spec.whatwg.org/multipage/worklets.html#worklets-global
Copy link
Collaborator

@mkruisselbrink mkruisselbrink left a comment

Choose a reason for hiding this comment

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

lgtm

@mkruisselbrink mkruisselbrink merged commit dc2efeb into w3c:main Feb 15, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Feb 15, 2024
SHA: dc2efeb
Reason: push, by mkruisselbrink

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit to asleekgeek/ServiceWorker that referenced this pull request Feb 17, 2024
SHA: dc2efeb
Reason: push, by pull[bot]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants