Skip to content
Permalink
Browse files

[worklets] Fixes the setup of the inside setttings object for worklet…

…s. (#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 #227 - inherits the HTTPS state from document
  • Loading branch information...
bfgeek committed Apr 13, 2017
1 parent d154d09 commit 7481964e1d2e9dfc3b241d9c6a58bf478bae6f88
Showing with 57 additions and 55 deletions.
  1. +57 −55 worklets/Overview.bs
@@ -26,56 +26,33 @@ Editor: Ian Kilpatrick, ikilpatrick@chromium.org
}
</style>

<pre class=link-defaults>
spec:fetch; type:dfn; for:/; text:fetch
spec:html; type:dfn; for:/; text:browsing context
spec:html; type:dfn; for:environment settings object;
text: global object
text: https state
text: referrer policy
spec:html; type:dfn; for:environment; text:id
spec:webidl; type:dfn; for:interface; text:inherit
</pre>

<pre class="anchors">
urlPrefix: http://heycam.github.io/webidl/; type: dfn;
text: AbortError
text: SyntaxError
urlPrefix: #idl-;
text: DOMException
urlPrefix: #dfn-;
text: inherit
urlPrefix: #es-;
text: invoking callback functions
urlPrefix: https://fetch.spec.whatwg.org/; type: dfn;
urlPrefix: #concept-;
text: fetch
urlPrefix: https://html.spec.whatwg.org/multipage/browsers.html; type: dfn;
text: effective script origin
url: #origin-2; text: origin
urlPrefix: https://html.spec.whatwg.org/multipage/workers.html; type: dfn;
text: web workers
urlPrefix: #dom-workerglobalscope-;
text: self
urlPrefix: https://html.spec.whatwg.org/multipage/webappapis.html; type: dfn;
text: api base url
text: api url character encoding
text: browsing context
text: code entry-point
text: creation url
text: document environment
text: environment settings object
text: event loop
text: event loop processing model
text: global object
text: https state
text: incumbent settings object
text: microtask queue
text: module script
text: perform the request
text: realm execution context
text: relevant settings object
text: responsible browsing context
text: responsible document
text: responsible event loop
text: run a module script
text: script execution environment
text: task queues
urlPrefix: https://html.spec.whatwg.org/multipage/infrastructure.html; type: dfn;
text: cors setting attribute
text: in parallel
url: resolve-a-url; text: resolve;
urlPrefix: https://www.w3.org/2001/tag/doc/promises-guide; type: dfn;
text: a new promise
urlPrefix: http://www.ecma-international.org/ecma-262/6.0/#sec-; type: dfn;
text: Construct
text: InitializeHostDefinedRealm
@@ -162,6 +139,9 @@ interface WorkletGlobalScope {

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

Each {{WorkletGlobalScope}} has an associated <dfn for=WorkletGlobalScope>module map</dfn>. It is a
<a>module map</a>, initially empty.

Each {{WorkletGlobalScope}} has a <dfn>worklet global scope execution environment</dfn>. This
execution environment may be parallel (i.e. it may be on a separate thread, process, or other
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
- Do not obtain any source texts for scripts or modules.

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

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

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

<div algorithm>
When a user agent is to <dfn>set up a worklet environment settings object</dfn>, given a
|executionContext|, it must run the following steps:
1. Let |inheritedResponsibleBrowsingContext| be the <a>responsible browsing context</a>
specified by the <a>incumbent settings object</a>.
|executionContext|, and |outsideSettings|, it must run the following steps:
1. Let |inheritedResponsibleBrowsingContext| be |outsideSettings|'s <a>responsible browsing
context</a>.

2. Let |id| be a new unique opaque string.

3. Let |inheritedAPIBaseURL| be |outsideSettings|'s <a>API base URL</a>.

4. Let |origin| be a unique <a>opaque origin</a>.

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

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

4. Let |workletEventLoop| be a newly created <a>event loop</a>.
7. Let |workletEventLoop| be a newly created <a>event loop</a>.

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

6. Let |settingsObject| be a new <a>environment settings object</a> whose algorithms are
9. Let |workletGlobalScope| be |realm|'s <a>global object</a>.

10. Let |settingsObject| be a new <a>environment settings object</a> whose algorithms are
defined as follows:

: The <a>id</a>
:: Return |id|.

: The <a>Creation URL</a>
:: Return |inheritedAPIBaseURL|.

: The <a>target browsing context</a>
:: Return null.

: The <a>active service worker</a>
:: Return null.

: The <a>realm execution context</a>
:: Return |executionContext|.

: The <a>global object</a>
:: Return |workletGlobalScope|.
: The <a>module map</a>.
:: Return |workletGlobalScope|'s <a for=WorkletGlobalScope>module map</a>.

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

: The <a>responsible document</a>
:: Not applicable (the <a>responsible event loop</a> is not a <a>browsing context</a>
<a>event loop</a>).
<a>event loop</a>).

: The <a>API URL character encoding</a>
:: Return UTF-8.
:: Return <a>UTF-8</a>.

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

: The <a>origin</a> and <a>effective script origin</a>
:: Return |inheritedOrigin|.

: The <a>creation URL</a>
:: Not applicable.
: The <a for="environment settings object">origin</a>
:: Return |origin|.

: The <a>HTTPS state</a>
:: Return |workletGlobalScope|'s <a>HTTPS state</a>.
:: Return |inheritedHTTPSState|.

: The <a>referrer policy</a>
:: Return |inheritedReferrerPolicy|.

11. Set |realm|'s \[[HostDefined]] field to |settingsObject|.

7. Return |settingsObject|.
12. Return |settingsObject|.
</div>

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
1. <a>Fetch a module worker script graph</a> given |moduleURLRecord|, |outsideSettings|, "script",
|credentialOptions|, and |insideSettings|.

To <a>perform the request</a> given |request|, perform the following steps:
To <a>perform the fetch</a> given |request|, perform the following steps:

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

0 comments on commit 7481964

Please sign in to comment.
You can’t perform that action at this time.