Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[giow] (1) Update 'connect' events in shared workers to include the p…
…ort on event.source, as well as event.ports[0], to make the event more intuitive.

Affected topics: DOM APIs, Web Workers

git-svn-id: http://svn.whatwg.org/webapps@7114 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jun 1, 2012
1 parent e69d9ea commit d71dca8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 40 deletions.
33 changes: 20 additions & 13 deletions complete.html
Expand Up @@ -79399,11 +79399,10 @@ <h5 id=shared-workers><span class=secno>9.1.3.3 </span>Shared workers</h5>

<p>Inside the shared worker, new clients of the worker are announced
using the <code title=event-connect>connect</code> event. The port
for the new client is given by the event object's <code title=dom-messageevent-ports><a href=#dom-messageevent-ports>ports</a></code> array as its first (and
only) value.</p>
for the new client is given by the event object's <code title=dom-messageevent-source><a href=#dom-messageevent-source>source</a></code> attribute.</p>

<pre>onconnect = function (event) {
var newPort = event.ports[0];
var newPort = event.source;
// set up a listener
newPort.onmessage = function (event) { ... };
// send a message back to the port
Expand Down Expand Up @@ -80334,11 +80333,12 @@ <h5 id=shared-workers-and-the-sharedworker-interface><span class=secno>9.2.7.3 <
<li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code>
interface, with the name <code title=event-connect>connect</code>, which does not bubble, is
not cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value
is initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose
is initialized to the empty string, has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose
value is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read only</a> array containing
only the newly created port, and <a href=#queue-a-task>queue a task</a> to
dispatch the event at <var title="">worker global
scope</var>.</li>
only the newly created port, and has a <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute whose
value is initialized to the newly created port, and <a href=#queue-a-task>queue
a task</a> to dispatch the event at <var title="">worker
global scope</var>.</li>

<li>

Expand Down Expand Up @@ -80389,10 +80389,13 @@ <h5 id=shared-workers-and-the-sharedworker-interface><span class=secno>9.2.7.3 <
<li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code>
interface, with the name <code title=event-connect>connect</code>, which does not bubble, is not
cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value is
initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose value
initialized to the empty string, has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose value
is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read
only</a> array containing only the newly created port, and
<a href=#queue-a-task>queue a task</a> to dispatch the event at <var title="">worker global scope</var>.</li>
only</a> array containing only the newly created port, and has a
<code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute whose
value is initialized to the newly created port, and <a href=#queue-a-task>queue a
task</a> to dispatch the event at <var title="">worker global
scope</var>.</li>

<li>

Expand Down Expand Up @@ -80671,7 +80674,7 @@ <h3 id=event-definitions-1><span class=secno>10.1 </span>Event definitions</h3>
readonly attribute any <a href=#dom-messageevent-data title=dom-MessageEvent-data>data</a>;
readonly attribute DOMString <a href=#dom-messageevent-origin title=dom-MessageEvent-origin>origin</a>;
readonly attribute DOMString <a href=#dom-messageevent-lasteventid title=dom-MessageEvent-lastEventId>lastEventId</a>;
readonly attribute <a href=#windowproxy>WindowProxy</a>? <a href=#dom-messageevent-source title=dom-MessageEvent-source>source</a>;
readonly attribute (<a href=#windowproxy>WindowProxy</a> or <a href=#messageport>MessagePort</a>)? <a href=#dom-messageevent-source title=dom-MessageEvent-source>source</a>;
readonly attribute <a href=#messageport>MessagePort</a>[]? <a href=#dom-messageevent-ports title=dom-MessageEvent-ports>ports</a>;
};

Expand Down Expand Up @@ -80714,7 +80717,9 @@ <h3 id=event-definitions-1><span class=secno>10.1 </span>Event definitions</h3>
<dd>

<p>Returns the <code><a href=#windowproxy>WindowProxy</a></code> of the source window, for
<a href=#web-messaging>cross-document messaging</a>.</p>
<a href=#web-messaging>cross-document messaging</a>, and the
<code><a href=#messageport>MessagePort</a></code> being attached, in the <code title=event-connect>connect</code> event fired at
<code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> objects.</p>

</dd>

Expand Down Expand Up @@ -80755,7 +80760,9 @@ <h3 id=event-definitions-1><span class=secno>10.1 </span>Event definitions</h3>
created, this attribute must be initialized to null. It represents,
in <a href=#web-messaging>cross-document messaging</a>, the
<code><a href=#windowproxy>WindowProxy</a></code> of the <a href=#browsing-context>browsing context</a> of the
<code><a href=#window>Window</a></code> object from which the message came.</p>
<code><a href=#window>Window</a></code> object from which the message came; and in the
<code title=event-connect>connect</code> events used by <a href=#sharedworkerglobalscope title=SharedWorkerGlobalScope>shared workers</a>, the newly
connecting <code><a href=#messageport>MessagePort</a></code>.</p>

<p>The <dfn id=dom-messageevent-ports title=dom-MessageEvent-ports><code>ports</code></dfn>
attribute must return the value it was initialized to. When the
Expand Down
33 changes: 20 additions & 13 deletions index
Expand Up @@ -79399,11 +79399,10 @@ worker.port.postMessage({ foo: 'structured', bar: ['data', 'also', 'possible']})

<p>Inside the shared worker, new clients of the worker are announced
using the <code title=event-connect>connect</code> event. The port
for the new client is given by the event object's <code title=dom-messageevent-ports><a href=#dom-messageevent-ports>ports</a></code> array as its first (and
only) value.</p>
for the new client is given by the event object's <code title=dom-messageevent-source><a href=#dom-messageevent-source>source</a></code> attribute.</p>

