Skip to content

Commit

Permalink
Flag ServiceWorkerGlobalScope as SecureContext
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tidoust committed Feb 7, 2024
1 parent 4711a07 commit 0782416
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
<h3 id="serviceworkerglobalscope-interface">{{ServiceWorkerGlobalScope}}</h3>

<pre class="idl">
[Global=(Worker,ServiceWorker), Exposed=ServiceWorker]
[Global=(Worker,ServiceWorker), Exposed=ServiceWorker, SecureContext]
interface ServiceWorkerGlobalScope : WorkerGlobalScope {
[SameObject] readonly attribute Clients clients;
[SameObject] readonly attribute ServiceWorkerRegistration registration;
Expand Down

0 comments on commit 0782416

Please sign in to comment.