Skip to content

Commit 7481964

Browse files
authored
[worklets] Fixes the setup of the inside setttings object for worklets. (w3c#381)
* [worklets] Fixes the setup of the inside setttings object for worklets. Primarily based on: https://html.spec.whatwg.org/#set-up-a-worker-environment-settings-object Inherits a couple more things from the document. Fixes w3c#227 - inherits the HTTPS state from document
1 parent d154d09 commit 7481964

File tree

1 file changed

+57
-55
lines changed

1 file changed

+57
-55
lines changed

worklets/Overview.bs

Lines changed: 57 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,56 +26,33 @@ Editor: Ian Kilpatrick, ikilpatrick@chromium.org
2626
}
2727
</style>
2828

29+
<pre class=link-defaults>
30+
spec:fetch; type:dfn; for:/; text:fetch
31+
spec:html; type:dfn; for:/; text:browsing context
32+
spec:html; type:dfn; for:environment settings object;
33+
text: global object
34+
text: https state
35+
text: referrer policy
36+
spec:html; type:dfn; for:environment; text:id
37+
spec:webidl; type:dfn; for:interface; text:inherit
38+
</pre>
39+
2940
<pre class="anchors">
3041
urlPrefix: http://heycam.github.io/webidl/; type: dfn;
3142
text: AbortError
3243
text: SyntaxError
3344
urlPrefix: #idl-;
3445
text: DOMException
35-
urlPrefix: #dfn-;
36-
text: inherit
3746
urlPrefix: #es-;
3847
text: invoking callback functions
39-
urlPrefix: https://fetch.spec.whatwg.org/; type: dfn;
40-
urlPrefix: #concept-;
41-
text: fetch
42-
urlPrefix: https://html.spec.whatwg.org/multipage/browsers.html; type: dfn;
43-
text: effective script origin
44-
url: #origin-2; text: origin
4548
urlPrefix: https://html.spec.whatwg.org/multipage/workers.html; type: dfn;
46-
text: web workers
4749
urlPrefix: #dom-workerglobalscope-;
4850
text: self
4951
urlPrefix: https://html.spec.whatwg.org/multipage/webappapis.html; type: dfn;
50-
text: api base url
51-
text: api url character encoding
52-
text: browsing context
53-
text: code entry-point
54-
text: creation url
5552
text: document environment
56-
text: environment settings object
57-
text: event loop
5853
text: event loop processing model
59-
text: global object
60-
text: https state
61-
text: incumbent settings object
6254
text: microtask queue
63-
text: module script
64-
text: perform the request
65-
text: realm execution context
66-
text: relevant settings object
67-
text: responsible browsing context
68-
text: responsible document
69-
text: responsible event loop
70-
text: run a module script
71-
text: script execution environment
7255
text: task queues
73-
urlPrefix: https://html.spec.whatwg.org/multipage/infrastructure.html; type: dfn;
74-
text: cors setting attribute
75-
text: in parallel
76-
url: resolve-a-url; text: resolve;
77-
urlPrefix: https://www.w3.org/2001/tag/doc/promises-guide; type: dfn;
78-
text: a new promise
7956
urlPrefix: http://www.ecma-international.org/ecma-262/6.0/#sec-; type: dfn;
8057
text: Construct
8158
text: InitializeHostDefinedRealm
@@ -162,6 +139,9 @@ interface WorkletGlobalScope {
162139

163140
Each {{WorkletGlobalScope}} has an associated <a>environment settings object</a>.
164141

142+
Each {{WorkletGlobalScope}} has an associated <dfn for=WorkletGlobalScope>module map</dfn>. It is a
143+
<a>module map</a>, initially empty.
144+
165145
Each {{WorkletGlobalScope}} has a <dfn>worklet global scope execution environment</dfn>. This
166146
execution environment may be parallel (i.e. it may be on a separate thread, process, or other
167147
equivalent construct), or it may live on the same thread or process as the {{Worklet}} object it
@@ -209,7 +189,7 @@ When a user agent is to <dfn>create a WorkletGlobalScope</dfn>, given |workletGl
209189
- Do not obtain any source texts for scripts or modules.
210190

211191
3. Let |insideSettings| be the result of <a>set up a worklet environment settings object</a>
212-
with |realmExecutionContext|.
192+
given |realmExecutionContext|, and |outsideSettings|.
213193

214194
4. Associate the |insideSettings| with |workletGlobalScope|.
215195

@@ -236,26 +216,46 @@ When a user agent is to <dfn>create a WorkletGlobalScope</dfn>, given |workletGl
236216

237217
<div algorithm>
238218
When a user agent is to <dfn>set up a worklet environment settings object</dfn>, given a
239-
|executionContext|, it must run the following steps:
240-
1. Let |inheritedResponsibleBrowsingContext| be the <a>responsible browsing context</a>
241-
specified by the <a>incumbent settings object</a>.
219+
|executionContext|, and |outsideSettings|, it must run the following steps:
220+
1. Let |inheritedResponsibleBrowsingContext| be |outsideSettings|'s <a>responsible browsing
221+
context</a>.
222+
223+
2. Let |id| be a new unique opaque string.
224+
225+
3. Let |inheritedAPIBaseURL| be |outsideSettings|'s <a>API base URL</a>.
226+
227+
4. Let |origin| be a unique <a>opaque origin</a>.
242228

243-
2. Let |inheritedOrigin| be the <a>origin</a> specified by the <a>incumbent settings object</a>.
229+
5. Let |inheritedHTTPSState| be |outsideSettings|'s <a>HTTPS state</a>.
244230

245-
3. Let |inheritedAPIBaseURL| be the <a>API base URL</a> specified by the <a>incumbent settings object</a>.
231+
6. Let |inheritedReferrerPolicy| be |outsideSettings|'s <a>referrer policy</a>.
246232

247-
4. Let |workletEventLoop| be a newly created <a>event loop</a>.
233+
7. Let |workletEventLoop| be a newly created <a>event loop</a>.
248234

249-
5. Let |workletGlobalScope| be |executionContext|'s <a>global object</a>.
235+
8. Let |realm| be the value of |executionContext|'s Realm component.
250236

251-
6. Let |settingsObject| be a new <a>environment settings object</a> whose algorithms are
237+
9. Let |workletGlobalScope| be |realm|'s <a>global object</a>.
238+
239+
10. Let |settingsObject| be a new <a>environment settings object</a> whose algorithms are
252240
defined as follows:
253241

242+
: The <a>id</a>
243+
:: Return |id|.
244+
245+
: The <a>Creation URL</a>
246+
:: Return |inheritedAPIBaseURL|.
247+
248+
: The <a>target browsing context</a>
249+
:: Return null.
250+
251+
: The <a>active service worker</a>
252+
:: Return null.
253+
254254
: The <a>realm execution context</a>
255255
:: Return |executionContext|.
256256

257-
: The <a>global object</a>
258-
:: Return |workletGlobalScope|.
257+
: The <a>module map</a>.
258+
:: Return |workletGlobalScope|'s <a for=WorkletGlobalScope>module map</a>.
259259

260260
: The <a>responsible browsing context</a>
261261
:: Return |inheritedResponsibleBrowsingContext|.
@@ -265,24 +265,26 @@ When a user agent is to <dfn>set up a worklet environment settings object</dfn>,
265265

266266
: The <a>responsible document</a>
267267
:: Not applicable (the <a>responsible event loop</a> is not a <a>browsing context</a>
268-
<a>event loop</a>).
268+
<a>event loop</a>).
269269

