serviceworker
"serviceworker
keyword may be used with <{link}> elements. This keyword creates an external resource link (serviceworker link) that is used to declare a [=/service worker registration=] and its [=service worker registration/scope url=].
+ A [=/service worker registration=] and its [=service worker registration/scope url=] are created by a serviceworker link, which is declared using a "serviceworker" `Link` header or a <{link}> element whose <{link/rel}> attribute contains the keyword "<{link/rel/serviceworker}>".
Link
headerLink
header+ Link: <sw.js>; rel="serviceworker"; scope="/"; workertype="module"; updateviacache="all" ++
Link
headerLink
header that contains a serviceworker link, the user agent *should* run these steps:
@@ -1793,7 +1818,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
classic
" if the <{link/workertype}> attribute is omitted.
- 1. If |workerType| is not a valid {{WorkerType}} value, queue a task to fire an event named error
at the <{link}> element, and abort these steps.
+ 1. Let |workerType| be the state of the <{link/workertype}> attribute.
+ 1. If |workerType| is invalid, abort these steps.
1. Let |updateViaCache| be the <{link/updateviacache}> attribute, or "`imports`" if the <{link/updateviacache}> attribute is omitted.
1. Let |promise| be a new promise.
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s creation URL, |workerType|, and |updateViaCache|.
@@ -1836,24 +1861,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
- partial interface HTMLLinkElement { - [CEReactions] attribute USVString scope; - [CEReactions] attribute WorkerType workerType; - [CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache; - }; -- - The scope IDL attribute must reflect the element's scope content attribute. - - The workerType IDL attribute must reflect the element's workertype content attribute. - - The updateViaCache IDL attribute must reflect the element's updateViaCache content attribute. -
serviceworker
"
serviceworker
"The serviceworker
keyword may be used with link
elements. This keyword creates an external resource link (serviceworker link) that is used to declare a service worker registration and its scope url.
A service worker registration and its scope url are created by a serviceworker link, which is declared using a "serviceworker" Link
header or a link
element whose rel
attribute contains the keyword "serviceworker
".
Link
headerWhen a user agent that supports [RFC5988] processes a Link
header that contains a serviceworker link, the user agent should run these steps:
Link
headerA serviceworker link can be declared using a Link
header [RFC5988] with "serviceworker
" as the value of the "rel
" parameter and a script url as the target IRI, and the following optional target attributes:
scope
+ Value: A scope url.
+workertype
+ Value: A worker type.
+updateviacache
+ Value: An update via cache mode.
+The "anchor
" parameter must not be specified.
Link
headerWhen a user agent that supports [RFC5988] processes a Link
header that contains a serviceworker link, the user agent should run these steps:
If the Link
header has an "anchor
" parameter, abort these steps.
link
elementWhen a serviceworker link’s link
element is inserted into a document, or a serviceworker link is created on a link
element that is already in a document tree, or the href
, scope
, or updateviacache
attributes of the link
element of a serviceworker link is changed, the user agent should run these steps:
link
elementWhen a serviceworker link’s link
element is inserted into a document, or a serviceworker link is created on a link
element that is already in a document tree, or the href
, scope
, or updateviacache
attributes of the link
element of a serviceworker link is changed, the user agent should run these steps:
If the href
attribute is the empty string, abort these steps.
Let scopeURL be null.
If the scope
attribute is present, set scopeURL to the result of parsing the scope
attribute with the link
element’s node document’s document base URL.
If the scope
attribute is present, set scopeURL to the result of parsing the scope
attribute with the link
element’s node document’s document base URL.
Let workerType be the workertype
attribute, or "classic
" if the workertype
attribute is omitted.
Let workerType be the state of the workertype
attribute.
If workerType is not a valid WorkerType
value, queue a task to fire an event named error
at the link
element, and abort these steps.
If workerType is invalid, abort these steps.
Let updateViaCache be the updateviacache
attribute, or "imports
" if the updateviacache
attribute is omitted.
Let updateViaCache be the updateviacache
attribute, or "imports
" if the updateviacache
attribute is omitted.
Let promise be a new promise.
load
at the link
element.
The serviceworker link element must not delay the load event of the element’s node document.
+The serviceworker link element must not delay the load event of the element’s node document.
partial interface HTMLLinkElement { - [CEReactions] attribute USVString scope; - [CEReactions] attribute WorkerType workerType; - [CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache; -}; --
The scope
IDL attribute must reflect the element’s scope
content attribute.
The workerType
IDL attribute must reflect the element’s workertype
content attribute.
The updateViaCache
IDL attribute must reflect the element’s updateViaCache
content attribute.
no-cache
" if any of the following are true:
registration’s update via cache mode is "none
".
registration’s update via cache mode is "none
".
The current global object's force bypass cache for importscripts flag is set.
The following definitions are the user agent’s internal data structures used throughout the specification.
-A scope to registration map is an ordered map where the keys are scope urls, serialized, and the values are service worker registrations.
+A scope to registration map is an ordered map where the keys are scope urls, serialized, and the values are service worker registrations.
A job is an abstraction of one of register, update, and unregister request for a service worker registration.
For unregister jobs, their scope url is the same.
-A job queue is a thread safe queue used to synchronize the set of concurrent jobs. The job queue contains jobs as its elements. The job queue should satisfy the general properties of FIFO queue. A user agent must maintain a separate job queue for each service worker registration keyed by its scope url. A job queue is initially empty. Unless stated otherwise, the job queue referenced from the algorithm steps is a job queue for the job’s scope url.
+A job queue is a thread safe queue used to synchronize the set of concurrent jobs. The job queue contains jobs as its elements. The job queue should satisfy the general properties of FIFO queue. A user agent must maintain a separate job queue for each service worker registration keyed by its scope url. A job queue is initially empty. Unless stated otherwise, the job queue referenced from the algorithm steps is a job queue for the job’s scope url.
referrer, a URL
workerType, a worker type
+workerType, a worker type
updateViaCache, an update via cache mode
+updateViaCache, an update via cache mode
none
@@ -4794,7 +4803,7 @@Let job be the result of running Create Job with register, scopeURL, scriptURL, promise, and client.
Set job’s worker type to workerType.
+Set job’s worker type to workerType.
Set job’s update via cache mode to updateViaCache.
Let newestWorker be the result of running the Get Newest Worker algorithm passing registration as the argument.
If newestWorker is not null, job’s script url equals newestWorker’s script url with the exclude fragments flag set, and job’s update via cache mode's value equals registration’s update via cache mode, then:
+If newestWorker is not null, job’s script url equals newestWorker’s script url with the exclude fragments flag set, and job’s update via cache mode's value equals registration’s update via cache mode, then:
Invoke Resolve Job Promise with job and the ServiceWorkerRegistration
object which represents registration.
Let newestWorker be the result of running Get Newest Worker algorithm passing registration as the argument.
If job’s job type is update, and newestWorker’s script url does not equal job’s script url with the exclude fragments flag set, then:
+If job’s job type is update, and newestWorker’s script url does not equal job’s script url with the exclude fragments flag set, then:
Invoke Reject Job Promise with job and a TypeError
.
Let referrerPolicy be the empty string.
Switching on job’s worker type, run these substeps with the following options:
+Switching on job’s worker type, run these substeps with the following options:
classic
"
no-cache
" if any of the following are true:
registration’s update via cache mode is not "all
".
registration’s update via cache mode is not "all
".
job’s force bypass cache flag is set.
Let scopeURL be registration’s scope url.
+Let scopeURL be registration’s scope url.
Let maxScopeString be null.
Else, continue the rest of these steps after the algorithm’s asynchronous completion, with script being the asynchronous completion value.
If newestWorker is not null, newestWorker’s script url equals job’s script url with the exclude fragments flag set, and script’s source text is a byte-for-byte match with newestWorker’s script resource's source text, if script is a classic script, and script’s module record's [[ECMAScriptCode]] is a byte-for-byte match with newestWorker’s script resource's module record's [[ECMAScriptCode]] otherwise, then:
+If newestWorker is not null, newestWorker’s script url equals job’s script url with the exclude fragments flag set, and script’s source text is a byte-for-byte match with newestWorker’s script resource's source text, if script is a classic script, and script’s module record's [[ECMAScriptCode]] is a byte-for-byte match with newestWorker’s script resource's module record's [[ECMAScriptCode]] otherwise, then:
Invoke Resolve Job Promise with job and the ServiceWorkerRegistration
object which represents registration.
Generate a unique opaque string and set worker’s id to the value.
Set worker’s script url to job’s script url, worker’s script resource to script, and worker’s type to job’s worker type.
+Set worker’s script url to job’s script url, worker’s script resource to script, and worker’s type to job’s worker type.
Set worker’s script resource’s HTTPS state to httpsState.
If newestWorker is null, abort these steps.
Let job be the result of running Create Job with update, registration’s scope url, newestWorker’s script url, null, and null.
+Let job be the result of running Create Job with update, registration’s scope url, newestWorker’s script url, null, and null.
Set job’s worker type to newestWorker’s type.
+Set job’s worker type to newestWorker’s type.
Set job’s force bypass cache flag if the force bypass cache flag is set.
Invoke Resolve Job Promise with job and the ServiceWorkerRegistration
object which represents registration.
Queue a task to fire an event named updatefound
at all the ServiceWorkerRegistration
objects for all the service worker clients whose creation URL matches registration’s scope url and all the service workers whose containing service worker registration is registration.
Queue a task to fire an event named updatefound
at all the ServiceWorkerRegistration
objects for all the service worker clients whose creation URL matches registration’s scope url and all the service workers whose containing service worker registration is registration.
Let installingWorker be registration’s installing worker.
Note: Once an active worker is activating, neither a runtime script error nor a force termination of the active worker prevents the active worker from getting activated.
For each service worker client client whose creation URL matches registration’s scope url:
+For each service worker client client whose creation URL matches registration’s scope url:
If client is a window client, unassociate client’s responsible document from its application cache, if it has one.
@@ -5311,7 +5320,7 @@Return serviceWorker’s script url.
+Return serviceWorker’s script url.
Return its registering service worker client's origin.
@@ -5323,7 +5332,7 @@Set workerGlobalScope’s url to serviceWorker’s script url.
+Set workerGlobalScope’s url to serviceWorker’s script url.
Set workerGlobalScope’s HTTPS state to serviceWorker’s script resource’s HTTPS state.
scope, a URL
updateViaCache, an update via cache mode
+updateViaCache, an update via cache mode
registration, a service worker registration
@@ -5914,7 +5923,7 @@Let scopeString be serialized scope with the exclude fragment flag set.
Let registration be a new service worker registration whose scope url is set to scope and update via cache mode is set to updateViaCache.
+Let registration be a new service worker registration whose scope url is set to scope and update via cache mode is set to updateViaCache.
Set scope to registration map[scopeString] to registration.
active
" and null as the arguments.
Let scopeString be serialized registration’s scope url with the exclude fragment flag set.
+Let scopeString be serialized registration’s scope url with the exclude fragment flag set.
Remove scope to registration map[scopeString].
@@ -6559,7 +6568,7 @@Service-Worker-Allowed
`
Indicates the user agent will override the path restriction, which limits the maximum allowed scope url that the script can control, to the given value.
+Indicates the user agent will override the path restriction, which limits the maximum allowed scope url that the script can control, to the given value.
Note: The value is a URL. If a relative URL is given, it is parsed against the script’s URL.
ports
= [];
};
-partial interface HTMLLinkElement {
- [CEReactions] attribute USVString scope;
- [CEReactions] attribute WorkerType workerType;
- [CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache;
-};
-
partial interface WindowOrWorkerGlobalScope {
[SecureContext, SameObject] readonly attribute CacheStorage caches;
};
@@ -7878,10 +7876,11 @@