Skip to content

Commit

Permalink
[e] (0) Add more shared worker examples.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@4865 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 25, 2010
1 parent 244f70a commit 2dcb3d5
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 8 deletions.
69 changes: 62 additions & 7 deletions complete.html
Expand Up @@ -169,7 +169,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<hgroup><h1>Web Applications 1.0</h1>
<h2 class="no-num no-toc">Draft Standard &mdash; 24 March 2010</h2>
<h2 class="no-num no-toc">Draft Standard &mdash; 25 March 2010</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
Expand Down Expand Up @@ -908,9 +908,10 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
<li><a href=#a-background-number-crunching-worker><span class=secno>9.1.2.1 </span>A background number-crunching worker</a></li>
<li><a href=#a-worker-for-updating-a-client-side-database><span class=secno>9.1.2.2 </span>A worker for updating a client-side database</a></li>
<li><a href=#worker-used-for-background-i/o><span class=secno>9.1.2.3 </span>Worker used for background I/O</a></li>
<li><a href=#shared-workers><span class=secno>9.1.2.4 </span>Shared workers</a></li>
<li><a href=#delegation><span class=secno>9.1.2.5 </span>Delegation</a></li>
<li><a href=#providing-libraries><span class=secno>9.1.2.6 </span>Providing libraries</a></ol></ol></li>
<li><a href=#shared-workers-introduction><span class=secno>9.1.2.4 </span>Shared workers introduction</a></li>
<li><a href=#shared-state-using-a-shared-worker><span class=secno>9.1.2.5 </span>Shared state using a shared worker</a></li>
<li><a href=#delegation><span class=secno>9.1.2.6 </span>Delegation</a></li>
<li><a href=#providing-libraries><span class=secno>9.1.2.7 </span>Providing libraries</a></ol></ol></li>
<li><a href=#infrastructure-0><span class=secno>9.2 </span>Infrastructure</a>
<ol>
<li><a href=#the-global-scope><span class=secno>9.2.1 </span>The global scope</a>
Expand Down Expand Up @@ -64610,7 +64611,61 @@ <h5 id=worker-used-for-background-i/o><span class=secno>9.1.2.3 </span>Worker us
<p><a href=http://www.whatwg.org/demos/workers/stocks/page.html>View this example online</a>.</p>


<h5 id=shared-workers><span class=secno>9.1.2.4 </span>Shared workers</h5>
<h5 id=shared-workers-introduction><span class=secno>9.1.2.4 </span>Shared workers introduction</h5>

<p><i>This section is non-normative.</i></p>

<p>This section introduces shared workers using a Hello World
example. Shared workers use slightly different APIs, since each
worker can have multiple connections.</p>

<p>This first example shows how you connect to a worker and how a
worker can send a message back to the page when it connects to
it. Received messages are displayed in a log.</p>

<p>Here is the HTML page:</p>

<pre>EXAMPLE workers/shared/001/test.html</pre>

<p>Here is the JavaScript worker:</p>

<pre>EXAMPLE workers/shared/001/test.js</pre>

<hr><p>This second example extends the first one by changing two things:
first, messages are received using <code title="">addEventListener()</code> instead of an <a href=#event-handler-idl-attributes title="event
handler IDL attributes">event handler IDL attribute</a>, and
second, a message is sent <em>to</em> the worker, causing the worker
to send another message in return. Received messages are again
displayed in a lot.</p>

<p>Here is the HTML page:</p>

<pre>EXAMPLE workers/shared/001/test.html</pre>

<p>Here is the JavaScript worker:</p>

<pre>EXAMPLE workers/shared/001/test.js</pre>

<hr><p>Finally, the example is extended to show how two pages can
connect to the same worker; in this case, the second page is merely
in an <code><a href=#the-iframe-element>iframe</a></code> on the first page, but the same principle
would apply to an entirely separate page in a separate
<a href=#top-level-browsing-context>top-level browsing context</a>.</p>

<p>Here is the outer HTML page:</p>

<pre>EXAMPLE workers/shared/003/test.html</pre>

<p>Here is the inner HTML page:</p>

<pre>EXAMPLE workers/shared/003/inner.html</pre>

<p>Here is the JavaScript worker:</p>

<pre>EXAMPLE workers/shared/003/test.js</pre>


<h5 id=shared-state-using-a-shared-worker><span class=secno>9.1.2.5 </span>Shared state using a shared worker</h5>

<p><i>This section is non-normative.</i></p>

Expand Down Expand Up @@ -64894,7 +64949,7 @@ <h5 id=shared-workers><span class=secno>9.1.2.4 </span>Shared workers</h5>
<p><a href=http://www.whatwg.org/demos/workers/multiviewer/page.html>View this example online</a>.</p>


<h5 id=delegation><span class=secno>9.1.2.5 </span>Delegation</h5>
<h5 id=delegation><span class=secno>9.1.2.6 </span>Delegation</h5>

<p><i>This section is non-normative.</i></p>

Expand Down Expand Up @@ -64982,7 +65037,7 @@ <h5 id=delegation><span class=secno>9.1.2.5 </span>Delegation</h5>
<p><a href=http://www.whatwg.org/demos/workers/multicore/page.html>View this example online</a>.</p>


<h5 id=providing-libraries><span class=secno>9.1.2.6 </span>Providing libraries</h5>
<h5 id=providing-libraries><span class=secno>9.1.2.7 </span>Providing libraries</h5>

<p><i>This section is non-normative.</i></p>

Expand Down
61 changes: 60 additions & 1 deletion source
Expand Up @@ -73038,7 +73038,66 @@ v2 (well, really v0):
<p><a href="http://www.whatwg.org/demos/workers/stocks/page.html">View this example online</a>.</p>


<h5>Shared workers</h5>
<h5>Shared workers introduction</h5>

<p><i>This section is non-normative.</i></p>

<p>This section introduces shared workers using a Hello World
example. Shared workers use slightly different APIs, since each
worker can have multiple connections.</p>

<p>This first example shows how you connect to a worker and how a
worker can send a message back to the page when it connects to
it. Received messages are displayed in a log.</p>

<p>Here is the HTML page:</p>

<pre>EXAMPLE workers/shared/001/test.html</pre>

<p>Here is the JavaScript worker:</p>

<pre>EXAMPLE workers/shared/001/test.js</pre>

<hr>

<p>This second example extends the first one by changing two things:
first, messages are received using <code
title="">addEventListener()</code> instead of an <span title="event
handler IDL attributes">event handler IDL attribute</span>, and
second, a message is sent <em>to</em> the worker, causing the worker
to send another message in return. Received messages are again
displayed in a lot.</p>

<p>Here is the HTML page:</p>

<pre>EXAMPLE workers/shared/001/test.html</pre>

<p>Here is the JavaScript worker:</p>

<pre>EXAMPLE workers/shared/001/test.js</pre>

<hr>

<p>Finally, the example is extended to show how two pages can
connect to the same worker; in this case, the second page is merely
in an <code>iframe</code> on the first page, but the same principle
would apply to an entirely separate page in a separate
<span>top-level browsing context</span>.</p>

<p>Here is the outer HTML page:</p>

<pre>EXAMPLE workers/shared/003/test.html</pre>

<p>Here is the inner HTML page:</p>

<pre>EXAMPLE workers/shared/003/inner.html</pre>

<p>Here is the JavaScript worker:</p>

<pre>EXAMPLE workers/shared/003/test.js</pre>


<h5>Shared state using a shared worker</h5>

<p><i>This section is non-normative.</i></p>

Expand Down

0 comments on commit 2dcb3d5

Please sign in to comment.