270270
: The <a>API URL character encoding</a>
271-
:: Return UTF-8.
271+
:: Return <a>UTF-8</a>.
272272

273273
: The <a>API base URL</a>
274274
:: Return |inheritedAPIBaseURL|.
275275

276-
: The <a>origin</a> and <a>effective script origin</a>
277-
:: Return |inheritedOrigin|.
278-
279-
: The <a>creation URL</a>
280-
:: Not applicable.
276+
: The <a for="environment settings object">origin</a>
277+
:: Return |origin|.
281278

282279
: The <a>HTTPS state</a>
283-
:: Return |workletGlobalScope|'s <a>HTTPS state</a>.
280+
:: Return |inheritedHTTPSState|.
281+
282+
: The <a>referrer policy</a>
283+
:: Return |inheritedReferrerPolicy|.
284+
285+
11. Set |realm|'s \[[HostDefined]] field to |settingsObject|.
284286

285-
7. Return |settingsObject|.
287+
12. Return |settingsObject|.
286288
</div>
287289

288290
Issue: Merge this with https://html.spec.whatwg.org/multipage/workers.html#set-up-a-worker-environment-settings-object
@@ -429,7 +431,7 @@ Note: This algorithm is to be run within the <a>worklet global scope execution e
429431
1. <a>Fetch a module worker script graph</a> given |moduleURLRecord|, |outsideSettings|, "script",
430432
|credentialOptions|, and |insideSettings|.
431433

432-
To <a>perform the request</a> given |request|, perform the following steps:
434+
To <a>perform the fetch</a> given |request|, perform the following steps:
433435

434436
1. Let |cache| be the |moduleResponsesMap|.
435437

0 commit comments

Comments
 (0)