- From: poot <cvsmail@w3.org>
- Date: Tue, 16 Dec 2008 13:50:05 +0900 (JST)
- To: public-html-diffs@w3.org
Add structured data support to postMessage(). (whatwg r2533) 7 Communication http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#comms 2.8.4 Safe passing of structured data http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#safe-passing-of-structured-data PARSE_ERR http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#parse_err 7.4.4 Posting messages with message ports http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#posting-messages-with-message-ports hasFeature(feature, version) http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#hasfeature DOMSTRING_SIZE_ERR http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#domstring_size_err initMessageEventNS() http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-messageevent-initmessageeventns 2.8.8 Garbage collection http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#garbage-collection initMessageEvent() http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-messageevent-initmessageevent Window http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#window 7.4.2.2 User agents http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#user-agents MessageChannel http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#messagechannel 7.4.3 Posting messages http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#posting-messages SERIALISE_ERR http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#serialise_err message http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#event-message INDEX_SIZE_ERR http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#index_size_err MessagePort http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#messageport 2.8.6 DOM feature strings http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-feature-strings postMessage() http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-messageport-postmessage UNAVAILABLE_SCRIPT_ERR http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#unavailable_script_err XXX3(name) http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-stringmap-xxx3 XXX2(name, value) http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-stringmap-xxx2 stringify http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-tokenlist-tostring 7.5.2 Message channels http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#message-channels 2.8.5 DOMStringMap http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#domstringmap 7.5 Channel messaging http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#channel-messaging internal structured cloning algorithm http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#internal-structured-cloning-algorithm HIERARCHY_REQUEST_ERR http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#hierarchy_request_err 7.5.3 Message ports http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#message-ports toggle(token) http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#dom-tokenlist-toggle 2.8.7 Exceptions http://people.w3.org/mike/diffs/html5/spec/Overview.1.1704.html#exceptions http://people.w3.org/mike/diffs/html5/spec/Overview.diff.html http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.1703&r2=1.1704&f=h http://html5.org/tools/web-apps-tracker?from=2532&to=2533 =================================================================== RCS file: /sources/public/html5/spec/Overview.html,v retrieving revision 1.1703 retrieving revision 1.1704 diff -u -d -r1.1703 -r1.1704 --- Overview.html 16 Dec 2008 01:33:57 -0000 1.1703 +++ Overview.html 16 Dec 2008 04:46:44 -0000 1.1704 @@ -206,10 +206,11 @@ <li><a href=#htmlformcontrolscollection><span class=secno>2.8.2.2 </span>HTMLFormControlsCollection</a></li> <li><a href=#htmloptionscollection><span class=secno>2.8.2.3 </span>HTMLOptionsCollection</a></ol></li> <li><a href=#domtokenlist><span class=secno>2.8.3 </span>DOMTokenList</a></li> - <li><a href=#domstringmap><span class=secno>2.8.4 </span>DOMStringMap</a></li> - <li><a href=#dom-feature-strings><span class=secno>2.8.5 </span>DOM feature strings</a></li> - <li><a href=#exceptions><span class=secno>2.8.6 </span>Exceptions</a></li> - <li><a href=#garbage-collection><span class=secno>2.8.7 </span>Garbage collection</a></ol></ol></li> + <li><a href=#safe-passing-of-structured-data><span class=secno>2.8.4 </span>Safe passing of structured data</a></li> + <li><a href=#domstringmap><span class=secno>2.8.5 </span>DOMStringMap</a></li> + <li><a href=#dom-feature-strings><span class=secno>2.8.6 </span>DOM feature strings</a></li> + <li><a href=#exceptions><span class=secno>2.8.7 </span>Exceptions</a></li> + <li><a href=#garbage-collection><span class=secno>2.8.8 </span>Garbage collection</a></ol></ol></li> <li><a href=#dom><span class=secno>3 </span>Semantics and structure of HTML documents</a> <ol> <li><a href=#semantics-intro><span class=secno>3.1 </span>Introduction</a></li> @@ -799,9 +800,8 @@ <ol> <li><a href=#authors><span class=secno>7.4.2.1 </span>Authors</a></li> <li><a href=#user-agents><span class=secno>7.4.2.2 </span>User agents</a></ol></li> - <li><a href=#posting-text><span class=secno>7.4.3 </span>Posting text</a></li> - <li><a href=#posting-message-ports><span class=secno>7.4.4 </span>Posting message ports</a></li> - <li><a href=#posting-structured-data><span class=secno>7.4.5 </span>Posting structured data</a></ol></li> + <li><a href=#posting-messages><span class=secno>7.4.3 </span>Posting messages</a></li> + <li><a href=#posting-messages-with-message-ports><span class=secno>7.4.4 </span>Posting messages with message ports</a></ol></li> <li><a href=#channel-messaging><span class=secno>7.5 </span>Channel messaging</a> <ol> <li><a href=#introduction-6><span class=secno>7.5.1 </span>Introduction</a></li> @@ -4663,7 +4663,84 @@ </ol><p>Objects implementing the <code><a href=#domtokenlist-0>DOMTokenList</a></code> interface must <dfn id=dom-tokenlist-tostring title=dom-tokenlist-toString>stringify</dfn> to the object's - underlying string representation.<h4 id=domstringmap><span class=secno>2.8.4 </span>DOMStringMap</h4><p>The <code><a href=#domstringmap-0>DOMStringMap</a></code> interface represents a set of + underlying string representation.<h4 id=safe-passing-of-structured-data><span class=secno>2.8.4 </span>Safe passing of structured data</h4><p>When a user agent is required to obtain a <dfn id=structured-clone>structured + clone</dfn> of an object, it must run the following algorithm, which + either returns a separate object, or returns an exception.<ol><li><p>Let <var title="">input</var> be the object being + cloned.</li> + + <li><p>Let <var title="">memory</var> be a list of objects, + initially empty. (This is used to catch cycles.)</li> + + <li><p>Let <var title="">output</var> be the object resulting from + calling the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> with + <var title="">input</var> and <var title="">memory</var>.</li> + + <li><p>Return <var title="">output</var>.</li> + + </ol><p>The <dfn id=internal-structured-cloning-algorithm>internal structured cloning algorithm</dfn> is always + called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior depends on the type of <var title="">input</var>, as follows:<dl class=switch><dt>If <var title="">input</var> is the undefined value</dt> + + <dd><p>Return the undefined value.</dd> + + <dt>If <var title="">input</var> is the null value</dt> + + <dd><p>Return the null value.</dd> + + <dt>If <var title="">input</var> is the false value</dt> + + <dd><p>Return the false value.</dd> + + <dt>If <var title="">input</var> is the true value</dt> + + <dd><p>Return the true value.</dd> + + <dt>If <var title="">input</var> is a Number object</dt> + + <dd><p>Return a newly constructed Number object with the same value as <var title="">input</var>.</dd> + + <dt>If <var title="">input</var> is a String object</dt> + + <dd><p>Return a newly constructed String object with the same value as <var title="">input</var>.</dd> + + <dt>If <var title="">input</var> is a Date object</dt> + + <dd><p>Return a newly constructed Date object with the same value as <var title="">input</var>.</dd> + + <dt>If <var title="">input</var> is a host object</dt> + + <dd><p>Return the null value.</dd> + + <dt>If <var title="">input</var> is an Array object</dt> + <dt>If <var title="">input</var> is an Object object</dt> + + <dd> + + <ol><li><p>If <var title="">input</var> is in <var title="">memory</var>, then return a + <code><a href=#not_supported_err>NOT_SUPPORTED_ERR</a></code> exception and abort the overall + <a href=#structured-clone>structured clone</a> algorithm.</li> + + <li><p>Otherwise, let <var title="">new memory</var> be a list + consisting of the items in <var title="">memory</var> with the + addition of <var title="">input</var>.</li> + + <li><p>Create a new object, <var title="">output</var>, of the + same type as <var title="">input</var>: either an Array or an + Object.</li> + + <li><p>For each property in <var title="">input</var>, add a + corresponding property to <var title="">output</var> having the + same name, and having a value created from invoking the + <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively + with the value of the property as the "<var title="">input</var>" + arguemnt and <var title="">new memory</var> as the "<var title="">memory</var>" argument. The order of the properties in + the <var title="">input</var> and <var title="">output</var> + objects must be the same.</li> + + <li><p>Return <var title="">output</var>.</li> + + </ol></dd> + + </dl><h4 id=domstringmap><span class=secno>2.8.5 </span>DOMStringMap</h4><p>The <code><a href=#domstringmap-0>DOMStringMap</a></code> interface represents a set of name-value pairs. When a <code><a href=#domstringmap-0>DOMStringMap</a></code> object is instanced, it is associated with three algorithms, one for getting values from names, one for setting names to certain values, and one @@ -4680,7 +4757,7 @@ <var title="">name</var> as the name and <var title="">value</var> as the value.<p>The <dfn id=dom-stringmap-xxx3 title=dom-stringmap-XXX3><code>XXX3(<var title="">name</var>)</code></dfn> method must call the algorithm for deleting names, passing <var title="">name</var> as the name, and - must return true.<h4 id=dom-feature-strings><span class=secno>2.8.5 </span>DOM feature strings</h4><p>DOM3 Core defines mechanisms for checking for interface support, + must return true.<h4 id=dom-feature-strings><span class=secno>2.8.6 </span>DOM feature strings</h4><p>DOM3 Core defines mechanisms for checking for interface support, and for obtaining implementations of interfaces, using <a href=http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures>feature strings</a>. <a href=#references>[DOM3CORE]</a><p>A DOM application can use the <dfn id=hasfeature title=hasFeature><code>hasFeature(<var title="">feature</var>, <var title="">version</var>)</code></dfn> method of the @@ -4700,7 +4777,7 @@ always supersets of the interfaces defined in DOM2 HTML; some features that were formerly deprecated, poorly supported, rarely used or considered unnecessary have been removed. Therefore it is - not guaranteed that an implementation that supports "<code title="">HTML</code>" "<code>5.0</code>" also supports "<code title="">HTML</code>" "<code>2.0</code>".<h4 id=exceptions><span class=secno>2.8.6 </span>Exceptions</h4><p>The following <code>DOMException</code> codes are defined in DOM + not guaranteed that an implementation that supports "<code title="">HTML</code>" "<code>5.0</code>" also supports "<code title="">HTML</code>" "<code>2.0</code>".<h4 id=exceptions><span class=secno>2.8.7 </span>Exceptions</h4><p>The following <code>DOMException</code> codes are defined in DOM Core. <a href=#references>[DOMCORE]</a><ol class=brief><li value=1><dfn id=index_size_err><code>INDEX_SIZE_ERR</code></dfn></li> <li value=2><dfn id=domstring_size_err><code>DOMSTRING_SIZE_ERR</code></dfn></li> <li value=3><dfn id=hierarchy_request_err><code>HIERARCHY_REQUEST_ERR</code></dfn></li> @@ -4726,7 +4803,7 @@ <li value=23><dfn id=unavailable_script_err><code>UNAVAILABLE_SCRIPT_ERR</code></dfn></li> <!-- actually defined right here for now --> <li value=81><dfn id=parse_err><code>PARSE_ERR</code></dfn></li> <!-- actually defined in dom3ls --> <li value=82><dfn id=serialise_err><code>SERIALISE_ERR</code></dfn></li> <!-- actually defined in dom3ls --> - </ol><h4 id=garbage-collection><span class=secno>2.8.7 </span>Garbage collection</h4><p>There is an <dfn id=implied-strong-reference>implied strong reference</dfn> from any DOM + </ol><h4 id=garbage-collection><span class=secno>2.8.8 </span>Garbage collection</h4><p>There is an <dfn id=implied-strong-reference>implied strong reference</dfn> from any DOM attribute that returns a pre-existing object to that object.<div class=example> <p>For example, the <code>document.defaultView</code> attribute @@ -26519,8 +26596,8 @@ void <a href=#dom-shownotification title=dom-showNotification>showNotification</a>(in DOMString title, in DOMString subtitle, in DOMString description, in VoidCallback onclick); // <a href=#crossDocumentMessages>cross-document messaging</a> - void <a href=#dom-window-postmessage-2 title=dom-window-postMessage-2>postMessage</a>(in DOMString message, in DOMString targetOrigin); - void <a href=#dom-window-postmessage-3 title=dom-window-postMessage-3>postMessage</a>(in DOMString message, in <a href=#messageport>MessagePort</a> messagePort, in DOMString targetOrigin); + void <a href=#dom-window-postmessage-2 title=dom-window-postMessage-2>postMessage</a>(in any message, in DOMString targetOrigin); + void <a href=#dom-window-postmessage-3 title=dom-window-postMessage-3>postMessage</a>(in any message, in <a href=#messageport>MessagePort</a> messagePort, in DOMString targetOrigin); // <a href=#event-handler-dom-attributes>event handler DOM attributes</a> attribute <span>EventListener</span> <a href=#handler-onabort title=handler-onabort>onabort</a>; @@ -34354,13 +34431,13 @@ --><h2 id=comms><span class=secno>7 </span>Communication</h2><h3 id=event-definitions><span class=secno>7.1 </span>Event definitions</h3><p>Messages in <a href=#server-sent-events>server-sent events</a>, <a href=#network>Web sockets</a>, <a href=#crossDocumentMessages>cross-document messaging</a>, and <a href=#channel-messaging>channel messaging</a> use the <dfn id=event-message title=event-message><code>message</code></dfn> event.<p>The following interface is defined for this event:<pre class=idl>interface <dfn id=messageevent>MessageEvent</dfn> : Event { - readonly attribute DOMString <a href=#dom-messageevent-data title=dom-MessageEvent-data>data</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=#window>Window</a> <a href=#dom-messageevent-source title=dom-MessageEvent-source>source</a>; readonly attribute <a href=#messageport>MessagePort</a> <a href=#dom-messageevent-messageport title=dom-MessageEvent-messagePort>messagePort</a>; - void <a href=#dom-messageevent-initmessageevent title=dom-MessageEvent-initMessageEvent>initMessageEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString dataArg, in DOMString originArg, in DOMString lastEventIdArg, in Window sourceArg, in <a href=#messageport>MessagePort</a> messagePortArg); - void <a href=#dom-messageevent-initmessageeventns title=dom-MessageEvent-initMessageEventNS>initMessageEventNS</a>(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString dataArg, in DOMString originArg, in DOMString lastEventIdArg, in Window sourceArg, in <a href=#messageport>MessagePort</a> messagePortArg); + void <a href=#dom-messageevent-initmessageevent title=dom-MessageEvent-initMessageEvent>initMessageEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString lastEventIdArg, in Window sourceArg, in <a href=#messageport>MessagePort</a> messagePortArg); + void <a href=#dom-messageevent-initmessageeventns title=dom-MessageEvent-initMessageEventNS>initMessageEventNS</a>(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any dataArg, in DOMString originArg, in DOMString lastEventIdArg, in Window sourceArg, in <a href=#messageport>MessagePort</a> messagePortArg); };</pre><p>The <dfn id=dom-messageevent-initmessageevent title=dom-MessageEvent-initMessageEvent><code>initMessageEvent()</code></dfn> and <dfn id=dom-messageevent-initmessageeventns title=dom-MessageEvent-initMessageEventNS><code>initMessageEventNS()</code></dfn> methods must initialize the event in a manner analogous to the @@ -35520,7 +35597,7 @@ implementation of this feature. It allows authors to transmit information from one domain to another domain, which is normally disallowed for security reasons. It also requires that UAs be - careful to allow access to certain properties but not others.<h4 id=posting-text><span class=secno>7.4.3 </span>Posting text</h4><p>When a script invokes the <dfn id=dom-window-postmessage-2 title=dom-window-postMessage-2><code>postMessage(<var title="">message</var>, <var title="">targetOrigin</var>)</code></dfn> method (with only two + careful to allow access to certain properties but not others.<h4 id=posting-messages><span class=secno>7.4.3 </span>Posting messages</h4><p>When a script invokes the <dfn id=dom-window-postmessage-2 title=dom-window-postMessage-2><code>postMessage(<var title="">message</var>, <var title="">targetOrigin</var>)</code></dfn> method (with only two arguments) on a <code><a href=#window>Window</a></code> object, the user agent must follow these steps: @@ -35538,6 +35615,16 @@ <li> + <p>Let <var title="">message clone</var> be the result of + obtaining a <a href=#structured-clone>structured clone</a> of the <var title="">message</var> argument.</p> + + <p>If doing this raised an exception, then raise that exception + and abort these steps.</p> + + </li> + + <li> + <p>Return from the <code title=dom-window-postMessage-2><a href=#dom-window-postmessage-2>postMessage()</a></code> method, but asynchronously continue running these steps.</p> @@ -35560,12 +35647,10 @@ <p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is cancelable, and has no default action. The <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute must be set to - the value passed as the <var title="">message</var> argument to - the <code title=dom-window-postMessage-2><a href=#dom-window-postmessage-2>postMessage()</a></code> - method, the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> - attribute must be set to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of - an origin">Unicode serialization</a> of the <a href=#origin-0>origin</a> - of the script that invoked the method, and the <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute must be + the value of <var title="">message clone</var>, the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute must be + set to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of an + origin">Unicode serialization</a> of the <a href=#origin-0>origin</a> of + the script that invoked the method, and the <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute must be set to the <code><a href=#window>Window</a></code> object of the <a href=#default-view>default view</a> of the <a href=#browsing-context>browsing context</a> for which the <code>Document</code> object with which the script is associated @@ -35585,7 +35670,7 @@ </li> - </ol><h4 id=posting-message-ports><span class=secno>7.4.4 </span>Posting message ports</h4><p>When a script invokes the <dfn id=dom-window-postmessage-3 title=dom-window-postMessage-3><code>postMessage(<var title="">message</var>, <var title="">messagePort</var>, <var title="">targetOrigin</var>)</code></dfn> method (with three + </ol><h4 id=posting-messages-with-message-ports><span class=secno>7.4.4 </span>Posting messages with message ports</h4><p>When a script invokes the <dfn id=dom-window-postmessage-3 title=dom-window-postMessage-3><code>postMessage(<var title="">message</var>, <var title="">messagePort</var>, <var title="">targetOrigin</var>)</code></dfn> method (with three arguments) on a <code><a href=#window>Window</a></code> object, the user agent must follow these steps: @@ -35601,6 +35686,14 @@ </li> + <li> + + <p>Let <var title="">message clone</var> be the result of + obtaining a <a href=#structured-clone>structured clone</a> of the <var title="">message</var> argument. If this returns an exception, + then throw that exception and abort these steps.</p> + + </li> + <li> <!-- NEW STEP --> <p>If the <var title="">messagePort</var> argument is null, then @@ -35642,12 +35735,10 @@ <p>Create an event that uses the <code><a href=#messageevent>MessageEvent</a></code> interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is cancelable, and has no default action. The <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute must be set to - the value passed as the <var title="">message</var> argument to - the <code title=dom-window-postMessage-3><a href=#dom-window-postmessage-3>postMessage()</a></code> - method, the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> - attribute must be set to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of - an origin">Unicode serialization</a> of the <a href=#origin-0>origin</a> - of the script that invoked the method, and the <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute must be + the value of <var title="">message clone</var>, the <code title=dom-MessageEvent-origin><a href=#dom-messageevent-origin>origin</a></code> attribute must be + set to the <a href=#unicode-serialization-of-an-origin title="Unicode serialization of an + origin">Unicode serialization</a> of the <a href=#origin-0>origin</a> of + the script that invoked the method, and the <code title=dom-MessageEvent-source><a href=#dom-messageevent-source>source</a></code> attribute must be set to the <code><a href=#window>Window</a></code> object of the <a href=#default-view>default view</a> of the <a href=#browsing-context>browsing context</a> for which the <code>Document</code> object with which the script is associated @@ -35679,9 +35770,7 @@ previous section.</p><!-- XXX merge this section and the previous section when implementations have shipped postMessage(). Anne asked that these sections be kept separate so that implementors can avoid getting - confused with the 'port' step. --><h4 id=posting-structured-data><span class=secno>7.4.5 </span>Posting structured data</h4><p class=XXX>People often request the ability to send - name/value pairs, arrays, and numbers using postMessage() instead of - just strings.<h3 id=channel-messaging><span class=secno>7.5 </span><dfn>Channel messaging</dfn></h3><h4 id=introduction-6><span class=secno>7.5.1 </span>Introduction</h4><p><em>This section is non-normative.</em><p class=XXX>An introduction to the channel and port + confused with the 'port' step. --><h3 id=channel-messaging><span class=secno>7.5 </span><dfn>Channel messaging</dfn></h3><h4 id=introduction-6><span class=secno>7.5.1 </span>Introduction</h4><p><em>This section is non-normative.</em><p class=XXX>An introduction to the channel and port APIs.<h4 id=message-channels><span class=secno>7.5.2 </span>Message channels</h4><pre class=idl>[<a href=#dom-messagechannel title=dom-MessageChannel>Constructor</a>] interface <dfn id=messagechannel>MessageChannel</dfn> { readonly attribute <a href=#messageport>MessagePort</a> <a href=#dom-channel-port1 title=dom-channel-port1>port1</a>; @@ -35712,8 +35801,8 @@ <code><a href=#messagechannel>MessageChannel</a></code> object was created.<h4 id=message-ports><span class=secno>7.5.3 </span>Message ports</h4><p>Each channel has two message ports. Data sent through one port is received by the other port, and vice versa.<pre class=idl>interface <dfn id=messageport>MessagePort</dfn> { readonly attribute boolean <a href=#dom-messageport-active title=dom-MessagePort-active>active</a>; - void <a href=#dom-messageport-postmessage title=dom-MessagePort-postMessage>postMessage</a>(in DOMString message); - void <a href=#dom-messageport-postmessage title=dom-MessagePort-postMessage>postMessage</a>(in DOMString message, in <a href=#messageport>MessagePort</a> messagePort);<!-- + void <a href=#dom-messageport-postmessage title=dom-MessagePort-postMessage>postMessage</a>(in any message); + void <a href=#dom-messageport-postmessage title=dom-MessagePort-postMessage>postMessage</a>(in any message, in <a href=#messageport>MessagePort</a> messagePort);<!-- <span>MessagePort</span> <span title="dom-MessagePort-startConversation">startConversation</span>(in DOMString message);--> void <a href=#dom-messageport-start title=dom-MessagePort-start>start</a>(); void <a href=#dom-messageport-close title=dom-MessagePort-close>close</a>(); @@ -35790,6 +35879,10 @@ notice. we don't return false because if the port is _about_ to be closed, the message might not be listened for anyway. --> + <li><p>Let <var title="">message clone</var> be the result of + obtaining a <a href=#structured-clone>structured clone</a> of the <var title="">message</var> argument. If this returns an exception, then + throw that exception and abort these steps.</li> + <li><p>Let <var title="">target port</var> be the port with which <var title="">source port</var> is entangled.</li> @@ -35798,7 +35891,8 @@ cancelable, and has no default action.</li> <li><p>Let the <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> - attribute of the event have the value of <var title="">message</var>, the method's first argument.</li> + attribute of the event have the value of <var title="">message + clone</var>.</li> <li><p>If the method was called with a second argument <var title="">data port</var> and that argument isn't null, then run the following substeps:</p> @@ -35822,9 +35916,7 @@ <li><p>Add the event to the <a href=#port-message-queue>port message queue</a> of <var title="">target port</var>.</li> - </ol><p class=XXX>People often request the ability to send - name/value pairs, arrays, and numbers using postMessage() instead of - just strings.</p><!-- + </ol><!-- <hr> <p>The <dfn
Received on Tuesday, 16 December 2008 04:50:51 UTC