[html5] r4865 - [e] (0) Add more shared worker examples.

whatwg at whatwg.org whatwg at whatwg.org
Wed Mar 24 17:52:56 PDT 2010


Author: ianh
Date: 2010-03-24 17:52:55 -0700 (Wed, 24 Mar 2010)
New Revision: 4865

Modified:
   complete.html
   source
Log:
[e] (0) Add more shared worker examples.

Modified: complete.html
===================================================================
--- complete.html	2010-03-24 22:26:30 UTC (rev 4864)
+++ complete.html	2010-03-25 00:52:55 UTC (rev 4865)
@@ -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 — 24 March 2010</h2>
+    <h2 class="no-num no-toc">Draft Standard — 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>-->
@@ -908,9 +908,10 @@
        <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>
@@ -64610,10 +64611,64 @@
   <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>
+
   <p>In this example, multiple windows (viewers) can be opened that
   are all viewing the same map. All the windows share the same map
   information, with a single worker coordinating all the viewers. Each
@@ -64894,7 +64949,7 @@
   <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>
 
@@ -64982,7 +65037,7 @@
   <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>
 

Modified: source
===================================================================
--- source	2010-03-24 22:26:30 UTC (rev 4864)
+++ source	2010-03-25 00:52:55 UTC (rev 4865)
@@ -73038,10 +73038,69 @@
   <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>
+
   <p>In this example, multiple windows (viewers) can be opened that
   are all viewing the same map. All the windows share the same map
   information, with a single worker coordinating all the viewers. Each




More information about the Commit-Watchers mailing list