diff --git a/worklets/Overview.bs b/worklets/Overview.bs index 29739e51..2baaa088 100644 --- a/worklets/Overview.bs +++ b/worklets/Overview.bs @@ -34,6 +34,7 @@ spec:html; type:dfn; for:environment settings object; text: https state text: referrer policy spec:html; type:dfn; for:environment; text:id +spec:infra; type:dfn; text:list spec:webidl; type:dfn; for:interface; text:inherit @@ -49,6 +50,8 @@ urlPrefix: https://html.spec.whatwg.org/multipage/workers.html; type: dfn; urlPrefix: #dom-workerglobalscope-; text: self urlPrefix: https://html.spec.whatwg.org/multipage/webappapis.html; type: dfn; + text: abort a running script + text: currently running task text: document environment text: event loop processing model text: microtask queue @@ -194,7 +197,10 @@ When a user agent is to create a WorkletGlobalScope, given |workletGl 4. Associate the |insideSettings| with |workletGlobalScope|. - 5. For each |entry| in the given |moduleResponsesMap| (in insertion order), run the following + 5. Set |workletGlobalScope|'s owner document be |outsideSettings|'s + responsible document. + + 6. For each |entry| in the given |moduleResponsesMap| (in insertion order), run the following substeps: 1. Let |moduleURLRecord| be |entry|'s key. @@ -210,7 +216,7 @@ When a user agent is to create a WorkletGlobalScope, given |workletGl point it should have successfully been parsed by another worklet global scope. I.e. |script| should never be null here. - 6. Run the responsible event loop specified by |insideSettings|. + 7. Run the responsible event loop specified by |insideSettings|. ### Script settings for worklets ### {#script-settings-for-worklets} @@ -497,14 +503,38 @@ Issue(w3c/css-houdini-drafts#47): Need ability to load code into a {{WorkletGlob Lifetime of the Worklet {#lifetime-of-the-worklet} -------------------------------------------------- -The lifetime of a {{Worklet}} is tied to the object it belongs to, for example the {{Window}}. +A {{WorkletGlobalScope}} has a owner document. + +When the owner document is discarded the user agent must destroy all {{WorkletGlobalScope}}s. + +
+When the user agent is to destroy a WorkletGlobalScope, given +|workletGlobalScope|, it must run the following steps: + 1. Remove |workletGlobalScope| from worklet's WorkletGlobalScopes. + + 2. If there are any tasks queued in the |workletGlobalScope|'s event loop, discard + them without processing them. + + 3. Wait for the |workletGlobalScope|'s event loop to complete the currently running + task. + + 4. If the above step doesn't complete within a period of time as defined by the user agent, + abort the script currently running in + |workletGlobalScope|. + + 5. Destroy |workletGlobalScope|'s event loop. + + 6. Clear |workletGlobalScope|'s owner document. +
-The lifetime of a {{WorkletGlobalScope}} should be defined by subsequent specifications which -inherit from {{WorkletGlobalScope}}. +Note: Most {{Worklet}}s will be instantiated lazily when the web developer wants to use them, it is + expected that they won't be created eagerly. Subsequent specifications may define that a {{WorkletGlobalScope}} can be terminated at any time particularly if there are no pending operations, or detects abnormal operation such as infinite -loops and callbacks exceeding imposed time limits. +loops and callbacks exceeding imposed time limits. In such cases the specification should call +destroy a WorkletGlobalScope. Security Considerations {#security-considerations} ==================================================