Annotation of html5/postmsg/Overview.html, revision 1.32
1.31 ihickson 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><title>HTML5 Web Messaging</title><style type="text/css">
1.1 ihickson 2: pre { margin-left: 2em; white-space: pre-wrap; }
3: h2 { margin: 3em 0 1em 0; }
4: h3 { margin: 2.5em 0 1em 0; }
5: h4 { margin: 2.5em 0 0.75em 0; }
6: h5, h6 { margin: 2.5em 0 1em; }
7: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
8: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
9: p { margin: 1em 0; }
10: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
11: dl, dd { margin-top: 0; margin-bottom: 0; }
12: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
13: dt + dt { margin-top: 0; }
14: dd dt { margin-top: 0.25em; margin-bottom: 0; }
15: dd p { margin-top: 0; }
16: dd dl + p { margin-top: 1em; }
17: dd table + p { margin-top: 1em; }
18: p + * > li, dd li { margin: 1em 0; }
19: dt, dfn { font-weight: bold; font-style: normal; }
20: dt dfn { font-style: italic; }
21: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
22: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
23: pre em { font-weight: bolder; font-style: normal; }
24: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
25: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
26: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
27: table thead { border-bottom: solid; }
28: table tbody th:first-child { border-left: solid; }
29: table tbody th { text-align: left; }
30: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
31: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
32:
33: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
34: .matrix, .matrix td { border: none; text-align: right; }
35: .matrix { margin-left: 2em; }
36: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
37: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
38: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
39:
40: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
41: img.extra { float: right; }
42: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
43: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
44: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
45: pre.css:first-line { color: #AAAA50; }
1.15 ihickson 46: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1 ihickson 47: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
48: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
49: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
50: dl.domintro dd p { margin: 0.5em 0; }
51: dl.switch { padding-left: 2em; }
52: dl.switch > dt { text-indent: -1.5em; }
53: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
54: dl.triple { padding: 0 0 0 1em; }
55: dl.triple dt, dl.triple dd { margin: 0; display: inline }
56: dl.triple dt:after { content: ':'; }
57: dl.triple dd:after { content: '\A'; white-space: pre; }
58: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
59: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
60: a .diff-new { border-bottom: 1px blue solid; }
61:
62: h2 { page-break-before: always; }
63: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
64: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
65:
66: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
67:
68: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
69: div.head p { margin: 0; }
70: div.head h1 { margin: 0; }
71: div.head .logo { float: right; margin: 0 1em; }
72: div.head .logo img { border: none } /* remove border from top image */
73: div.head dl { margin: 1em 0; }
74: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
75:
76: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
77: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
78: body > .toc > li > * { margin-bottom: 0.5em; }
79: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
80: .toc, .toc li { list-style: none; }
81:
82: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
83: .brief li { margin: 0; padding: 0; }
84: .brief li p { margin: 0; padding: 0; }
85:
86: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
87: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
88: .category-list li { display: inline; }
89: .category-list li:not(:last-child)::after { content: ', '; }
90: .category-list li > span, .category-list li > a { text-transform: lowercase; }
91: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
92:
93: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
94: .XXX > :first-child { margin-top: 0; }
95: p .XXX { line-height: 3em; }
96: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
97: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
98: .annotation :link, .annotation :visited { color: inherit; }
99: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
100: .annotation span { border: none ! important; }
101: .note { color: green; background: transparent; font-family: sans-serif; }
102: .warning { color: red; background: transparent; }
103: .note, .warning { font-weight: bolder; font-style: italic; }
104: p.note, div.note { padding: 0.5em 2em; }
105: span.note { padding: 0 2em; }
106: .note p:first-child, .warning p:first-child { margin-top: 0; }
107: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
108: .warning:before { font-style: normal; }
109: p.note:before { content: 'Note: '; }
110: p.warning:before { content: '\26A0 Warning! '; }
111:
112: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
113: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
114: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
115:
116: h4 { position: relative; z-index: 3; }
117: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
118: .element {
119: background: #EEEEFF;
120: color: black;
121: margin: 0 0 1em 0.15em;
122: padding: 0 1em 0.25em 0.75em;
123: border-left: solid #9999FF 0.25em;
124: position: relative;
125: z-index: 1;
126: }
127: .element:before {
128: position: absolute;
129: z-index: 2;
130: top: 0;
131: left: -1.15em;
132: height: 2em;
133: width: 0.9em;
134: background: #EEEEFF;
135: content: ' ';
136: border-style: none none solid solid;
137: border-color: #9999FF;
138: border-width: 0.25em;
139: }
140:
141: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
142: td > .example:only-child { margin: 0 0 0 0.1em; }
143:
144: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
145: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
146: ul.domTree li li { list-style: none; }
147: ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
148: ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
149: ul.domTree span { font-style: italic; font-family: serif; }
150: ul.domTree .t1 code { color: purple; font-weight: bold; }
151: ul.domTree .t2 { font-style: normal; font-family: monospace; }
152: ul.domTree .t2 .name { color: black; font-weight: bold; }
153: ul.domTree .t2 .value { color: blue; font-weight: normal; }
154: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
155: ul.domTree .t7 code, .domTree .t8 code { color: green; }
156: ul.domTree .t10 code { color: teal; }
157:
1.7 ihickson 158: body.dfnEnabled dfn { cursor: pointer; }
159: .dfnPanel {
160: display: inline;
161: position: absolute;
162: z-index: 10;
163: height: auto;
164: width: auto;
165: padding: 0.5em 0.75em;
166: font: small sans-serif, Droid Sans Fallback;
167: background: #DDDDDD;
168: color: black;
169: border: outset 0.2em;
170: }
171: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
172: .dfnPanel :link, .dfnPanel :visited { color: black; }
173: .dfnPanel p { font-weight: bolder; }
174: .dfnPanel * + p { margin-top: 0.25em; }
175: .dfnPanel li { list-style-position: inside; }
176:
1.1 ihickson 177: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
178: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
179: #configUI p label { display: block; }
180: #configUI #updateUI, #configUI .loginUI { text-align: center; }
181: #configUI input[type=button] { display: block; margin: auto; }
182: </style><style type="text/css">
183:
184: .applies thead th > * { display: block; }
185: .applies thead code { display: block; }
186: .applies tbody th { whitespace: nowrap; }
187: .applies td { text-align: center; }
188: .applies .yes { background: yellow; }
189:
190: .matrix, .matrix td { border: none; text-align: right; }
191: .matrix { margin-left: 2em; }
192:
193: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
194: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
195: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
196:
197: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
198: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
199: #table-example-1 caption { padding-bottom: 0.5em; }
200: #table-example-1 thead, #table-example-1 tbody { border: none; }
201: #table-example-1 th, #table-example-1 td { border: solid thin; }
202: #table-example-1 th { font-weight: normal; }
203: #table-example-1 td { border-style: none solid; vertical-align: top; }
204: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
205: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
206: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
207: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
208: #table-example-1 tbody td:first-child::after { content: leader(". "); }
209: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
210: #table-example-1 tbody td:first-child + td { width: 10em; }
211: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
212: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
213:
214: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
215: .apple-table-examples * { font-family: "Times", serif; }
216: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
217: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
218: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
219: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
220: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
221: .apple-table-examples td { text-align: right; vertical-align: top; }
222: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
223: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
224: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
225: .apple-table-examples sup { line-height: 0; }
226:
227: .details-example img { vertical-align: top; }
228:
1.29 ihickson 229: #named-character-references-table {
230: font-size: 0.6em;
231: column-width: 28em;
232: column-gap: 1em;
233: -moz-column-width: 28em;
234: -moz-column-gap: 1em;
235: -webkit-column-width: 28em;
236: -webkit-column-gap: 1em;
237: }
1.30 ihickson 238: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
239: #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
1.29 ihickson 240:
1.24 ihickson 241: </style><style type="text/css">
1.27 ihickson 242: .domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
243: </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20{%20display:%20none;%20}%0Ahtml%20{%20border:%20solid%20yellow;%20}%20.domintro:before%20{%20display:%20none;%20}" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20{%20background:%20%23FFEEEE;%20}%20.domintro:before%20{%20background:%20%23FFEEEE;%20}" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.1 ihickson 244: function getCookie(name) {
245: var params = location.search.substr(1).split("&");
246: for (var index = 0; index < params.length; index++) {
247: if (params[index] == name)
248: return "1";
249: var data = params[index].split("=");
250: if (data[0] == name)
251: return unescape(data[1]);
252: }
253: var cookies = document.cookie.split("; ");
254: for (var index = 0; index < cookies.length; index++) {
255: var data = cookies[index].split("=");
256: if (data[0] == name)
257: return unescape(data[1]);
258: }
259: return null;
260: }
261: function load(script) {
262: var e = document.createElement('script');
263: e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
264: document.body.appendChild(e);
265: }
266: function init() {
267: if (location.search == '?slow-browser')
268: return;
269: var configUI = document.createElement('div');
270: configUI.id = 'configUI';
271: document.body.appendChild(configUI);
272: // load('reviewer.js'); // would need cross-site XHR
273: if (document.getElementById('head'))
274: load('toc.js');
275: load('styler.js');
276: // load('updater.js'); // would need cross-site XHR
277: load('dfn.js'); // doesn't support split-out specs, but, oh well.
278: // load('status.js'); // would need cross-site XHR
279: if (getCookie('profile') == '1')
280: document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
281: fixBrokenLink();
282: }
283: </script><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css"><body onload="init()"><div class="head" id="head">
284: <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.10 ihickson 285: <h1>HTML5 Web Messaging</h1>
1.1 ihickson 286: <h2 class="no-num no-toc" id="generatedID"></h2>
287:
1.32 ! ihickson 288: <h2 class="no-num no-toc" id="editor-s-draft-3-april-2010">Editor's Draft 3 April 2010</h2>
1.1 ihickson 289: <dl><dt>Latest Published Version:</dt>
290: <dd><a href="http://www.w3.org/TR/postmsg/">http://www.w3.org/TR/postmsg/</a></dd>
291: <dt>Latest Editor's Draft:</dt>
292: <dd><a href="http://dev.w3.org/html5/postmsg/">http://dev.w3.org/html5/postmsg/</a></dd>
293: <!-- ZZZ: add the new version after it has shipped -->
294: <!--
295: <dt>Previous Versions:</dt>
296: -->
297: <!-- :ZZZ -->
298: <dt>Editors:</dt>
299: <dd><a href="mailto:ian@hixie.ch">Ian Hickson</a>, Google, Inc.</dd>
1.3 ihickson 300: </dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
1.22 ihickson 301: © 2010 <a href="http://www.w3.org/"><abbr title="World Wide
1.1 ihickson 302: Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts
303: Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.org/"><abbr title="European Research
304: Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
305: <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
306: <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
307: and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document
308: use</a> rules apply.</p>
1.6 ihickson 309:
310: <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
311: <!-- temporarily removed after discussion with plh in October 2009 -->
1.22 ihickson 312: <!-- will be moved back to below W3C copyright in April 2010 -->
1.6 ihickson 313: <!--
314: <p class="alt">The <a
315: href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">WHATWG
316: version</a> of this specification is available under a license that
317: permits reuse of the specification text.</p>
318: -->
319: <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
320:
1.1 ihickson 321: </div><hr class="top"><h2 class="no-num no-toc" id="abstract">Abstract</h2><p>This specification defines two mechanism for communicating
1.6 ihickson 322: between browsing contexts in HTML documents.<h2 class="no-num no-toc" id="status-of-this-document">Status of This document</h2><!-- intro boilerplate (required) --><p><em>This section describes the status of this document at the
1.1 ihickson 323: time of its publication. Other documents may supersede this
324: document. A list of current W3C publications and the most recently
325: formally published revision of this technical report can be found in
326: the <a href="http://www.w3.org/TR/">W3C technical reports index</a>
327: at http://www.w3.org/TR/.</em></p><!-- where to send feedback (required) --><p>If you wish to make comments regarding this document, please send
328: them to <a href="mailto:public-html-comments@w3.org">public-html-comments@w3.org</a>
329: (<a href="mailto:public-html-comments-request@w3.org?subject=subscribe">subscribe</a>,
330: <a href="http://lists.w3.org/Archives/Public/public-html-comments/">archives</a>)
331:
332: <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING SENTENCE TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
333: or <a href="mailto:whatwg@whatwg.org">whatwg@whatwg.org</a> (<a href="http://lists.whatwg.org/listinfo.cgi/whatwg-whatwg.org">subscribe</a>,
334: <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/">archives</a>),
335: <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING SENTENCE TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
336:
337: or submit them using <a href="http://www.w3.org/Bugs/Public/enter_bug.cgi?product=HTML%20WG">our
338: public bug database</a>.
339:
1.12 ihickson 340: All feedback is welcome.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><p>The working groups maintains <a href="http://www.w3.org/Bugs/Public/buglist.cgi?component=HTML5+Spec%20bugs&component=HTML5+Spec%20proposals&product=HTML%20WG&resolution=NEEDSINFO&resolution=LATER&resolution=REMIND&resolution=---&order=bugs.resolution%2Cbugs.priority%2C%20bugs.bug_severity">a
1.1 ihickson 341: list of all bug reports that the editor has not yet tried to
342: address</a> and <a href="http://www.w3.org/html/wg/tracker/products/1">a list of issues
343: for which the chairs have not yet declared a decision</a>. The
344: editor also maintains <a href="http://www.whatwg.org/issues/">a list
345: of all e-mails that he has not yet tried to address</a>. These bugs,
1.18 ihickson 346: issues, and e-mails apply to multiple HTML-related specifications,
347: not just this one.</p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- stability (required) --><p>Implementors should be aware that this specification is not
1.1 ihickson 348: stable. <strong>Implementors who are not taking part in the
349: discussions are likely to find the specification changing out from
350: under them in incompatible ways.</strong> Vendors interested in
351: implementing this specification before it eventually reaches the
352: Candidate Recommendation stage should join the aforementioned
1.6 ihickson 353: mailing lists and take part in the discussions.</p><!-- not everyone agrees with this (requested before html5 fpwd) --><p>The publication of this document by the W3C as a W3C Working
1.1 ihickson 354: Draft does not imply that all of the participants in the W3C HTML
355: working group endorse the contents of the specification. Indeed, for
356: any section of the specification, one can usually find many members
357: of the working group or of the W3C as a whole who object strongly to
358: the current text, the existence of the section at all, or the idea
359: that the working group should even spend time discussing the concept
360: of that section.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- version history or list of changes (required) --><p>The latest stable version of the editor's draft of this
361: specification is always available on <a href="http://dev.w3.org/html5/">the W3C CVS server</a> and in the <a href="http://svn.whatwg.org/webapps/">WHATWG Subversion
362: repository</a>. The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete.html">latest
363: editor's working copy</a> (which may contain unfinished text in the
364: process of being prepared) contains the latest draft text of this
365: specification (amongst others). For more details, please see the <a href="http://wiki.whatwg.org/wiki/FAQ#What_are_the_various_versions_of_the_spec.3F">WHATWG
366: FAQ</a>.</p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><p>There are various ways to follow the change history for the
367: HTML specifications:<dl><dt>E-mail notifications of changes</dt>
368: <dd>HTML-Diffs mailing list (diff-marked HTML versions for each change): <a href="http://lists.w3.org/Archives/Public/public-html-diffs/latest">http://lists.w3.org/Archives/Public/public-html-diffs/latest</a></dd>
369: <dd>Commit-Watchers mailing list (complete source diffs): <a href="http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org">http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a></dd>
370: <dt>Real-time notifications of changes:</dt>
371: <dd>Generated diff-marked HTML versions for each change: <a href="http://twitter.com/HTML5">http://twitter.com/HTML5</a></dd>
372: <dd>All (non-editorial) changes to the spec source: <a href="http://twitter.com/WHATWG">http://twitter.com/WHATWG</a></dd>
373: <dt>Browsable version-control record of all changes:</dt>
374: <dd>CVSWeb interface with side-by-side diffs: <a href="http://dev.w3.org/cvsweb/html5/">http://dev.w3.org/cvsweb/html5/</a></dd>
375: <dd>Annotated summary with unified diffs: <a href="http://html5.org/tools/web-apps-tracker">http://html5.org/tools/web-apps-tracker</a></dd>
376: <dd>Raw Subversion interface: <code>svn checkout http://svn.whatwg.org/webapps/</code></dd>
377: </dl><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- status of document, group responsible (required) --><p>The W3C <a href="http://www.w3.org/html/wg/">HTML Working
378: Group</a> is the W3C working group responsible for this
379: specification's progress along the W3C Recommendation
380: track.
381:
1.32 ! ihickson 382: This specification is the 3 April 2010 Editor's Draft.
1.20 ihickson 383: </p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- relationship to other work (required) --><p>The contents of this specification are also part of <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/">a
1.19 ihickson 384: specification</a> published by the <a href="http://www.whatwg.org/">WHATWG</a>, which is available under a
1.6 ihickson 385: license that permits reuse of the specification text.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- context and rationale (required) --><!-- (this text is from the RDFa+HTML spec --><p>This specification is an extension to the HTML5 language. All
386: normative content in the HTML5 specification, unless specifically
387: overridden by this specification, is intended to be the basis for
388: this specification.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- required patent boilerplate --><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
1.1 ihickson 389: February 2004 W3C Patent Policy</a>. W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/40318/status" rel="disclosure">public list of
390: any patent disclosures</a> made in connection with the deliverables
391: of the group; that page also includes instructions for disclosing a
392: patent. An individual who has actual knowledge of a patent which the
393: individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
394: Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
1.6 ihickson 395: 6 of the W3C Patent Policy</a>.<h2 class="no-num no-toc" id="contents">Table of Contents</h2>
1.1 ihickson 396: <!--begin-toc-->
397: <ol class="toc">
398: <li><a href="#conformance-requirements"><span class="secno">1 </span>Conformance requirements</a></li>
1.10 ihickson 399: <li><a href="#event-definitions"><span class="secno">2 </span>Event definitions</a></li>
400: <li><a href="#crossDocumentMessages"><span class="secno">3 </span>Cross-document messaging</a>
1.1 ihickson 401: <ol>
1.10 ihickson 402: <li><a href="#introduction"><span class="secno">3.1 </span>Introduction</a></li>
1.28 ihickson 403: <li><a href="#security-postmsg"><span class="secno">3.2 </span>Security</a>
1.1 ihickson 404: <ol>
1.10 ihickson 405: <li><a href="#authors"><span class="secno">3.2.1 </span>Authors</a></li>
406: <li><a href="#user-agents"><span class="secno">3.2.2 </span>User agents</a></ol></li>
407: <li><a href="#posting-messages"><span class="secno">3.3 </span>Posting messages</a></li>
408: <li><a href="#posting-messages-with-message-ports"><span class="secno">3.4 </span>Posting messages with message ports</a></ol></li>
409: <li><a href="#channel-messaging"><span class="secno">4 </span>Channel messaging</a>
1.1 ihickson 410: <ol>
1.10 ihickson 411: <li><a href="#introduction-0"><span class="secno">4.1 </span>Introduction</a></li>
412: <li><a href="#message-channels"><span class="secno">4.2 </span>Message channels</a></li>
413: <li><a href="#message-ports"><span class="secno">4.3 </span>Message ports</a>
1.1 ihickson 414: <ol>
1.10 ihickson 415: <li><a href="#ports-and-garbage-collection"><span class="secno">4.3.1 </span>Ports and garbage collection</a></ol></ol></li>
1.1 ihickson 416: <li><a class="no-num" href="#references">References</a></li>
417: <li><a class="no-num" href="#acknowledgements">Acknowledgements</a></ol>
418: <!--end-toc--><hr><h2 id="conformance-requirements"><span class="secno">1 </span>Conformance requirements</h2><p>This specification is an HTML specification. All the conformance
419: requirements, conformance classes, definitions, dependencies,
1.4 ihickson 420: terminology, and typographical conventions described in the core
1.10 ihickson 421: HTML5 specification apply to this specification. <a href="#refsHTML5">[HTML5]</a><h2 id="event-definitions"><span class="secno">2 </span>Event definitions</h2><p>Messages in <span>server-sent events</span>, <span>Web
1.1 ihickson 422: sockets</span>, <a href="#crossDocumentMessages">cross-document messaging</a>, and
423: <a href="#channel-messaging">channel messaging</a> use the <dfn id="event-message" title="event-message"><code>message</code></dfn> event.
424:
425: <a href="#refsEVENTSOURCE">[EVENTSOURCE]</a>
426: <a href="#refsWEBSOCKET">[WEBSOCKET]</a>
427:
1.17 ihickson 428: <p>The following interface is defined for this event:<pre class="idl">interface <dfn id="messageevent">MessageEvent</dfn> : <span>Event</span> {
1.1 ihickson 429: readonly attribute any <a href="#dom-messageevent-data" title="dom-MessageEvent-data">data</a>;
430: readonly attribute DOMString <a href="#dom-messageevent-origin" title="dom-MessageEvent-origin">origin</a>;
431: readonly attribute DOMString <a href="#dom-messageevent-lasteventid" title="dom-MessageEvent-lastEventId">lastEventId</a>;
432: readonly attribute <span>WindowProxy</span> <a href="#dom-messageevent-source" title="dom-MessageEvent-source">source</a>;
433: readonly attribute <a href="#messageportarray">MessagePortArray</a> <a href="#dom-messageevent-ports" title="dom-MessageEvent-ports">ports</a>;
434: 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 <span>WindowProxy</span> sourceArg, in <a href="#messageportarray">MessagePortArray</a> portsArg);
435: };</pre><dl class="domintro"><dt><var title="">event</var> . <code title="dom-MessageEvent-data"><a href="#dom-messageevent-data">data</a></code></dt>
436:
437: <dd>
438:
439: <p>Returns the data of the message.</p>
440:
441: </dd>
442:
443: <dt><var title="">event</var> . <code title="dom-MessageEvent-origin"><a href="#dom-messageevent-origin">origin</a></code></dt>
444:
445: <dd>
446:
447: <p>Returns the origin of the message, for <span>server-sent
448: events</span> and <a href="#crossDocumentMessages">cross-document messaging</a>.</p>
449:
450: </dd>
451:
452: <dt><var title="">event</var> . <code title="dom-MessageEvent-lastEventId"><a href="#dom-messageevent-lasteventid">lastEventId</a></code></dt>
453:
454: <dd>
455:
456: <p>Returns the last event ID, for <span>server-sent
457: events</span>.</p>
458:
459: </dd>
460:
461: <dt><var title="">event</var> . <code title="dom-MessageEvent-source"><a href="#dom-messageevent-source">source</a></code></dt>
462:
463: <dd>
464:
465: <p>Returns the <code>WindowProxy</code> of the source window, for
466: <a href="#crossDocumentMessages">cross-document messaging</a>.</p>
467:
468: </dd>
469:
470: <dt><var title="">event</var> . <code title="dom-MessageEvent-ports"><a href="#dom-messageevent-ports">ports</a></code></dt>
471:
472: <dd>
473:
474: <p>Returns the <code><a href="#messageportarray">MessagePortArray</a></code> sent with the
475: message, for <a href="#crossDocumentMessages">cross-document messaging</a> and
476: <a href="#channel-messaging">channel messaging</a>.</p>
477:
478: </dd>
479:
480: </dl><div class="impl">
481:
482: <p>The <dfn id="dom-messageevent-initmessageevent" title="dom-MessageEvent-initMessageEvent"><code>initMessageEvent()</code></dfn>
483: method must initialize the event in a manner analogous to the
484: similarly-named method in the DOM Events interfaces. <a href="#refsDOMEVENTS">[DOMEVENTS]</a></p>
485:
486: <p>The <dfn id="dom-messageevent-data" title="dom-MessageEvent-data"><code>data</code></dfn>
487: attribute represents the message being sent.</p>
488:
489: <p>The <dfn id="dom-messageevent-origin" title="dom-MessageEvent-origin"><code>origin</code></dfn> attribute
490: represents, in <span>server-sent events</span> and
491: <a href="#crossDocumentMessages">cross-document messaging</a>, the <span>origin</span> of
492: the document that sent the message (typically the scheme, hostname,
493: and port of the document, but not its path or fragment
494: identifier).</p>
495:
496: <p>The <dfn id="dom-messageevent-lasteventid" title="dom-MessageEvent-lastEventId"><code>lastEventId</code></dfn>
497: attribute represents, in <span>server-sent events</span>, the <span title="concept-event-stream-last-event-id">last event ID
498: string</span> of the event source.</p>
499:
500: <p>The <dfn id="dom-messageevent-source" title="dom-MessageEvent-source"><code>source</code></dfn> attribute
501: represents, in <a href="#crossDocumentMessages">cross-document messaging</a>, the
502: <code>WindowProxy</code> of the <span>browsing context</span> of the
503: <code>Window</code> object from which the message came.</p>
504:
505: <p>The <dfn id="dom-messageevent-ports" title="dom-MessageEvent-ports"><code>ports</code></dfn>
506: attribute represents, in <a href="#crossDocumentMessages">cross-document messaging</a> and
507: <a href="#channel-messaging">channel messaging</a> the <code><a href="#messageportarray">MessagePortArray</a></code>
508: being sent, if any.</p>
509:
510: <p>Except where otherwise specified, when the user agent creates and
511: dispatches a <code title="event-message"><a href="#event-message">message</a></code> event in the
512: algorithms described in the following sections, the <code title="dom-MessageEvent-lastEventId"><a href="#dom-messageevent-lasteventid">lastEventId</a></code> attribute
513: must be the empty string, the <code title="dom-MessageEvent-origin"><a href="#dom-messageevent-origin">origin</a></code> attribute must be the
514: empty string, the <code title="dom-MessageEvent-source"><a href="#dom-messageevent-source">source</a></code> attribute must be
515: null, and the <code title="dom-MessageEvent-ports"><a href="#dom-messageevent-ports">ports</a></code>
516: attribute must be null.</p>
517:
1.10 ihickson 518: </div><h2 id="crossDocumentMessages"><span class="secno">3 </span><dfn>Cross-document messaging</dfn></h2><p>Web browsers, for security and privacy reasons, prevent documents
1.1 ihickson 519: in different domains from affecting each other; that is, cross-site
520: scripting is disallowed.<p>While this is an important security feature, it prevents pages
521: from different domains from communicating even when those pages are
522: not hostile. This section introduces a messaging system that allows
523: documents to communicate with each other regardless of their source
524: domain, in a way designed to not enable cross-site scripting
525: attacks.<div class="impl">
526:
527: <p>The <span>task source</span> for the <span title="concept-task">tasks</span> in <a href="#crossDocumentMessages">cross-document
528: messaging</a> is the <dfn id="posted-message-task-source">posted message task source</dfn>.</p>
529:
1.10 ihickson 530: </div><h3 id="introduction"><span class="secno">3.1 </span>Introduction</h3><p><i>This section is non-normative.</i><div class="example">
1.1 ihickson 531:
532: <p>For example, if document A contains an <code>iframe</code>
533: element that contains document B, and script in document A calls
534: <code title="dom-window-postMessage-2"><a href="#dom-window-postmessage-2">postMessage()</a></code> on the
535: <code>Window</code> object of document B, then a message event will
536: be fired on that object, marked as originating from the
537: <code>Window</code> of document A. The script in document A might
538: look like:</p>
539:
540: <pre>var o = document.getElementsByTagName('iframe')[0];
541: o.contentWindow.postMessage('Hello world', 'http://b.example.org/');</pre>
542:
543: <p>To register an event handler for incoming events, the script
544: would use <code title="">addEventListener()</code> (or similar
545: mechanisms). For example, the script in document B might look
546: like:</p>
547:
548: <pre>window.addEventListener('message', receiver, false);
549: function receiver(e) {
550: if (e.origin == 'http://example.com') {
551: if (e.data == 'Hello world') {
552: e.source.postMessage('Hello', e.origin);
553: } else {
554: alert(e.data);
555: }
556: }
557: }</pre>
558:
559: <p>This script first checks the domain is the expected domain, and
560: then looks at the message, which it either displays to the user, or
561: responds to by sending a message back to the document which sent
562: the message in the first place.</p>
563:
1.28 ihickson 564: </div><h3 id="security-postmsg"><span class="secno">3.2 </span>Security</h3><div class="impl">
1.1 ihickson 565:
1.10 ihickson 566: <h4 id="authors"><span class="secno">3.2.1 </span>Authors</h4>
1.1 ihickson 567:
1.28 ihickson 568: </div><p class="warning" id="security-4">Use of this API requires extra
569: care to protect users from hostile entities abusing a site for their
570: own purposes.<p>Authors should check the <code title="dom-MessageEvent-origin"><a href="#dom-messageevent-origin">origin</a></code> attribute to ensure
1.1 ihickson 571: that messages are only accepted from domains that they expect to
572: receive messages from. Otherwise, bugs in the author's message
573: handling code could be exploited by hostile sites.<p>Furthermore, even after checking the <code title="dom-MessageEvent-origin"><a href="#dom-messageevent-origin">origin</a></code> attribute, authors
574: should also check that the data in question is of the expected
575: format. Otherwise, if the source of the event has been attacked
576: using a cross-site scripting flaw, further unchecked processing of
577: information sent using the <code title="dom-window-postMessage-2"><a href="#dom-window-postmessage-2">postMessage()</a></code> method could
578: result in the attack being propagated into the receiver.<p>Authors should not use the wildcard keyword (*) in the <var title="">targetOrigin</var> argument in messages that contain any
579: confidential information, as otherwise there is no way to guarantee
580: that the message is only delivered to the recipient to which it was
581: intended.<div class="impl">
582:
1.10 ihickson 583: <h4 id="user-agents"><span class="secno">3.2.2 </span>User agents</h4>
1.1 ihickson 584:
585: <p>The integrity of this API is based on the inability for scripts
586: of one <span>origin</span> to post arbitrary events (using <code title="">dispatchEvent()</code> or otherwise) to objects in other
587: origins (those that are not the <span title="same
588: origin">same</span>).</p>
589:
590: <p class="note">Implementors are urged to take extra care in the
591: implementation of this feature. It allows authors to transmit
592: information from one domain to another domain, which is normally
593: disallowed for security reasons. It also requires that UAs be
594: careful to allow access to certain properties but not others.</p>
595:
1.10 ihickson 596: </div><h3 id="posting-messages"><span class="secno">3.3 </span>Posting messages</h3><dl class="domintro"><dt><var title="">window</var> . <code title="dom-window-postMessage-2"><a href="#dom-window-postmessage-2">postMessage</a></code>(<var title="">message</var>, [ <var title="">ports</var>, ] <var title="">targetOrigin</var>)</dt>
1.1 ihickson 597:
598: <dd>
599:
600: <p>Posts a message, optionally with an array of ports, to the
601: given window.</p>
602:
603: <p>If the origin of the target window doesn't match the given
604: origin, the message is discarded, to avoid information leakage. To
605: send the message to the target regardless of origin, set the
1.11 ihickson 606: target origin to "<code title="">*</code>". To restrict the
607: message to same-origin targets only, without needing to explicitly
608: state the origin, set the target origin to "<code title="">/</code>".</p>
1.1 ihickson 609:
610: <p>Throws an <code>INVALID_STATE_ERR</code> if the <var title="">ports</var> array is not null and it contains either null
611: entries or duplicate ports.</p>
612:
613: </dd>
614:
615: </dl><div class="impl">
616:
617: <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
618: arguments) on a <code>Window</code> object, the user agent must
619: follow these steps:
620:
621: <ol><li>
622:
623: <p>If the value of the <var title="">targetOrigin</var> argument
1.11 ihickson 624: is neither a single U+002A ASTERISK character (*), a single U+002F
625: SOLIDUS character (/), nor an <span>absolute URL</span> with a
1.1 ihickson 626: <code title="url-host-specific"><host-specific></code>
1.11 ihickson 627: component that is either empty or a single U+002F SOLIDUS
1.1 ihickson 628: character (/), then throw a <code>SYNTAX_ERR</code> exception and
629: abort the overall set of steps.</p>
630:
631: </li>
632:
633: <li>
634:
635: <p>Let <var title="">message clone</var> be the result of
636: obtaining a <span>structured clone</span> of the <var title="">message</var> argument. If this throws an exception, then
637: throw that exception and abort these steps.</p>
638:
639: </li>
640:
641: <li>
642:
643: <p>Return from the <code title="dom-window-postMessage-2"><a href="#dom-window-postmessage-2">postMessage()</a></code> method, but
644: asynchronously continue running these steps.</p>
645:
646: </li>
647:
648: <li>
649:
1.11 ihickson 650: <p>If the <var title="">targetOrigin</var> argument is a single
651: literal U+002F SOLIDUS character (/), and the
652: <code>Document</code> of the <code>Window</code> object on which
653: the method was invoked does not have the <span>same origin</span>
1.16 ihickson 654: as the <span>entry script</span>'s <span title="script's
655: document">document</span>, then abort these steps silently.</p>
1.11 ihickson 656:
657: <p>Otherwise, if the <var title="">targetOrigin</var> argument is
658: an <span>absolute URL</span>, and the <code>Document</code> of the
659: <code>Window</code> object on which the method was invoked does
660: not have the <span>same origin</span> as <var title="">targetOrigin</var>, then abort these steps silently.</p>
661:
662: <p>Otherwise, the <var title="">targetOrigin</var> argument is a
663: single literal U+002A ASTERISK character (*), and no origin check
664: is made.</p>
1.1 ihickson 665:
666: </li>
667:
668: <li>
669:
670: <p>Create an event that uses the <code><a href="#messageevent">MessageEvent</a></code>
671: interface, with the event name <code title="event-message"><a href="#event-message">message</a></code>, which does not bubble, is
672: not 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
673: 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
674: set to the <span title="Unicode serialization of an
675: origin">Unicode serialization</span> of the <span>origin</span> of
676: the script that invoked the method, and the <code title="dom-MessageEvent-source"><a href="#dom-messageevent-source">source</a></code> attribute must be
1.25 ihickson 677: set to the <span>script's global object</span>'s
678: <code>WindowProxy</code> object.</p> <!-- invariant: the global
679: object is always a Window if the script can see this method -->
1.1 ihickson 680:
681: </li>
682:
683: <li>
684:
685: <p><span>Queue a task</span> to dispatch the event created in the
686: previous step at the <code>Window</code> object on which the
687: method was invoked. The <span>task source</span> for this <span title="concept-task">task</span> is the <a href="#posted-message-task-source">posted message task
688: source</a>.</p>
689:
690: </li>
691:
692: </ol></div><div class="impl">
693:
1.10 ihickson 694: <h3 id="posting-messages-with-message-ports"><span class="secno">3.4 </span>Posting messages with message ports</h3>
1.1 ihickson 695:
1.26 ihickson 696: <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="">targetOrigin</var>, <var title="">ports</var>)</code></dfn> method (with three arguments) on
697: a <code>Window</code> object, the user agent must follow these
698: steps:
1.1 ihickson 699:
700: <ol><!-- EXCEPT WHERE NOTED, THESE STEPS ARE IDENTICAL TO THE PREVIOUS SECTION --><!-- one exception is the use of -3 instead of -2 in the xrefs --><li>
701:
702: <p>If the value of the <var title="">targetOrigin</var> argument
1.11 ihickson 703: is neither a single U+002A ASTERISK character (*), a single U+002F
704: SOLIDUS character (/), nor an <span>absolute URL</span> with a
1.1 ihickson 705: <code title="url-host-specific"><host-specific></code>
1.11 ihickson 706: component that is either empty or a single U+002F SOLIDUS
1.1 ihickson 707: character (/), then throw a <code>SYNTAX_ERR</code> exception and
708: abort the overall set of steps.</p>
709:
710: </li>
711:
712: <li>
713:
714: <p>Let <var title="">message clone</var> be the result of
715: obtaining a <span>structured clone</span> of the <var title="">message</var> argument. If this throws an exception, then
716: throw that exception and abort these steps.</p>
717:
718: </li>
719:
720: <li> <!-- NEW STEP -->
721:
722: <p>If the <var title="">ports</var> argument is empty<!-- or null
723: (if we make it nullable)-->, then act as if the method had just
724: been <a href="#dom-window-postmessage-2" title="dom-window-postMessage-2">called with two
725: arguments</a>, <var title="">message</var> and <var title="">targetOrigin</var>.</p>
726:
727: </li>
728:
729: <li> <!-- NEW STEP -->
730:
731: <p>If any of the entries in <var title="">ports</var> are null, if
732: any <code><a href="#messageport">MessagePort</a></code> object is listed in <var title="">ports</var> more than once, or if any of the
733: <code><a href="#messageport">MessagePort</a></code> objects listed in <var title="">ports</var> have already been cloned once before, then
734: throw an <code>INVALID_STATE_ERR</code> exception.</p>
735:
736: </li>
737:
738: <li> <!-- NEW STEP -->
739:
740: <p>Let <var title="">new ports</var> be an empty array.</p>
741:
742: <p>For each port in <var title="">ports</var> in turn,
743: obtain a new port by <a href="#clone-a-port" title="clone a port">cloning</a> the
744: port with the <code>Window</code> object on which the method was
745: invoked as the owner of the clone, and append the clone to the
746: <var title="">new ports</var> array.</p>
747: <!--
748: <p class="note">If the original <var title="">ports</var>
749: array was empty, then the <var title="">new ports</var> array will
750: also be empty.</p>
751: -->
752: </li>
753:
754: <li>
755:
756: <p>Return from the <code title="dom-window-postMessage-3"><a href="#dom-window-postmessage-3">postMessage()</a></code> method, but
757: asynchronously continue running these steps.</p>
758:
759: </li>
760:
761: <li>
762:
1.11 ihickson 763: <p>If the <var title="">targetOrigin</var> argument is a single
764: literal U+002F SOLIDUS character (/), and the
765: <code>Document</code> of the <code>Window</code> object on which
766: the method was invoked does not have the <span>same origin</span>
1.16 ihickson 767: as the <span>entry script</span>'s <span title="script's
768: document">document</span>, then abort these steps silently.</p>
1.11 ihickson 769:
770: <p>Otherwise, if the <var title="">targetOrigin</var> argument is
771: an <span>absolute URL</span>, and the <code>Document</code> of the
772: <code>Window</code> object on which the method was invoked does
773: not have the <span>same origin</span> as <var title="">targetOrigin</var>, then abort these steps silently.</p>
774:
775: <p>Otherwise, the <var title="">targetOrigin</var> argument is a
776: single literal U+002A ASTERISK character (*), and no origin check
777: is made.</p>
1.1 ihickson 778:
779: </li>
780:
781: <li>
782:
783: <p>Create an event that uses the <code><a href="#messageevent">MessageEvent</a></code>
784: interface, with the event name <code title="event-message"><a href="#event-message">message</a></code>, which does not bubble, is
785: not 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
786: 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
787: set to the <span title="Unicode serialization of an
788: origin">Unicode serialization</span> of the <span>origin</span> of
789: the script that invoked the method, and the <code title="dom-MessageEvent-source"><a href="#dom-messageevent-source">source</a></code> attribute must be
1.25 ihickson 790: set to the <span>script's global object</span>'s
791: <code>WindowProxy</code> object.</p> <!-- invariant: the global
792: object is always a Window if the script can see this method -->
1.1 ihickson 793:
794: </li>
795:
796: <li> <!-- NEW STEP -->
797:
798: <p>Let the <code title="dom-MessageEvent-ports"><a href="#dom-messageevent-ports">ports</a></code> attribute
799: of the event be the <var title="">new ports</var> array.</p>
800:
801: </li>
802:
803: <li>
804:
805: <p><span>Queue a task</span> to dispatch the event created in the
806: previous step at the <code>Window</code> object on which the
807: method was invoked. The <span>task source</span> for this <span title="concept-task">task</span> is the <a href="#posted-message-task-source">posted message task
808: source</a>.</p>
809:
810: </li>
811:
1.25 ihickson 812: </ol><p class="note">These steps, with the exception of the third,
813: fourth, and fifth steps and the penultimate step, are identical to
814: those in the previous section.</p>
1.1 ihickson 815:
816: <!-- v2: we can merge this section and the previous section when
817: implementations have shipped postMessage(). Anne asked that these
818: sections be kept separate so that implementors can avoid getting
819: confused with the 'port' step. -->
820:
1.10 ihickson 821: </div><h2 id="channel-messaging"><span class="secno">4 </span><dfn>Channel messaging</dfn></h2><h3 id="introduction-0"><span class="secno">4.1 </span>Introduction</h3><p><i>This section is non-normative.</i><p>To enable independent pieces of code (e.g. running in different
1.1 ihickson 822: <span title="browsing context">browsing contexts</span>) to
823: communicate directly, authors can use <a href="#channel-messaging">channel
824: messaging</a>.<p>Communication channels in this mechanisms are implemented as
825: two-ways pipes, with a port at each end. Messages sent in one port
826: are delivered at the other port, and vice-versa. Messages are
827: asynchronous, and delivered as DOM events.<p>To create a connection (two "entangled" ports), the <code title="">MessageChannel()</code> constructor is called:<pre>var channel = new MessageChannel();</pre><p>One of the ports is kept as the local port, and the other port is
1.32 ! ihickson 828: sent to the remote code, e.g. using <code title="dom-window-postMessage-3"><a href="#dom-window-postmessage-3">postMessage()</a></code>:<pre>otherWindow.postMessage('hello', 'http://example.com', [channel.port2]);</pre><p>To send messages, the <code title="dom-MessagePort-postMessage"><a href="#dom-messageport-postmessage">postMessage()</a></code> method on
1.1 ihickson 829: the port is used:<pre>channel.port1.postMessage('hello');</pre><p>To receive messages, one listens to <code title="event-message"><a href="#event-message">message</a></code> events:<pre>channel.port1.onmessage = handleMessage;
830: function handleMessage(event) {
831: // message is in event.data
832: // ...
1.10 ihickson 833: }</pre><h3 id="message-channels"><span class="secno">4.2 </span>Message channels</h3><pre class="idl">[<a href="#dom-messagechannel" title="dom-MessageChannel">Constructor</a>]
1.1 ihickson 834: interface <dfn id="messagechannel">MessageChannel</dfn> {
835: readonly attribute <a href="#messageport">MessagePort</a> <a href="#dom-channel-port1" title="dom-channel-port1">port1</a>;
836: readonly attribute <a href="#messageport">MessagePort</a> <a href="#dom-channel-port2" title="dom-channel-port2">port2</a>;
837: };</pre><dl class="domintro"><dt><var title="">channel</var> = new <code title="dom-MessageChannel"><a href="#dom-messagechannel">MessageChannel</a></code>()</dt>
838:
839: <dd>
840:
841: <p>Returns a new <code><a href="#messagechannel">MessageChannel</a></code> object with two new <code><a href="#messageport">MessagePort</a></code> objects.</p>
842:
843: </dd>
844:
845: <dt><var title="">channel</var> . <code title="dom-MessageChannel-port1">port1</code></dt>
846:
847: <dd>
848:
849: <p>Returns the first <code><a href="#messageport">MessagePort</a></code> object.</p>
850:
851: </dd>
852:
853: <dt><var title="">channel</var> . <code title="dom-MessageChannel-port2">port2</code></dt>
854:
855: <dd>
856:
857: <p>Returns the second <code><a href="#messageport">MessagePort</a></code> object.</p>
858:
859: </dd>
860:
861: </dl><div class="impl">
862:
863: <p>When the <dfn id="dom-messagechannel" title="dom-MessageChannel"><code>MessageChannel()</code></dfn>
864: constructor is called, it must run the following algorithm:</p>
865:
866: <ol><li><p><a href="#create-a-new-messageport-object">Create a new <code>MessagePort</code> object</a>
867: owned by the <span>script's global object</span>, and let <var title="">port1</var> be that object.</li>
868:
869: <li><p><a href="#create-a-new-messageport-object">Create a new <code>MessagePort</code> object</a>
870: owned by the <span>script's global object</span>, and let <var title="">port2</var> be that object.</li>
871:
872: <li><p><a href="#entangle">Entangle</a> the <var title="">port1</var> and <var title="">port2</var> objects.</li>
873:
874: <li><p>Instantiate a new <code><a href="#messagechannel">MessageChannel</a></code> object, and
875: let <var title="">channel</var> be that object.</li>
876:
877: <li><p>Let the <code title="dom-channel-port1"><a href="#dom-channel-port1">port1</a></code>
878: attribute of the <var title="">channel</var> object be <var title="">port1</var>.</p>
879:
880: <li><p>Let the <code title="dom-channel-port2"><a href="#dom-channel-port2">port2</a></code>
881: attribute of the <var title="">channel</var> object be <var title="">port2</var>.</p>
882:
883: <li><p>Return <var title="">channel</var>.</li>
884:
885: </ol><p>This constructor must be visible when the <span>script's global
886: object</span> is either a <code>Window</code> object or an object
887: implementing the <code>WorkerUtils</code> interface.</p>
888:
889: <p>The <dfn id="dom-channel-port1" title="dom-channel-port1"><code>port1</code></dfn> and
890: <dfn id="dom-channel-port2" title="dom-channel-port2"><code>port2</code></dfn> attributes
891: must return the values they were assigned when the
892: <code><a href="#messagechannel">MessageChannel</a></code> object was created.</p>
893:
1.10 ihickson 894: </div><h3 id="message-ports"><span class="secno">4.3 </span>Message ports</h3><p>Each channel has two message ports. Data sent through one port is
1.1 ihickson 895: received by the other port, and vice versa.<pre class="idl">typedef sequence<MessagePort> <dfn id="messageportarray">MessagePortArray</dfn>;
896:
897: interface <dfn id="messageport">MessagePort</dfn> {
898: <!-- v2-onclose readonly attribute boolean <span title="dom-MessagePort-active">active</span>;
899: --> void <a href="#dom-messageport-postmessage" title="dom-MessagePort-postMessage">postMessage</a>(in any message, in optional <a href="#messageportarray">MessagePortArray</a> ports);<!--
900: <span>MessagePort</span> <span title="dom-MessagePort-startConversation">startConversation</span>(in any message);-->
901: void <a href="#dom-messageport-start" title="dom-MessagePort-start">start</a>();
902: void <a href="#dom-messageport-close" title="dom-MessagePort-close">close</a>();
903:
904: // event handlers
905: attribute <span>Function</span> <a href="#handler-messageport-onmessage" title="handler-MessagePort-onmessage">onmessage</a>;
906: };
907: <a href="#messageport">MessagePort</a> implements <span>EventTarget</span>;</pre><dl class="domintro"><!-- v2-onclose
908: <dt><var title="">port</var> . <code title="dom-MessagePort-active">active</code></dt>
909:
910: <dd>
911:
912: <p>Returns true if the port is still active; otherwise, returns false.</p>
913:
914: </dd>
915: --><dt><var title="">port</var> . <code title="dom-MessagePort-poseMessage">postMessage</code>(<var title="">message</var> [, <var title="">ports</var>] )</dt>
916:
917: <dd>
918:
919: <p>Posts a message through the channel, optionally with the given
920: ports.</p>
921:
922: <p>Throws an <code>INVALID_STATE_ERR</code> if the <var title="">ports</var> array is not null and it contains either null
923: entries, duplicate ports, or the source or target port.</p>
924:
925: </dd>
926:
927: <dt><var title="">port</var> . <code title="dom-MessagePort-start"><a href="#dom-messageport-start">start</a></code>()</dt>
928:
929: <dd>
930:
931: <p>Begins dispatching messages received on the port.</p>
932:
933: </dd>
934:
935: <dt><var title="">port</var> . <code title="dom-MessagePort-close"><a href="#dom-messageport-close">close</a></code>()</dt>
936:
937: <dd>
938:
939: <p>Disconnects the port, so that it is no longer active.</p>
940:
941: </dd>
942:
943: </dl><div class="impl">
944:
945: <p>Each <code><a href="#messageport">MessagePort</a></code> object can be entangled with
946: another (a symmetric relationship). Each <code><a href="#messageport">MessagePort</a></code>
947: object also has a <span>task source</span> called the <dfn id="port-message-queue">port
948: message queue</dfn>, initial empty. A <a href="#port-message-queue">port message
949: queue</a> can be enabled or disabled, and is initially
950: disabled. Once enabled, a port can never be disabled again (though
951: messages in the queue can get moved to another queue or removed
952: altogether, which has much the same effect).</p>
953:
954: <p>When the user agent is to <dfn id="create-a-new-messageport-object">create a new
955: <code>MessagePort</code> object</dfn> owned by a <span>script's
956: global object</span> object <var title="">owner</var>, it must
957: instantiate a new <code><a href="#messageport">MessagePort</a></code> object, and let its owner
958: be <var title="">owner</var>.</p>
959:
960: <hr><p>When the user agent is to <dfn id="entangle">entangle</dfn> two
961: <code><a href="#messageport">MessagePort</a></code> objects, it must run the following
962: steps:</p>
963:
964: <ol><li>
965:
966: <p>If one of the ports is already entangled, then disentangle it
967: and the port that it was entangled with.</p>
968:
969: <p class="note">If those two previously entangled ports were the
970: two ports of a <code><a href="#messagechannel">MessageChannel</a></code> object, then that
971: <code><a href="#messagechannel">MessageChannel</a></code> object no longer represents an actual
972: channel: the two ports in that object are no longer entangled.</p>
973:
974: </li>
975:
976: <li><p>Associate the two ports to be entangled, so that they form
977: the two parts of a new channel. (There is no
978: <code><a href="#messagechannel">MessageChannel</a></code> object that represents this
979: channel.)</li>
980:
981: </ol><hr><p>When the user agent is to <dfn id="clone-a-port">clone a port</dfn> <var title="">original port</var>, with the clone being owned by <var title="">owner</var>, it must run the following steps, which return
982: a new <code><a href="#messageport">MessagePort</a></code> object. These steps must be run
983: atomically.</p>
984:
985: <ol><li><p><a href="#create-a-new-messageport-object">Create a new <code>MessagePort</code> object</a>
986: owned by <var title="">owner</var>, and let <var title="">new
987: port</var> be that object.</li>
988:
989: <li><p>Move all the events in the <a href="#port-message-queue">port message queue</a>
990: of <var title="">original port</var> to the <a href="#port-message-queue">port message
991: queue</a> of <var title="">new port</var>, if any, leaving the
992: <var title="">new port</var>'s <a href="#port-message-queue">port message queue</a> in
993: its initial disabled state.</li>
994:
995: <li>
996:
997: <p>If the <var title="">original port</var> is entangled with
998: another port, then run these substeps:</p>
999:
1000: <ol><li><p>Let the <var title="">remote port</var> be the port with
1001: which the <var title="">original port</var> is entangled.</li>
1002:
1003: <li><p><a href="#entangle">Entangle</a> the <var title="">remote port</var>
1004: and <var title="">new port</var> objects. The <var title="">original port</var> object will be disentangled by this
1005: process.</li>
1006:
1007: </ol></li>
1008:
1009: <li><p>Return <var title="">new port</var>. It is the
1010: clone.</li>
1011:
1012: </ol><hr><!-- v2-onclose
1013: <p>The <dfn title="dom-MessagePort-active"><code>active</code></dfn>
1014: attribute must return true if the port is entangled, and false
1015: otherwise.</p>
1016:
1017: <hr>
1018: --><p>The <dfn id="dom-messageport-postmessage" title="dom-MessagePort-postMessage"><code>postMessage()</code></dfn>
1019: method, when called on a port <var title="">source port</var>, must
1020: cause the user agent to run the following steps:</p>
1021:
1022: <ol><li><p>Let <var title="">target port</var> be the port with which
1023: <var title="">source port</var> is entangled, if any.</li>
1024:
1025: <li><p>If the method was called with a second argument <var title="">ports</var> and that argument isn't null, then, if any of
1026: the entries in <var title="">ports</var> are null, if any
1027: <code><a href="#messageport">MessagePort</a></code> object is listed in <var title="">ports</var> more than once, if any of the
1028: <code><a href="#messageport">MessagePort</a></code> objects listed in <var title="">ports</var> have already been cloned once before, or if
1029: any of the entries in <var title="">ports</var> are either the <var title="">source port</var> or the <var title="">target port</var>
1030: (if any), then throw an <code>INVALID_STATE_ERR</code>
1031: exception.</li>
1032:
1033: <li><p>If there is no <var title="">target port</var> (i.e. if <var title="">source port</var> is not entangled), then abort these
1034: steps.</li>
1035: <!-- we don't raise an exception if there is no target port because
1036: this can happen at a moment's notice. we don't return false because
1037: if the port is _about_ to be closed, the message might not be
1038: listened for anyway. -->
1039:
1040: <li><p>Create an event that uses the <code><a href="#messageevent">MessageEvent</a></code>
1041: interface, with the name <code title="event-message"><a href="#event-message">message</a></code>, which does not bubble, is not
1042: cancelable, and has no default action.</li>
1043:
1044: <li><p>Let <var title="">message</var> be the method's first
1045: argument.</li>
1046:
1047: <li><p>Let <var title="">message clone</var> be the result of
1048: obtaining a <span>structured clone</span> of <var title="">message</var>. If this throws an exception, then throw
1049: that exception and abort these steps.</li>
1050:
1051: <li><p>Let the <code title="dom-MessageEvent-data"><a href="#dom-messageevent-data">data</a></code>
1052: attribute of the event have the value of <var title="">message
1053: clone</var>.</li>
1054:
1055: <li><p>If the method was called with a second argument <var title="">ports</var> and that argument isn't null, then run the
1056: following substeps:</p>
1057:
1058: <ol><li>
1059:
1060: <p>Let <var title="">new ports</var> be an empty array.</p>
1061:
1062: <p>For each port in <var title="">ports</var> in turn,
1063: obtain a new port by <a href="#clone-a-port" title="clone a port">cloning</a>
1064: the port with the owner of the <var title="">target port</var>
1065: as the owner of the clone, and append the clone to the <var title="">new ports</var> array.</p>
1066:
1067: <p class="note">If the original <var title="">ports</var>
1068: array was empty, then the <var title="">new ports</var> array will
1069: also be empty.</p>
1070:
1071: </li>
1072:
1073: <li><p>Let the <code title="dom-MessageEvent-ports"><a href="#dom-messageevent-ports">ports</a></code>
1074: attribute of the event be the <var title="">new ports</var>
1075: array.</li>
1076:
1077: </ol></li>
1078:
1079: <li><p>Add the event to the <a href="#port-message-queue">port message queue</a> of <var title="">target port</var>.</li>
1080:
1081: </ol><!--
1082: <hr>
1083:
1084: <p>The <dfn
1085: title="dom-MessagePort-startConversation"><code>startConversation(<var
1086: title="">message</var>)</code></dfn> method is a convenience method
1087: that simplifies create a new <code>MessageChannel</code> and
1088: invoking <code
1089: title="dom-MessagePort-postMessage">postMessage()</code> with one of
1090: the new ports. When invoked on a port <var title="">source
1091: port</var>, it must run the following steps:</p>
1092:
1093: <ol>
1094:
1095: <li><p>Let <var title="">message</var> be the method's first
1096: argument.</p></li>
1097:
1098: <li><p><span>Create a new <code>MessagePort</code> object</span>
1099: owned by the <span>script's global object</span>, and let <var
1100: title="">port1</var> be that object.</p></li>
1101:
1102: <li><p>If the <var title="">source port</var> is not entangled with
1103: another port, then return <var title="">port1</var> and abort these
1104: steps.</p></li>
1105: <!- - we don't raise an exception because this can happen moment's
1106: notice. we don't return null because then we'd end up with
1107: null derefs. better to just let the likely next postMessage call
1108: fall on the floor. - ->
1109:
1110: <li><p>Let <var title="">target port</var> be the port with which
1111: <var title="">source port</var> is entangled.</p></li>
1112:
1113: <li><p><span>Create a new <code>MessagePort</code> object</span>
1114: owned by the owner of the <var title="">target port</var>, and let
1115: <var title="">port2</var> be that object.</p></li>
1116:
1117: <li><p><span>Entangle</span> the <var title="">port1</var> and <var
1118: title="">port2</var> objects.</p></li>
1119:
1120: <li><p>Create an event that uses the <code>MessageEvent</code>
1121: interface, with the name <code
1122: title="event-message">message</code>, which does not bubble, is not
1123: cancelable, and has no default action.</p></li>
1124:
1125: <li><p>Let the <code title="dom-MessageEvent-data">data</code>
1126: attribute of the event have the value of <var
1127: title="">message</var>, the method's first argument.</p></li>
1128:
1129: <li><p>Let the <code
1130: title="dom-MessageEvent-ports">ports</code> attribute
1131: of the event be an array containing only <var
1132: title="">port2</var>.</p></li>
1133:
1134: <li><p>Return <var title="">port1</var> from the method, but
1135: continue with these steps.</p></li>
1136:
1137: <li><p>Add the event to the <span>port message queue</span> of <var
1138: title="">target port</var>.</p></li>
1139:
1140: </ol>
1141: --><hr><p>The <dfn id="dom-messageport-start" title="dom-MessagePort-start"><code>start()</code></dfn>
1142: method must enable its port's <a href="#port-message-queue">port message queue</a>, if it
1143: is not already enabled.</p>
1144:
1145: <p>When a port's <a href="#port-message-queue">port message queue</a> is enabled, the
1146: <span>event loop</span> must use it as one of its <span title="task
1147: source">task sources</span>.</p>
1148:
1149: <p class="note">If the <code>Document</code> of the port's event
1150: listeners' <span title="script's global object">global object</span>
1151: is not <span>fully active</span>, then the messages are lost.</p>
1152: <!-- because of the jump-to-entry-point algorithm first step -->
1153:
1154: <hr><p>The <dfn id="dom-messageport-close" title="dom-MessagePort-close"><code>close()</code></dfn>
1155: method, when called on a port <var title="">local port</var> that is
1156: entangled with another port, must cause the user agents to
1157: disentangle the two ports. If the method is called on a port that is
1158: not entangled, then the method must do nothing.</p>
1159:
1160: <hr><p>The following are the <span>event handlers</span> (and their
1161: corresponding <span title="event handler event type">event handler
1162: event types</span>) that must be supported, as IDL attributes, by
1163: all objects implementing the <code><a href="#messageport">MessagePort</a></code> interface:</p>
1164:
1165: <table><thead><tr><th><span title="event handlers">Event handler</span> <th><span>Event handler event type</span>
1166: <tbody><tr><td><dfn id="handler-messageport-onmessage" title="handler-MessagePort-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message"><a href="#event-message">message</a></code>
1167: </table><p>The first time a <code><a href="#messageport">MessagePort</a></code> object's <code title="handler-MessagePort-onmessage"><a href="#handler-messageport-onmessage">onmessage</a></code> IDL attribute
1168: is set, the port's <a href="#port-message-queue">port message queue</a> must be enabled,
1169: as if the <code title="dom-MessagePort-start"><a href="#dom-messageport-start">start()</a></code> method
1170: had been called.</p>
1171:
1.10 ihickson 1172: </div><h4 id="ports-and-garbage-collection"><span class="secno">4.3.1 </span>Ports and garbage collection</h4><div class="impl">
1.1 ihickson 1173:
1174: <p>When a <code><a href="#messageport">MessagePort</a></code> object <var title="">o</var> is
1175: entangled, user agents must either act as if <var title="">o</var>'s
1176: entangled <code><a href="#messageport">MessagePort</a></code> object has a strong reference to
1177: <var title="">o</var>, or as if <var title="">o</var>'s owner has a
1178: strong reference to <var title="">o</var>.</p>
1179:
1180: <div class="note">
1181:
1182: <p>Thus, a message port can be received, given an event listener,
1183: and then forgotten, and so long as that event listener could
1184: receive a message, the channel will be maintained.</p>
1185:
1186: <p>Of course, if this was to occur on both sides of the channel,
1187: then both ports could be garbage collected, since they would not be
1188: reachable from live code, despite having a strong reference to each
1189: other.</p>
1190:
1191: </div>
1192:
1193: <p>Furthermore, a <code><a href="#messageport">MessagePort</a></code> object must not be
1194: garbage collected while there exists a message in a <span>task
1195: queue</span> that is to be dispatched on that
1196: <code><a href="#messageport">MessagePort</a></code> object, or while the
1197: <code><a href="#messageport">MessagePort</a></code> object's <a href="#port-message-queue">port message queue</a> is
1198: open and there exists a <code title="event-message"><a href="#event-message">message</a></code>
1199: event in that queue.</p>
1200: <!-- we might not need to explicitly say the first part if DOM
1201: Events is fixed to say that events on a task queue prevent GC -->
1202:
1203: <!-- ports in the ports attribute of a MessageEvent that isn't
1204: dispatched yet are safe because the MessageEvent is safe -->
1205:
1206: </div><p class="note">Authors are strongly encouraged to explicitly close
1207: <code><a href="#messageport">MessagePort</a></code> objects to disentangle them, so that their
1208: resources can be recollected. Creating many <code><a href="#messageport">MessagePort</a></code>
1209: objects and discarding them without closing them can lead to high
1.8 ihickson 1210: memory usage.<h2 class="no-num" id="references">References</h2><!--REFS--><p>All references are normative unless marked "Non-normative".</p><!-- Dates are only included for standards older than the Web,
1211: because the newer ones keep changing. --><dl><dt id="refsDOMEVENTS">[DOMEVENTS]</dt>
1.1 ihickson 1212: <!--
1213: <dd><cite><a
1214: href="http://www.w3.org/TR/DOM-Level-3-Events/">Document Object
1215: Model (DOM) Level 3 Events Specification</a></cite>,
1.8 ihickson 1216: B. Höhrmann, P. Le Hegaret, T. Pixley. W3C.</dd>
1.1 ihickson 1217: -->
1218: <dd><cite><a href="http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html">Document
1219: Object Model (DOM) Level 3 Events Specification</a></cite>,
1.8 ihickson 1220: D. Schepers. W3C.</dd>
1.1 ihickson 1221:
1222: <dt id="refsEVENTSOURCE">[EVENTSOURCE]</dt>
1223: <!--
1224: <dd><cite><a href="http://www.w3.org/TR/eventsource/">Server-Sent
1.8 ihickson 1225: Events</a></cite>, I. Hickson. W3C.</dd>
1.1 ihickson 1226: -->
1227: <dd><cite><a href="http://dev.w3.org/html5/eventsource/">Server-Sent
1.8 ihickson 1228: Events</a></cite>, I. Hickson. W3C.</dd>
1.1 ihickson 1229:
1.6 ihickson 1230: <dt id="refsHTML5">[HTML5]</dt>
1.8 ihickson 1231: <dd><cite><a href="http://dev.w3.org/html5/spec/">HTML5</a></cite>,
1232: I. Hickson, D. Hyatt. W3C.</dd>
1.1 ihickson 1233:
1234: <dt id="refsWEBSOCKET">[WEBSOCKET]</dt>
1235: <!--
1.21 ihickson 1236: <dd><cite><a href="http://www.w3.org/TR/websockets/">The WebSocket
1.8 ihickson 1237: API</a></cite>, I. Hickson. W3C.</dd>
1.1 ihickson 1238: -->
1.21 ihickson 1239: <dd><cite><a href="http://dev.w3.org/html5/websockets/">The WebSocket
1.8 ihickson 1240: API</a></cite>, I. Hickson. W3C.</dd>
1.1 ihickson 1241:
1.6 ihickson 1242: </dl><h2 class="no-num" id="acknowledgements">Acknowledgements</h2><p>For a full list of acknowledgements, please see the HTML5
1243: specification. <a href="#refsHTML5">[HTML5]</a>
Webmaster