<pre>onconnect = function (event) {
var newPort = event.ports[0];
var newPort = event.source;
// set up a listener
newPort.onmessage = function (event) { ... };
// send a message back to the port
Expand Down Expand Up @@ -80334,11 +80333,12 @@ interface <dfn id=sharedworker>SharedWorker</dfn> : <a href=#eventtarget>EventTa
<li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code>
interface, with the name <code title=event-connect>connect</code>, which does not bubble, is
not cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value
is initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose
is initialized to the empty string, has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose
value is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read only</a> array containing
only the newly created port, and <a href=#queue-a-task>queue a task</a> to
dispatch the event at <var title="">worker global
scope</var>.</li>
only the newly created port, and has a <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute whose
value is initialized to the newly created port, and <a href=#queue-a-task>queue
a task</a> to dispatch the event at <var title="">worker
global scope</var>.</li>

<li>

Expand Down Expand Up @@ -80389,10 +80389,13 @@ interface <dfn id=sharedworker>SharedWorker</dfn> : <a href=#eventtarget>EventTa
<li><p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code>
interface, with the name <code title=event-connect>connect</code>, which does not bubble, is not
cancelable, has no default action, has a <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute whose value is
initialized to the empty string and has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose value
initialized to the empty string, has a <code title=dom-MessageEvent-ports><a href=#dom-messageevent-ports>ports</a></code> attribute whose value
is initialized to a <a href=#dfn-read-only-array title=dfn-read-only-array>read
only</a> array containing only the newly created port, and
<a href=#queue-a-task>queue a task</a> to dispatch the event at <var title="">worker global scope</var>.</li>
only</a> array containing only the newly created port, and has a
<code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute whose
value is initialized to the newly created port, and <a href=#queue-a-task>queue a
task</a> to dispatch the event at <var title="">worker global
scope</var>.</li>

<li>

Expand Down Expand Up @@ -80671,7 +80674,7 @@ interface <dfn id=messageevent>MessageEvent</dfn> : <a href=#event>Event</a> {
readonly attribute any <a href=#dom-messageevent-data title=dom-MessageEvent-data>data</a>;
readonly attribute DOMString <a href=#dom-messageevent-origin title=dom-MessageEvent-origin>origin</a>;
readonly attribute DOMString <a href=#dom-messageevent-lasteventid title=dom-MessageEvent-lastEventId>lastEventId</a>;
readonly attribute <a href=#windowproxy>WindowProxy</a>? <a href=#dom-messageevent-source title=dom-MessageEvent-source>source</a>;
readonly attribute (<a href=#windowproxy>WindowProxy</a> or <a href=#messageport>MessagePort</a>)? <a href=#dom-messageevent-source title=dom-MessageEvent-source>source</a>;
readonly attribute <a href=#messageport>MessagePort</a>[]? <a href=#dom-messageevent-ports title=dom-MessageEvent-ports>ports</a>;
};

Expand Down Expand Up @@ -80714,7 +80717,9 @@ dictionary <dfn id=messageeventinit>MessageEventInit</dfn> : <a href=#eventinit>
<dd>

<p>Returns the <code><a href=#windowproxy>WindowProxy</a></code> of the source window, for
<a href=#web-messaging>cross-document messaging</a>.</p>
<a href=#web-messaging>cross-document messaging</a>, and the
<code><a href=#messageport>MessagePort</a></code> being attached, in the <code title=event-connect>connect</code> event fired at
<code><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> objects.</p>

</dd>

Expand Down Expand Up @@ -80755,7 +80760,9 @@ dictionary <dfn id=messageeventinit>MessageEventInit</dfn> : <a href=#eventinit>
created, this attribute must be initialized to null. It represents,
in <a href=#web-messaging>cross-document messaging</a>, the
<code><a href=#windowproxy>WindowProxy</a></code> of the <a href=#browsing-context>browsing context</a> of the
<code><a href=#window>Window</a></code> object from which the message came.</p>
<code><a href=#window>Window</a></code> object from which the message came; and in the
<code title=event-connect>connect</code> events used by <a href=#sharedworkerglobalscope title=SharedWorkerGlobalScope>shared workers</a>, the newly
connecting <code><a href=#messageport>MessagePort</a></code>.</p>

<p>The <dfn id=dom-messageevent-ports title=dom-MessageEvent-ports><code>ports</code></dfn>
attribute must return the value it was initialized to. When the
Expand Down
37 changes: 23 additions & 14 deletions source
Expand Up @@ -92209,11 +92209,10 @@ worker.port.postMessage({ foo: 'structured', bar: ['data', 'also', 'possible']})
<p>Inside the shared worker, new clients of the worker are announced
using the <code title="event-connect">connect</code> event. The port
for the new client is given by the event object's <code
title="dom-messageevent-ports">ports</code> array as its first (and
only) value.</p>
title="dom-messageevent-source">source</code> attribute.</p>

<pre>onconnect = function (event) {
var newPort = event.ports[0];
var newPort = event.source;
// set up a listener
newPort.onmessage = function (event) { ... };
// send a message back to the port
Expand Down Expand Up @@ -93328,13 +93327,15 @@ interface <dfn>SharedWorker</dfn> : <span>EventTarget</span> {
title="event-connect">connect</code>, which does not bubble, is
not cancelable, has no default action, has a <code
title="dom-MessageEvent-data">data</code> attribute whose value
is initialized to the empty string and has a <code
is initialized to the empty string, has a <code
title="dom-MessageEvent-ports">ports</code> attribute whose
value is initialized to a <span
title="dfn-read-only-array">read only</span> array containing
only the newly created port, and <span>queue a task</span> to
dispatch the event at <var title="">worker global
scope</var>.</p></li>
only the newly created port, and has a <code
title="dom-MessageEvent-source">source</code> attribute whose
value is initialized to the newly created port, and <span>queue
a task</span> to dispatch the event at <var title="">worker
global scope</var>.</p></li>

<li>

Expand Down Expand Up @@ -93396,12 +93397,14 @@ interface <dfn>SharedWorker</dfn> : <span>EventTarget</span> {
title="event-connect">connect</code>, which does not bubble, is not
cancelable, has no default action, has a <code
title="dom-MessageEvent-data">data</code> attribute whose value is
initialized to the empty string and has a <code
initialized to the empty string, has a <code
title="dom-MessageEvent-ports">ports</code> attribute whose value
is initialized to a <span title="dfn-read-only-array">read
only</span> array containing only the newly created port, and
<span>queue a task</span> to dispatch the event at <var
title="">worker global scope</var>.</p></li>
only</span> array containing only the newly created port, and has a
<code title="dom-MessageEvent-source">source</code> attribute whose
value is initialized to the newly created port, and <span>queue a
task</span> to dispatch the event at <var title="">worker global
scope</var>.</p></li>

<li>

Expand Down Expand Up @@ -93735,7 +93738,7 @@ interface <dfn>MessageEvent</dfn> : <span>Event</span> {
readonly attribute any <span title="dom-MessageEvent-data">data</span>;
readonly attribute DOMString <span title="dom-MessageEvent-origin">origin</span>;
readonly attribute DOMString <span title="dom-MessageEvent-lastEventId">lastEventId</span>;
readonly attribute <span>WindowProxy</span>? <span title="dom-MessageEvent-source">source</span>;
readonly attribute (<span>WindowProxy</span> or <span>MessagePort</span>)? <span title="dom-MessageEvent-source">source</span>;
readonly attribute <span>MessagePort</span>[]? <span title="dom-MessageEvent-ports">ports</span>;
};

Expand Down Expand Up @@ -93781,7 +93784,10 @@ dictionary <dfn>MessageEventInit</dfn> : <span>EventInit</span> {
<dd>

<p>Returns the <code>WindowProxy</code> of the source window, for
<span>cross-document messaging</span>.</p>
<span>cross-document messaging</span>, and the
<code>MessagePort</code> being attached, in the <code
title="event-connect">connect</code> event fired at
<code>SharedWorkerGlobalScope</code> objects.</p>

</dd>

Expand Down Expand Up @@ -93828,7 +93834,10 @@ dictionary <dfn>MessageEventInit</dfn> : <span>EventInit</span> {
created, this attribute must be initialized to null. It represents,
in <span>cross-document messaging</span>, the
<code>WindowProxy</code> of the <span>browsing context</span> of the
<code>Window</code> object from which the message came.</p>
<code>Window</code> object from which the message came; and in the
<code title="event-connect">connect</code> events used by <span
title="SharedWorkerGlobalScope">shared workers</span>, the newly
connecting <code>MessagePort</code>.</p>

<p>The <dfn title="dom-MessageEvent-ports"><code>ports</code></dfn>
attribute must return the value it was initialized to. When the
Expand Down

0 comments on commit d71dca8

Please sign in to comment.