diff --git a/spec/service_worker/index.bs b/spec/service_worker/index.bs
index f07580c0..01a7aad9 100644
--- a/spec/service_worker/index.bs
+++ b/spec/service_worker/index.bs
@@ -81,6 +81,7 @@ spec: html; type: dfn
text: parent browsing context
text: queue a task
text: relevant settings object
+ text: the environment settings object's global object
text: replacement enabled
text: responsible browsing context
text: responsible document
@@ -518,17 +519,18 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
Invoke Run Service Worker algorithm with serviceWorker as the argument.
Let destination be the {{ServiceWorkerGlobalScope}} object associated with serviceWorker.
Let targetRealm be destination's Realm.
+ Let incumbentSettings be the incumbent settings object, and incumbentGlobal its global object.
Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.
Let clonedMessage be cloneRecord.\[[Clone]].
Let newPorts be a new frozen array consisting of all {{MessagePort}} objects in cloneRecord.\[[TransferList]], if any, maintaining their relative order.
Queue a task that runs the following steps:
- - Create an event e that uses the {{ExtendableMessageEvent}} interface, with the event type message, which does not bubble, is not cancelable, and has no default action.
+ - Create an event e that uses the {{ExtendableMessageEvent}} interface, with the event type message, which does not bubble and is not cancelable.
- Let the {{ExtendableMessageEvent/data}} attribute of e be initialized to clonedMessage.
- - Let the {{ExtendableMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of the origin specified by the incumbent settings object.
- - If the global object globalObject specified by the incumbent settings object is a {{ServiceWorkerGlobalScope}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{ServiceWorker}} object that represents globalObject's service worker.
- - Else if globalObject is a {{Window}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{WindowClient}} object that represents globalObject's browsing context.
- - Else, let it be initialized to a new {{Client}} object that represents the worker associated with globalObject.
+ - Let the {{ExtendableMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of incumbentSettings's origin.
+ - If incumbentGlobal is a {{ServiceWorkerGlobalScope}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{ServiceWorker}} object that represents incumbentGlobal's service worker.
+ - Else if incumbentGlobal is a {{Window}} object, let the {{ExtendableMessageEvent/source}} attribute of e be initialized to a new {{WindowClient}} object that represents incumbentGlobal's browsing context.
+ - Else, let it be initialized to a new {{Client}} object that represents the worker associated with incumbentGlobal.
- Let the {{ExtendableMessageEvent/ports}} attribute of e be initialized to newPorts.
- Dispatch e at destination.
@@ -1218,18 +1220,19 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
The postMessage(message, transfer)
method must run these steps or their equivalent:
+ - Let sourceSettings be the context object's relevant settings object.
- Let destination be the {{ServiceWorkerContainer}} object whose service worker client is the context object's service worker client.
- If destination is null, throw an "{{InvalidStateError}}" exception.
- - Let targetRealm be destination's Realm.
+ - Let targetRealm be destination's relevant Realm.
- Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.
- Let clonedMessage be cloneRecord.\[[Clone]].
- Let newPorts be a new frozen array consisting of all {{MessagePort}} objects in cloneRecord.\[[TransferList]], if any, maintaining their relative order.
- Add a task that runs the following steps to destination's client message queue:
- - Create an event e that uses the {{ServiceWorkerMessageEvent}} interface, with the event type message, which does not bubble, is not cancelable, and has no default action.
+ - Create an event e that uses the {{ServiceWorkerMessageEvent}} interface, with the event type message, which does not bubble and is not cancelable.
- Let the {{ServiceWorkerMessageEvent/data}} attribute of e be initialized to clonedMessage.
- - Let the {{ServiceWorkerMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of the origin specified by the incumbent settings object.
- - Let the {{ServiceWorkerMessageEvent/source}} attribute of e be initialized to a {{ServiceWorker}} object, which represents the service worker associated with the global object specified by the incumbent settings object.
+ - Let the {{ServiceWorkerMessageEvent/origin}} attribute of e be initialized to the Unicode serialisation of sourceSettings's origin.
+ - Let the {{ServiceWorkerMessageEvent/source}} attribute of e be initialized to a {{ServiceWorker}} object, which represents the service worker associated with sourceSettings's global object.
- Let the {{ServiceWorkerMessageEvent/ports}} attribute of e be initialized to newPorts.
- Dispatch e at destination.
@@ -1285,10 +1288,10 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
The navigate()
method must run these steps or their equivalent:
- - Let url be the result of parsing url with entry settings object's API base URL.
+ - Let url be the result of parsing url with the context object's relevant settings object's API base URL.
- If url is failure, return a promise rejected with a
TypeError
.
- If url is
about:blank
, return a promise rejected with a TypeError
.
- - If the context object's associated service worker client's active worker is not the incumbent settings object's global object's service worker, return a promise rejected with a
TypeError
.
+ - If the context object's associated service worker client's active worker is not the context object's relevant global object's service worker, return a promise rejected with a
TypeError
.
- Let promise be a new promise.
- Run these substeps in parallel:
@@ -1513,7 +1516,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
The openWindow(url)
method must run these steps or their equivalent:
- - Let url be the result of parsing url with entry settings object's API base URL.
+ - Let url be the result of parsing url with the context object's relevant settings object's API base URL.
- If url is failure, return a promise rejected with a
TypeError
.
- If url is
about:blank
, return a promise rejected with a TypeError
.
- If this algorithm is not triggered by user activation, return a promise rejected with an "{{InvalidAccessError}}" exception.
@@ -1689,11 +1692,11 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
- If options.{{ForeignFetchOptions/scopes}} is empty throw a
TypeError
and abort these steps.
- - Let scopeString be the incumbent settings object's global object's service worker's containing service worker registration's scope url, serialized.
+ - Let scopeString be the context object's relevant global object's service worker's containing service worker registration's scope url, serialized.
- Let subScopeURLs be an empty list of URLs.
- For each subScope in options.{{ForeignFetchOptions/scopes}}:
- - Let subScopeURL be the result of parsing subScope with entry settings object's API base URL.
+ - Let subScopeURL be the result of parsing subScope with context object's relevant settings object's API base URL.
- If subScopeURL is failure, throw a
TypeError
and abort these steps.
- Let subScopeString be the serialized subScopeURL.
- If subScopeString does not start with scopeString, throw a
TypeError
and abort these steps.
@@ -3387,7 +3390,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
- Invoke Run Service Worker algorithm with installingWorker as the argument.
- Queue a task task to run the following substeps:
- - Create a trusted event e that uses the {{InstallEvent}} interface, with the event type
install
, which does not bubble, is not cancelable, and has no default action.
+ - Create a trusted event e that uses the {{InstallEvent}} interface, with the event type
install
, which does not bubble and is not cancelable.
- Dispatch e at installingWorker's environment settings object's global object globalObject.
- WaitForAsynchronousExtensions: Run the following substeps in parallel:
@@ -3477,7 +3480,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
- Invoke Run Service Worker algorithm with activeWorker as the argument.
- Queue a task task to run the following substeps:
- - Create a trusted event e that uses the {{ExtendableEvent}} interface, with the event type
activate
, which does not bubble, is not cancelable, and has no default action.
+ - Create a trusted event e that uses the {{ExtendableEvent}} interface, with the event type
activate
, which does not bubble and is not cancelable.
- Dispatch e at activeWorker's environment settings object's global object.
- WaitForAsynchronousExtensions: Wait, in parallel, until e's extensions allowed flag is unset.
@@ -3626,7 +3629,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
- Invoke Run Service Worker algorithm with activeWorker as the argument.
- Queue a task task to run the following substeps:
- - Create a trusted event e that uses the {{FetchEvent}} interface, with the event type
fetch
, which does not bubble and has no default action.
+ - Create a trusted event e that uses the {{FetchEvent}} interface, with the event type
fetch
, which does not bubble.
- Let the request attribute of e be initialized to r.
- Let the clientId attribute of e be initialized to client's id if request is not a non-subresource request, and to null otherwise.
- Let the isReload attribute of e be initialized to
true
if request's client is a window client and the event was dispatched with the user's intention for the page reload, and false
otherwise.
@@ -3707,7 +3710,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
- Invoke [[#run-service-worker-algorithm]] algorithm with activeWorker as the argument.
- Queue a task task to run the following substeps:
- - Create a trusted event e that uses the {{ForeignFetchEvent}} interface, with the event type
foreignfetch
, which does not bubble and has no default action.
+ - Create a trusted event e that uses the {{ForeignFetchEvent}} interface, with the event type
foreignfetch
, which does not bubble.
- Let the {{ForeignFetchEvent/request}} attribute of e be initialized to r.
- Let the {{ForeignFetchEvent/origin}} attribute of e be initialized to the Unicode serialization of request's origin.
- Dispatch e at activeWorker's environment settings object's global object.
diff --git a/spec/service_worker/index.html b/spec/service_worker/index.html
index 64cba28c..c3361b55 100644
--- a/spec/service_worker/index.html
+++ b/spec/service_worker/index.html
@@ -1881,18 +1881,19 @@ <
- Invoke Run Service Worker algorithm with serviceWorker as the argument.
- Let destination be the
ServiceWorkerGlobalScope
object associated with serviceWorker.
- Let targetRealm be destination’s Realm.
+
- Let incumbentSettings be the incumbent settings object, and incumbentGlobal its global object.
- Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.
- Let clonedMessage be cloneRecord.[[Clone]].
- Let newPorts be a new frozen array consisting of all
MessagePort
objects in cloneRecord.[[TransferList]], if any, maintaining their relative order.
-
Queue a task that runs the following steps:
- - Create an event e that uses the
ExtendableMessageEvent
interface, with the event type message, which does not bubble, is not cancelable, and has no default action.
+ - Create an event e that uses the
ExtendableMessageEvent
interface, with the event type message, which does not bubble and is not cancelable.
- Let the
data
attribute of e be initialized to clonedMessage.
- - Let the
origin
attribute of e be initialized to the Unicode serialisation of the origin specified by the incumbent settings object.
- - If the global object globalObject specified by the incumbent settings object is a
ServiceWorkerGlobalScope
object, let the source
attribute of e be initialized to a new ServiceWorker
object that represents globalObject’s service worker.
- - Else if globalObject is a
Window
object, let the source
attribute of e be initialized to a new WindowClient
object that represents globalObject’s browsing context.
- - Else, let it be initialized to a new
Client
object that represents the worker associated with globalObject.
+ - Let the
origin
attribute of e be initialized to the Unicode serialisation of incumbentSettings’s origin.
+ - If incumbentGlobal is a
ServiceWorkerGlobalScope
object, let the source
attribute of e be initialized to a new ServiceWorker
object that represents incumbentGlobal’s service worker.
+ - Else if incumbentGlobal is a
Window
object, let the source
attribute of e be initialized to a new WindowClient
object that represents incumbentGlobal’s browsing context.
+ - Else, let it be initialized to a new
Client
object that represents the worker associated with incumbentGlobal.
- Let the
ports
attribute of e be initialized to newPorts.
- Dispatch e at destination.
@@ -2422,19 +2423,20 @@
The postMessage(message, transfer)
method must run these steps or their equivalent:
+ - Let sourceSettings be the context object’s relevant settings object.
- Let destination be the
ServiceWorkerContainer
object whose service worker client is the context object’s service worker client.
- If destination is null, throw an "
InvalidStateError
" exception.
- - Let targetRealm be destination’s Realm.
+
- Let targetRealm be destination’s relevant Realm.
- Let cloneRecord be StructuredCloneWithTransfer(message, transfer, targetRealm). If this throws an exception, rethrow that exception and abort these steps.
- Let clonedMessage be cloneRecord.[[Clone]].
- Let newPorts be a new frozen array consisting of all
MessagePort
objects in cloneRecord.[[TransferList]], if any, maintaining their relative order.
-
Add a task that runs the following steps to destination’s client message queue:
- - Create an event e that uses the
ServiceWorkerMessageEvent
interface, with the event type message, which does not bubble, is not cancelable, and has no default action.
+ - Create an event e that uses the
ServiceWorkerMessageEvent
interface, with the event type message, which does not bubble and is not cancelable.
- Let the
data
attribute of e be initialized to clonedMessage.
- - Let the
origin
attribute of e be initialized to the Unicode serialisation of the origin specified by the incumbent settings object.
- - Let the
source
attribute of e be initialized to a ServiceWorker
object, which represents the service worker associated with the global object specified by the incumbent settings object.
+ - Let the
origin
attribute of e be initialized to the Unicode serialisation of sourceSettings’s origin.
+ - Let the
source
attribute of e be initialized to a ServiceWorker
object, which represents the service worker associated with sourceSettings’s global object.
- Let the
ports
attribute of e be initialized to newPorts.
- Dispatch e at destination.
@@ -2479,10 +2481,10 @@
The navigate()
method must run these steps or their equivalent:
- - Let url be the result of parsing url with entry settings object’s API base URL.
+
- Let url be the result of parsing url with the context object’s relevant settings object’s API base URL.
- If url is failure, return a promise rejected with a
TypeError
.
- If url is
about:blank
, return a promise rejected with a TypeError
.
- - If the context object’s associated service worker client’s active worker is not the incumbent settings object’s global object’s service worker, return a promise rejected with a
TypeError
.
+ - If the context object’s associated service worker client’s active worker is not the context object’s relevant global object’s service worker, return a promise rejected with a
TypeError
.
- Let promise be a new promise.
-
Run these substeps in parallel:
@@ -2693,7 +2695,7 @@
The openWindow(url)
method must run these steps or their equivalent:
- - Let url be the result of parsing url with entry settings object’s API base URL.
+
- Let url be the result of parsing url with the context object’s relevant settings object’s API base URL.
- If url is failure, return a promise rejected with a
TypeError
.
- If url is
about:blank
, return a promise rejected with a TypeError
.
- If this algorithm is not triggered by user activation, return a promise rejected with an "
InvalidAccessError
" exception.
@@ -2842,12 +2844,12 @@ scopes is empty throw a TypeError
and abort these steps.
-
- Let scopeString be the incumbent settings object’s global object’s service worker’s containing service worker registration’s scope url, serialized.
+
- Let scopeString be the context object’s relevant global object’s service worker’s containing service worker registration’s scope url, serialized.
- Let subScopeURLs be an empty list of URLs.
-
For each subScope in options.
scopes
:
- - Let subScopeURL be the result of parsing subScope with entry settings object’s API base URL.
+
- Let subScopeURL be the result of parsing subScope with context object’s relevant settings object’s API base URL.
- If subScopeURL is failure, throw a
TypeError
and abort these steps.
- Let subScopeString be the serialized subScopeURL.
- If subScopeString does not start with scopeString, throw a
TypeError
and abort these steps.
@@ -4324,7 +4326,7 @@ In
-
Queue a task task to run the following substeps:
- - Create a trusted event e that uses the
InstallEvent
interface, with the event type install
, which does not bubble, is not cancelable, and has no default action.
+ - Create a trusted event e that uses the
InstallEvent
interface, with the event type install
, which does not bubble and is not cancelable.
- Dispatch e at installingWorker’s environment settings object’s global object globalObject.
-
WaitForAsynchronousExtensions: Run the following substeps in parallel:
@@ -4411,7 +4413,7 @@
Acti
-
Queue a task task to run the following substeps:
- - Create a trusted event e that uses the
ExtendableEvent
interface, with the event type activate
, which does not bubble, is not cancelable, and has no default action.
+ - Create a trusted event e that uses the
ExtendableEvent
interface, with the event type activate
, which does not bubble and is not cancelable.
- Dispatch e at activeWorker’s environment settings object’s global object.
- WaitForAsynchronousExtensions: Wait, in parallel, until e’s extensions allowed flag is unset.
@@ -4553,7 +4555,7 @@ Queue a task task to run the following substeps:
- - Create a trusted event e that uses the
FetchEvent
interface, with the event type fetch
, which does not bubble and has no default action.
+ - Create a trusted event e that uses the
FetchEvent
interface, with the event type fetch
, which does not bubble.
- Let the request attribute of e be initialized to r.
- Let the clientId attribute of e be initialized to client’s id if request is not a non-subresource request, and to null otherwise.
- Let the isReload attribute of e be initialized to
true
if request’s client is a window client and the event was dispatched with the user’s intention for the page reload, and false
otherwise.
@@ -4631,7 +4633,7 @@