Skip to content

Commit

Permalink
Fix: dedicated workers can be created from shared ones
Browse files Browse the repository at this point in the history
  • Loading branch information
kenchris committed Oct 16, 2023
1 parent bf532c0 commit add2e53
Showing 1 changed file with 35 additions and 55 deletions.
90 changes: 35 additions & 55 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,27 +890,30 @@ <h3>Supporting algorithms</h3>
</ul>
</aside>
<p>
To determine the <dfn>owning global object</dfn> for a {{DedicatedWorkerGlobalScope}} |workerGlobalScope|:
To determine the <dfn>owning global object set</dfn> for a {{WorkerGlobalScope}} |workerGlobalScope|:
<ol>
<li>
If |workerGlobalScope|'s [=WorkerGlobalScope/owner set=] consists of a single {{Document}} |document|,
then return |document|'s [=relevant global object=].
Let |owningGlobalObjectSet| be am empty set.
</li>
<li>
If |workerGlobalScope|'s [=WorkerGlobalScope/owner set=] consists of a single {{DedicatedWorkerGlobalScope}}
|parentWorkerGlobalScope|, then return |parentWorkerGlobalScope|'s [=owning global object=].
</li>
<li>
Return null.
[=list/For each=] |owner| in |workerGlobalScope|'s [=WorkerGlobalScope/owner set=]:
<ol>
<li>
If |owner| is a {{Document}}, then [=set/append=] |owner|'s [=relevant global object=] to |owningGlobalObjectSet|.
</li>
<li>
If |owner| is a {{WorkerGlobalScope}}, set |owningGlobalObjectSet| to the [=set/union=] of
|owningGlobalObjectSet| and |owner|'s [=owning global object set=].
</li>
</ol>
<li>
Return |owningGlobalObjectSet|.
</li>
</li>
</ol>
<aside class="note">
A {{DedicatedWorkerGlobalScope}}'s [=WorkerGlobalScope/owner set=] will always have exactly one item.
</aside>
</p>
<p>
The <dfn>passes window privacy test</dfn> steps given the argument |observer:PressureObserver| and
its [=relevant global object=] |relevantGlobal|, are as follows:
The <dfn>window has implicit focus</dfn> steps given the argument [=relevant global object=] |relevantGlobal|, are as follows:
<ol>
<li>
Assert: |relevantGlobal| is a {{Window}} object.
Expand Down Expand Up @@ -952,64 +955,41 @@ <h3>Supporting algorithms</h3>
</ol>
</p>
<p>
The <dfn>passes privacy test</dfn> steps given the argument |observer:PressureObserver| and
its [=relevant global object=] |relevantGlobal|, are as follows:
The <dfn>may receive data</dfn> steps given the argument |observer:PressureObserver| are as follows:
<ol>
<li>
Let |relevantGlobal| be |observer|'s [=relevant global object=].
</li>
<li>
If |relevantGlobal| is a {{Window}} object:
<ol>
<li>
Return the result of running [=window has implicit focus=] with |relevantGlobal|.
</li>
</ol>
</li>
<li>
If |relevantGlobal| is a {{WorkerGlobalScope}} object:
<ol>
<li>Let |owningGlobals| be |relevantGlobal|'s [=owning global object set=].</li>
<li>
If |relevantGlobal| is a {{DedicatedWorkerGlobalScope}} object:
[=list/For each=] |windowGlobal| in |owningGlobals|:
<ol>
<li>
Let |ownerGlobal| be |relevantGlobal|'s [=owning global object=].
</li>
<li>
If |ownerGlobal| is null, return false.
</li>
<li>
Return the result of running [=passes window privacy test=] with |observer| and |ownerGlobal|.
If the result of running [=window has implicit focus=] with |windowGlobal| is true,
return true.
</li>
</ol>
</li>
<li>
If |relevantGlobal| is a {{SharedWorkerGlobalScope}} object:
<ol>
<li>
[=list/For each=] |owner| in |relevantGlobal|'s [=WorkerGlobalScope/owner set=]:
<ol>
<li>
Assert: |owner| is {{Document}}.
</li>
<li>
If the result of running [=passes window privacy test=] with |observer| and |owner|'s
[=relevant global object=] is true, return true, or else [=iteration/continue=].
</li>
</ol>
<li>
Return false.
</li>
Otherwise, [=iteration/continue=].
</li>
</ol>
</li>
</ol>
</li>
<li>
If |relevantGlobal| is a {{Window}} object:
<ol>
<li>
Return the result of running [=passes window privacy test=] with |observer| and |relevantGlobal|.
</li>
</ol>
</li>
<li>
Return false.
</li>
</ol>
<aside class="note">
{{SharedWorkerGlobalScope}} is only exposed to the {{Window}} object, so shared workers
can only be created in this scope, which means that all owners will be {{Document}} objects.
</aside>
<aside class="note">
As there might be multiple observers, each with a different [=requested sampling rate=], the underlying
[=platform collector=] will need to use a [=sampling rate=] that fulfills all these requirements. This also
Expand Down Expand Up @@ -1106,7 +1086,7 @@ <h3>Data delivery</h3>
[=registered observer list=] for |source|:
<ol>
<li>
If running [=passes privacy test=] with |observer|
If running [=may receive data=] with |observer|
returns false, [=iteration/continue=].
</li>
<li>
Expand Down Expand Up @@ -1276,7 +1256,7 @@ <h3>Handling change of fully active</h3>
<a href="https://html.spec.whatwg.org/multipage/workers.html#active-needed-worker">
active needed workers</a>), like when
entering the back/forward cache, or "BFCache" for short, then no events are send to the pressure observers
(see [=passes privacy test=])
(see [=may receive data=])
in accordance with <a href="https://www.w3.org/TR/design-principles/#listen-fully-active">
Web Platform Design Principles: Listen for changes to fully active status</a>. This means that the
system can safely deactivate [=data delivery=] from the associated [=platform collector=],
Expand Down

0 comments on commit add2e53

Please sign in to comment.