You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
whatwg/html#1944 extended MessageEvent to accept
a ServiceWorker object as a type of the source attribute. This replaces
ServiceWorkerMessageEvent with MessageEvent to reduce the redundancy.
Fixes#989.
Related changes: whatwg/html#1944.
<li>Let <var>newPorts</var> be a new <a lt="frozen array type">frozen array</a> consisting of all {{MessagePort}} objects in <var>cloneRecord</var>.\[[TransferList]], if any, maintaining their relative order.</li>
356
356
<li><a>Queue a task</a> that runs the following steps:
357
357
<ol>
358
-
<li>Create an event <var>e</var> that uses the {{ExtendableMessageEvent}} interface, with the event type <a href="#service-worker-global-scope-message-event">message</a>, which does not bubble and is not cancelable.</li>
358
+
<li>Create an event <var>e</var> that uses the {{ExtendableMessageEvent}} interface, with the event type {{message!!event}}, which does not bubble and is not cancelable.</li>
359
359
<li>Let the {{ExtendableMessageEvent/data}} attribute of <var>e</var> be initialized to <var>clonedMessage</var>.</li>
360
360
<li>Let the {{ExtendableMessageEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="Unicode serialization of an origin">Unicode serialization</a> of <var>incumbentSettings</var>'s <a for="resource">origin</a>.</li>
361
361
<li>If <var>incumbentGlobal</var> is a {{ServiceWorkerGlobalScope}} object, let the {{ExtendableMessageEvent/source}} attribute of <var>e</var> be initialized to a new {{ServiceWorker}} object that represents <var>incumbentGlobal</var>'s <a for="ServiceWorkerGlobalScope">service worker</a>.</li>
<p><a href="#dfn-service-worker">Service workers</a> define the <a href="#service-worker-container-message-event">message</a> event that extends the {{Window/message}} event defined in [[!HTML]] to allow setting a {{ServiceWorker}} object as the source of the message. For the <a href="#service-worker-container-message-event">message</a> event, <a href="#dfn-service-worker">service workers</a> use the {{ServiceWorkerMessageEvent}} interface.</p>
<p>The <dfn attribute for="ServiceWorkerMessageEvent">data</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the message being sent.</p>
<p>The <dfn attribute for="ServiceWorkerMessageEvent">origin</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to the empty string. It represents the <a for="resource">origin</a> of the <a href="#dfn-service-worker">service worker</a>'s <a>environment settings object</a> from which the message is sent.</p>
<p>The <dfn attribute for="ServiceWorkerMessageEvent">lastEventId</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to the empty string.</p>
<p>The <dfn attribute for="ServiceWorkerMessageEvent">source</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to null. It represents the {{ServiceWorker}} object whose associated <a href="#dfn-service-worker">service worker</a> the message is sent from.</p>
<p>The <dfn attribute for="ServiceWorkerMessageEvent">ports</dfn> attribute <em class="rfc2119" title="MUST">must</em> return the value it was initialized to. When the object is created, this attribute <em class="rfc2119" title="MUST">must</em> be initialized to the empty array. It represents the {{MessagePort}} array being sent.</p>
<td>The <a for="ServiceWorkerContainer">service worker client</a>'s <a>active service worker</a> changes. (See step 9.2 of the <a href="#activation-algorithm">Activate</a> algorithm. The <a href="#dfn-skip-waiting-flag">skip waiting flag</a> of a <a href="#dfn-service-worker">service worker</a> causes <a href="#activation-algorithm">activation</a> of the <a href="#dfn-service-worker-registration">service worker registration</a> to occur while <a href="#dfn-service-worker-client">service worker clients</a> are <a href="#dfn-use">using</a> the <a href="#dfn-service-worker-registration">service worker registration</a>, {{ServiceWorkerContainer/controller|navigator.serviceWorker.controller}} immediately reflects the <a href="#dfn-active-worker">active worker</a> as the <a href="#dfn-service-worker">service worker</a> that <a href="#dfn-control">controls</a> the <a href="#dfn-service-worker-client">service worker client</a>.)</td>
<li>Let <var>newPorts</var> be a new <a lt="frozen array type">frozen array</a> consisting of all {{MessagePort}} objects in <var>cloneRecord</var>.\[[TransferList]], if any, maintaining their relative order.</li>
1041
980
<li>Add a <a>task</a> that runs the following steps to <var>destination</var>'s <a for="ServiceWorkerContainer">client message queue</a>:
1042
981
<ol>
1043
-
<li>Create an event <var>e</var> that uses the {{ServiceWorkerMessageEvent}} interface, with the event type <a href="#service-worker-container-message-event">message</a>, which does not bubble and is not cancelable.</li>
1044
-
<li>Let the {{ServiceWorkerMessageEvent/data}} attribute of <var>e</var> be initialized to <var>clonedMessage</var>.</li>
1045
-
<li>Let the {{ServiceWorkerMessageEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="Unicode serialization of an origin">Unicode serialization</a> of <var>sourceSettings</var>'s <a for="resource">origin</a>.</li>
1046
-
<li>Let the {{ServiceWorkerMessageEvent/source}} attribute of <var>e</var> be initialized to a {{ServiceWorker}} object, which represents the <a for="ServiceWorkerGlobalScope">service worker</a> associated with <var>sourceSettings</var>'s <a for="environment settings object">global object</a>.</li>
1047
-
<li>Let the {{ServiceWorkerMessageEvent/ports}} attribute of <var>e</var> be initialized to <var>newPorts</var>.</li>
982
+
<li>Create an event <var>e</var> that uses the {{MessageEvent}} interface, with the event type <a href="https://html.spec.whatwg.org/#event-message">message</a>, which does not bubble and is not cancelable.</li>
983
+
<li>Let the <a href="https://html.spec.whatwg.org/#dom-messageevent-data">data</a> attribute of <var>e</var> be initialized to <var>clonedMessage</var>.</li>
984
+
<li>Let the <a href="https://html.spec.whatwg.org/#dom-messageevent-origin">origin</a> attribute of <var>e</var> be initialized to the <a lt="Unicode serialization of an origin">Unicode serialization</a> of <var>sourceSettings</var>'s <a for="resource">origin</a>.</li>
985
+
<li>Let the <a href="https://html.spec.whatwg.org/#dom-messageevent-source">source</a> attribute of <var>e</var> be initialized to a {{ServiceWorker}} object, which represents the <a for="ServiceWorkerGlobalScope">service worker</a> associated with <var>sourceSettings</var>'s <a for="environment settings object">global object</a>.</li>
986
+
<li>Let the <a href="https://html.spec.whatwg.org/#dom-messageevent-ports">ports</a> attribute of <var>e</var> be initialized to <var>newPorts</var>.</li>
1048
987
<li><a>Dispatch</a><var>e</var> at <var>destination</var>.</li>
<p><a href="#dfn-service-worker">Service workers</a> define the <a href="#dom-extendableevent-waituntil">extendable</a><a href="#service-worker-global-scope-message-event">message</a> event that extends the {{Window/message}} event defined in [[!HTML]]to allow extending the lifetime of the event. For the <a href="#service-worker-global-scope-message-event">message</a> event, <a href="#dfn-service-worker">service workers</a> use the {{ExtendableMessageEvent}} interface which extends the {{ExtendableEvent}} interface.</p>
1814
+
<p><a href="#dfn-service-worker">Service workers</a> define the <a href="#dom-extendableevent-waituntil">extendable</a>{{message!!event}} event to allow extending the lifetime of the event. For the {{message!!event}} event, <a href="#dfn-service-worker">service workers</a> use the {{ExtendableMessageEvent}} interface which extends the {{ExtendableEvent}} interface.</p>
<td>[<a href="#dfn-functional-events">Functional event</a>] The <a>http fetch</a> invokes [[#on-foreign-fetch-request-algorithm]] with <var>request</var>. As a result of performing [[#on-foreign-fetch-request-algorithm]], the <a for="ServiceWorkerGlobalScope">service worker</a> returns a <a for="fetch">response</a> to the <a>http fetch</a>. The <a for="fetch">response</a>, represented by a {{Response}} object, can be retrieved from a {{Cache}} object or directly from network using {{WindowOrWorkerGlobalScope/fetch(input, init)|self.fetch(input, init)}} method. (A custom {{Response}} object can be another option.)</td>
0 commit comments