Annotation of html5/workers/Overview.html, revision 1.4

1.1       ihickson    1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
                      2: <!-- when publishing, change bits marked ZZZ -->
                      3: 
                      4: <html lang=en-US-x-Hixie>
                      5:  <head>
                      6:   <title>Web Workers</title>
                      7:   <link href="http://www.w3.org/StyleSheets/TR/%57%33%43-ED" rel=stylesheet
                      8:   type="text/css">
                      9:   <!-- ZZZ ED vs WD -->
                     10: 
                     11:  <body>
                     12:   <div class=head>
                     13:    <p><a href="http://www.w3.org/"><img alt=W3C height=48
                     14:     src="http://www.w3.org/Icons/w3c_home" width=72></a></p>
                     15: 
                     16:    <h1 id=web-workers>Web Workers</h1>
                     17: 
                     18:    <h2 class="no-num no-toc" id=an-accompaniment>An accompaniment
                     19:     specification for HTML5</h2>
                     20: 
                     21:    <h2 class="no-num no-toc" id=editors><!-- "W3C Working Draft" --> Editor's
1.4     ! ihickson   22:     Draft <!--ZZZ-->16 July 2008</h2>
1.1       ihickson   23: 
                     24:    <dl><!-- ZZZ: update the month/day
                     25:     <dt>This Version:</dt>
                     26:     <dd><a href="http://www.w3.org/TR/2008/WD-workers-20080101/">http://www.w3.org/TR/2008/WD-workers-20080101/</a></dd>
1.2       ihickson   27:     <dt>Latest Published Version:</dt>
                     28:     <dd><a href="http://www.w3.org/TR/workers/">http://www.w3.org/TR/workers/</a></dd>
1.1       ihickson   29:  :ZZZ -->
                     30: 
                     31:     <dt>Latest Editor's Draft:
                     32: 
                     33:     <dd><a
                     34:      href="http://dev.w3.org/html5/workers/">http://dev.w3.org/html5/workers/</a></dd>
1.2       ihickson   35:     <!-- ZZZ: add the new version after it has shipped
                     36:     <dt>Previous Versions:</dt>
                     37:     <dd><a href="http://www.w3.org/TR/2008/WD-workers-20080101/">http://www.w3.org/TR/2008/WD-workers-20080101/</a>
                     38:  :ZZZ -->
1.1       ihickson   39: 
                     40:     <dt>Editors:
                     41: 
                     42:     <dd><a href="mailto:ian@hixie.ch">Ian Hickson</a>, Google, Inc.
                     43:    </dl>
                     44: 
                     45:    <p class=copyright><a
                     46:     href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>
                     47:     &#169; 2008 <a href="http://www.w3.org/"><abbr title="World Wide Web
                     48:     Consortium">W3C</abbr></a><sup>&#174;</sup> (<a
                     49:     href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of
                     50:     Technology">MIT</abbr></a>, <a href="http://www.ercim.org/"><abbr
                     51:     title="European Research Consortium for Informatics and
                     52:     Mathematics">ERCIM</abbr></a>, <a
                     53:     href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
                     54:     href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
                     55:     <a
                     56:     href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
                     57:     and <a
                     58:     href="http://www.w3.org/Consortium/Legal/copyright-documents">document
                     59:     use</a> rules apply.</p>
                     60:    <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                     61:    
                     62:    <p class="alt copyright">The <a
                     63:     href="http://www.whatwg.org/specs/web-workers/current-work/">WHATWG
                     64:     version</a> of this specification is available under a more permissive
                     65:     license.</p>
                     66:    <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                     67:    </div>
                     68: 
                     69:   <hr>
                     70: 
                     71:   <h2 class="no-num no-toc" id=abstract>Abstract</h2>
                     72: 
                     73:   <p>This specification defines an API that allows Web application authors to
                     74:    spawn background workers running scripts in parallel to their main page.
                     75:    This allows for thread-like operation with message-passing as the
                     76:    coordination mechanism.
                     77: 
                     78:   <h2 class="no-num no-toc" id=status>Status of this document</h2>
                     79:   <!-- intro boilerplate (required) -->
                     80: 
                     81:   <p><em>This section describes the status of this document at the time of
                     82:    its publication. Other documents may supersede this document. A list of
                     83:    current W3C publications and the most recently formally published revision
                     84:    of this technical report can be found in the <a
                     85:    href="http://www.w3.org/TR/">W3C technical reports index</a> at
                     86:    http://www.w3.org/TR/.</em></p>
                     87:   <!-- where to send feedback (required) -->
                     88: 
                     89:   <p>If you wish to make comments regarding this document, please send them
                     90:    to <a
                     91:    href="mailto:public-html-comments@w3.org">public-html-comments@w3.org</a>
                     92:    (<a
                     93:    href="mailto:public-html-comments-request@w3.org?subject=subscribe">subscribe</a>,
                     94:    <a
                     95:    href="http://lists.w3.org/Archives/Public/public-html-comments/">archives</a>)
                     96:    <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING SENTENCE TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                     97:    or <a href="mailto:whatwg@whatwg.org">whatwg@whatwg.org</a> (<a
                     98:    href="http://lists.whatwg.org/listinfo.cgi/whatwg-whatwg.org">subscribe</a>,
                     99:    <a
                    100:    href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/">archives</a>).
                    101:    <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING SENTENCE TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    102:    All feedback is welcome.</p>
                    103:   <!-- stability (required) -->
                    104: 
                    105:   <p>Implementors should be aware that this specification is not stable.
                    106:    <strong>Implementors who are not taking part in the discussions are likely
                    107:    to find the specification changing out from under them in incompatible
                    108:    ways.</strong> Vendors interested in implementing this specification
                    109:    before it eventually reaches the Candidate Recommendation stage should
                    110:    join the aforementioned mailing lists and take part in the discussions.</p>
                    111:   <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    112:   <!-- version history or list of changes (required) -->
                    113: 
                    114:   <p>The latest stable version of the editor's draft of this specification is
                    115:    always available on <a
                    116:    href="http://dev.w3.org/html5/workers/Overview.html">the W3C CVS
                    117:    server</a> and in the <a href="http://svn.whatwg.org/webworkers/">WHATWG
                    118:    Subversion repository</a>. The latest editor's working copy (which may
                    119:    contain unfinished text in the process of being prepared) is available <a
                    120:    href="http://www.whatwg.org/specs/web-workers/current-work/">on the WHATWG
                    121:    site</a>. Detailed change history can be obtained from the following
                    122:    locations:</p>
                    123:   <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    124:   <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    125: 
                    126:   <ul>
                    127:    <li>Twitter messages (non-editorial changes only): <a
                    128:     href="http://twitter.com/WHATWG">http://twitter.com/WHATWG</a>
                    129: 
                    130:    <li>Interactive Web interface: <a
                    131:     href="http://html5.org/tools/web-workers-tracker">http://html5.org/tools/web-workers-tracker</a>
                    132: 
                    133:    <li>Commit-Watchers mailing list: <a
                    134:     href="http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org">http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a>
                    135: 
                    136:    <li>Subversion interface: <a
                    137:     href="http://svn.whatwg.org/webworkers/">http://svn.whatwg.org/webworkers/</a>
                    138: 
                    139:    <li>CVS log: <a
                    140:     href="http://dev.w3.org/cvsweb/html5/workers/Overview.html">http://dev.w3.org/cvsweb/html5/workers/Overview.html</a>
                    141:   </ul>
                    142:   <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    143:   <!-- status of document, group responsible (required) -->
                    144: 
                    145:   <p>The W3C <a href="http://www.w3.org/html/wg/">HTML Working Group</a> is
                    146:    the W3C working group responsible for this specification's progress along
1.4     ! ihickson  147:    the W3C Recommendation track. <!--ZZZ:--> This specification is the 16
1.3       ihickson  148:    July 2008 <!--ZZZ "Working Draft"-->Editor's Draft. <!--:ZZZ--></p>
1.1       ihickson  149:   <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    150:   <!-- relationship to other work (required) -->
                    151: 
                    152:   <p>This specification is also being produced by the <a
                    153:    href="http://www.whatwg.org/">WHATWG</a>. The two specifications are
                    154:    identical from the table of contents onwards.</p>
                    155:   <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    156:   <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    157:   <!-- context and rationale (required) -->
                    158: 
                    159:   <p>This specification is intended to specify a part of the Web platform
                    160:    closely related to HTML5. It is defined in a separate document primarily
                    161:    to ease the cognitive load on reviewers.</p>
                    162:   <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST -->
                    163:   <!-- required patent boilerplate -->
                    164: 
                    165:   <p>This document was produced by a group operating under the <a
                    166:    href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
                    167:    2004 W3C Patent Policy</a>. W3C maintains a <a
                    168:    href="http://www.w3.org/2004/01/pp-impl/40318/status"
                    169:    rel=disclosure>public list of any patent disclosures</a> made in
                    170:    connection with the deliverables of the group; that page also includes
                    171:    instructions for disclosing a patent. An individual who has actual
                    172:    knowledge of a patent which the individual believes contains <a
                    173:    href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
                    174:    Claim(s)</a> must disclose the information in accordance with <a
                    175:    href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
                    176:    6 of the W3C Patent Policy</a>.
                    177: 
                    178:   <h2 class="no-num no-toc" id=contents>Table of contents</h2>
                    179:   <!--begin-toc-->
                    180: 
                    181:   <ul class=toc>
                    182:    <li><a href="#introduction"><span class=secno>1. </span>Introduction</a>
                    183:     <ul class=toc>
1.4     ! ihickson  184:      <li><a href="#tutorial"><span class=secno>1.1 </span>Tutorial</a>
1.1       ihickson  185: 
1.3       ihickson  186:      <li><a href="#requirements"><span class=secno>1.2
                    187:       </span>Requirements</a>
1.1       ihickson  188: 
1.4     ! ihickson  189:      <li><a href="#conformance"><span class=secno>1.3 </span>Conformance
1.1       ihickson  190:       requirements</a>
                    191:       <ul class=toc>
1.4     ! ihickson  192:        <li><a href="#dependencies"><span class=secno>1.3.1
1.1       ihickson  193:         </span>Dependencies</a>
                    194:       </ul>
                    195: 
1.4     ! ihickson  196:      <li><a href="#terminology"><span class=secno>1.4 </span>Terminology</a>
        !           197:     </ul>
        !           198: 
        !           199:    <li><a href="#inside"><span class=secno>2. </span>Inside workers</a>
        !           200:     <ul class=toc>
        !           201:      <li><a href="#the-windowworker"><span class=secno>2.1 </span>The
        !           202:       <code>WindowWorker</code> interface</a>
        !           203: 
        !           204:      <li><a href="#the-queue"><span class=secno>2.2 </span>The queue of
        !           205:       events</a>
        !           206: 
        !           207:      <li><a href="#processing"><span class=secno>2.3 </span>Processing
        !           208:       model</a>
1.1       ihickson  209:     </ul>
                    210: 
1.4     ! ihickson  211:    <li><a href="#creating"><span class=secno>3. </span>Creating workers</a>
        !           212: 
1.1       ihickson  213:    <li class=no-num><a href="#references">References</a>
                    214: 
                    215:    <li class=no-num><a href="#acknowledgements">Acknowledgements</a>
                    216:   </ul>
                    217:   <!--end-toc-->
                    218: 
                    219:   <hr>
                    220: 
                    221:   <h2 id=introduction><span class=secno>1. </span>Introduction</h2>
                    222: 
1.4     ! ihickson  223:   <h3 id=tutorial><span class=secno>1.1 </span>Tutorial</h3>
1.1       ihickson  224: 
                    225:   <p><em>This section is non-normative.</em>
                    226: 
1.4     ! ihickson  227:   <p class=big-issue>This section is missing.
        !           228: 
1.3       ihickson  229:   <h3 id=requirements><span class=secno>1.2 </span>Requirements</h3>
1.1       ihickson  230: 
                    231:   <p><em>This section is non-normative.</em>
                    232: 
1.3       ihickson  233:   <p>This specification aims to address the following use cases and
                    234:    requirements:
                    235: 
                    236:   <ul>
                    237:    <li>Background workers: A Web application needs to keep its data
                    238:     synchronised with the server, both sending updates to the server and
                    239:     receiving updates from the server, including handling buffering of
                    240:     updates for when the application goes offline. The code to do this would
                    241:     ideally be independent of the UI code.
                    242: 
                    243:    <li>URLs: Workers should be spawned from URLs, not from strings, since
                    244:     script rarely has access to its own source.
                    245: 
                    246:    <li>Message queuing: Messages sent to a worker before the worker has
                    247:     initialised should not be lost.
                    248: 
                    249:    <li>Workers should have access to timers.
                    250: 
                    251:    <li>Workers should have access to the network.
                    252: 
                    253:    <li>Workers should be able to use libraries.
                    254: 
                    255:    <li>Implementations should not have to expose <code>Node</code> or
                    256:     <code>Document</code> objects to workers.
                    257: 
                    258:    <li>Workers should not share anything with the outside world. The objects
                    259:     representing the worker in the worker itself and in the context that
                    260:     created the worker should be different, for instance.
                    261: 
                    262:    <li>Shared workers: Multiple instances of the same Web application would
                    263:     want to keep just one connection back to the server.
                    264: 
                    265:    <li>Capabilities granting: It should be possible for code running in one
                    266:     iframe to negotiate a connection to another iframe, with that connection
                    267:     granting certain rights (e.g. adding to an address book but not reading
                    268:     from it).
                    269: 
                    270:    <li>Delegation: It should be possible for one worker to spawn another
                    271:     worker and efficiently delagate a request to that worker, without the
                    272:     caller being aware of the delagate and without the original worker having
                    273:     to proxy all the messages.
                    274: 
                    275:    <li>Workers whose parents are not longer useful should be killed. Workers
                    276:     should be able to detect this is about to happen and exit gracefully.
                    277:   </ul>
                    278: 
1.4     ! ihickson  279:   <h3 id=conformance><span class=secno>1.3 </span>Conformance requirements</h3>
1.1       ihickson  280: 
                    281:   <p>All diagrams, examples, and notes in this specification are
                    282:    non-normative, as are all sections explicitly marked non-normative.
                    283:    Everything else in this specification is normative.
                    284: 
                    285:   <p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
                    286:   NOT",-->
                    287:    "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the
                    288:    normative parts of this document are to be interpreted as described in
                    289:    RFC2119. For readability, these words do not appear in all uppercase
                    290:    letters in this specification. <a href="#refsRFC2119">[RFC2119]</a></p>
                    291:   <!-- XXX but they should be
                    292:   marked up -->
                    293: 
                    294:   <p>Requirements phrased in the imperative as part of algorithms (such as
                    295:    "strip any leading space characters" or "return false and abort these
                    296:    steps") are to be interpreted with the meaning of the key word ("must",
                    297:    "should", "may", etc) used in introducing the algorithm.
                    298: 
                    299:   <p>Some conformance requirements are phrased as requirements on attributes,
                    300:    methods or objects. Such requirements are to be interpreted as
                    301:    requirements on user agents.
                    302: 
                    303:   <p>Conformance requirements phrased as algorithms or specific steps may be
                    304:    implemented in any manner, so long as the end result is equivalent. (In
                    305:    particular, the algorithms defined in this specification are intended to
                    306:    be easy to follow, and not intended to be performant.)
                    307: 
                    308:   <p>The only conformance class defined by this specification is user agents.
                    309: 
                    310:   <p>User agents may impose implementation-specific limits on otherwise
                    311:    unconstrained inputs, e.g. to prevent denial of service attacks, to guard
                    312:    against running out of memory, or to work around platform-specific
                    313:    limitations.
                    314: 
1.4     ! ihickson  315:   <h4 id=dependencies><span class=secno>1.3.1 </span>Dependencies</h4>
1.1       ihickson  316: 
                    317:   <p>This specification relies on several other underlying specifications.
                    318: 
                    319:   <dl>
                    320:    <dt>HTML5
                    321: 
                    322:    <dd>
                    323:     <p>Many fundamental concepts from HTML5 are used by this specification.
                    324:      <a href="#refsHTML5">[HTML5]</a></p>
                    325: 
                    326:    <dt>ECMAScript
                    327: 
                    328:    <dd>
                    329:     <p>This specification is intended to be used with JavaScript as the
                    330:      scripting language. <a href="#refsJS">[JS]</a></p>
                    331: 
                    332:    <dt>WebIDL
                    333: 
                    334:    <dd>
                    335:     <p>The IDL blocks in this specification use the semantics of the WebIDL
                    336:      specification. <a href="#refsWebIDL">[WebIDL]</a></p>
                    337:   </dl>
                    338: 
1.4     ! ihickson  339:   <h3 id=terminology><span class=secno>1.4 </span>Terminology</h3>
1.1       ihickson  340: 
                    341:   <p>For simplicity, terms such as <em>shown</em>, <em>displayed</em>, and
                    342:    <em>visible</em> might sometimes be used when referring to the way a
                    343:    document is rendered to the user. These terms are not meant to imply a
                    344:    visual medium; they must be considered to apply to other media in
                    345:    equivalent ways.
                    346: 
1.4     ! ihickson  347:   <p>The construction "a <code title="">Foo</code> object", where <code
        !           348:    title="">Foo</code> is actually an interface, is sometimes used instead of
        !           349:    the more accurate "an object implementing the interface <code
        !           350:    title="">Foo</code>".
1.1       ihickson  351: 
                    352:   <p>The term DOM is used to refer to the API set made available to scripts
                    353:    in Web applications, and does not necessarily imply the existence of an
                    354:    actual <code>Document</code> object or of any other <code>Node</code>
                    355:    objects as defined in the DOM Core specifications. <a
                    356:    href="#refsDOM3CORE">[DOM3CORE]</a>
                    357: 
                    358:   <p>A DOM attribute is said to be <em>getting</em> when its value is being
                    359:    retrieved (e.g. by author script), and is said to be <em>setting</em> when
                    360:    a new value is assigned to it.
                    361: 
                    362:   <p>If a DOM object is said to be <dfn id=live>live</dfn>, then that means
                    363:    that any attributes returning that object must always return the same
                    364:    object (not a new object each time), and the attributes and methods on
                    365:    that object must operate on the actual underlying data, not a snapshot of
                    366:    the data.
                    367: 
1.4     ! ihickson  368:   <h2 id=inside><span class=secno>2. </span>Inside workers</h2>
        !           369: 
        !           370:   <h3 id=the-windowworker><span class=secno>2.1 </span>The <code><a
        !           371:    href="#windowworker">WindowWorker</a></code> interface</h3>
        !           372: 
        !           373:   <pre
        !           374:    class=idl>[NoInterfaceObject] interface <dfn id=windowworker>WindowWorker</dfn> {
        !           375:   readonly attribute boolean <a href="#closing" title=dom-windowworker-closing>closing</a>;
        !           376: };</pre>
        !           377: 
        !           378:   <p>Objects that implement the <code><a
        !           379:    href="#windowworker">WindowWorker</a></code> interface must also implement
        !           380:    the <code>Window</code> interface (and thus also the
        !           381:    <code>WindowTimers</code> interface) and the <code>EventTarget</code>
        !           382:    interface.
        !           383: 
        !           384:   <p>The <dfn id=closing
        !           385:    title=dom-windowworker-closing><code>closing</code></dfn> attribute must
        !           386:    return false until the "<a href="#kill-a">kill a worker</a>" processing
        !           387:    model defined below sets it to false.
        !           388: 
        !           389:   <h3 id=the-queue><span class=secno>2.2 </span>The queue of events</h3>
        !           390: 
        !           391:   <p>Each <code><a href="#windowworker">WindowWorker</a></code> object is
        !           392:    asssociated with a <dfn id=queue>queue of events</dfn>, which is initially
        !           393:    empty.
        !           394: 
        !           395:   <p>An event in the queue can be a DOM event or a timeout callback.
        !           396: 
        !           397:   <h3 id=processing><span class=secno>2.3 </span>Processing model</h3>
        !           398: 
        !           399:   <p>When a user agent is to <dfn id=run-a>run a worker</dfn> for a script
        !           400:    <var title="">script</var> and a browsing context <var title="">owner
        !           401:    browsing context</var> and a <code>Document</code> <var title="">owner
        !           402:    document</var>, it must run the following steps in a completely separate
        !           403:    and parallel execution environment:
        !           404: 
        !           405:   <ol>
        !           406:    <li>
        !           407:     <p>Create a new <code><a href="#windowworker">WindowWorker</a></code>
        !           408:      object, <var title="">window</var>.</p>
        !           409: 
        !           410:    <li>
        !           411:     <p>Let <var title="">script</var>'s <span>script execution context</span>
        !           412:      (and thus also <span>global object</span>) be <var
        !           413:      title="">window</var>.</p>
        !           414: 
        !           415:    <li>
        !           416:     <p>Let <var title="">script</var>'s <span>script browsing context</span>
        !           417:      be <var title="">owner browsing context</var>.</p>
        !           418: 
        !           419:    <li>
        !           420:     <p>Let <var title="">script</var>'s <span>script document context</span>
        !           421:      be <var title="">owner document</var>.</p>
        !           422: 
        !           423:    <li>
        !           424:     <p>Run <var title="">script</var> until it returns.</p>
        !           425: 
        !           426:    <li>
        !           427:     <p><i>Event loop</i>: Wait until there is an event in the <a
        !           428:      href="#queue">queue of events</a> associated with <var
        !           429:      title="">window</var>.</p>
        !           430: 
        !           431:    <li>
        !           432:     <p>Dispatch the oldest event or callback in the <a href="#queue">queue of
        !           433:      events</a>. Events must be targetted at the <code><a
        !           434:      href="#windowworker">WindowWorker</a></code> object.</p>
        !           435: 
        !           436:    <li>
        !           437:     <p>If there are any more events in the <a href="#queue">queue of
        !           438:      events</a> or if the <var title="">window</var> object's <code
        !           439:      title=dom-windowworker-closing><a href="#closing">closing</a></code>
        !           440:      attribute is set to false, then jump back to the step above labeled
        !           441:      <i>event loop</i>.</p>
        !           442: 
        !           443:    <li>
        !           444:     <p class=big-issue>timers, intervals, XMLHttpRequests, database
        !           445:      transactions, etc, must be killed; ports must be deactivated and
        !           446:      unentangled</p>
        !           447:   </ol>
        !           448: 
        !           449:   <hr>
        !           450: 
        !           451:   <p>When a user agent is to <dfn id=kill-a>kill a worker</dfn>, it must run
        !           452:    the following steps in parallel with the worker's main loop (the "<a
        !           453:    href="#run-a">run a worker</a>" processing model defined above):
        !           454: 
        !           455:   <ol>
        !           456:    <li>
        !           457:     <p>Set the worker's <code><a href="#windowworker">WindowWorker</a></code>
        !           458:      object's <code title=dom-windowworker-closing><a
        !           459:      href="#closing">closing</a></code> attribute to true.
        !           460: 
        !           461:    <li>
        !           462:     <p>Create an <code>Event</code> object with the event name <code
        !           463:      title=event-unload>unload</code>, which does not bubble and is not
        !           464:      cancelable, and add it to the worker's <code><a
        !           465:      href="#windowworker">WindowWorker</a></code> object's <a
        !           466:      href="#queue">queue of events</a>.
        !           467: 
        !           468:    <li>
        !           469:     <p>Wait a user-agent-defined amount of time.
        !           470: 
        !           471:    <li>
        !           472:     <p>If there are any events in the <a href="#queue">queue of events</a>
        !           473:      other than the <code title=event-unload>unload</code> event that this
        !           474:      algorithm just added, discard them without dispatching them.
        !           475: 
        !           476:    <li>
        !           477:     <p>If the <code title=event-unload>unload</code> event that this
        !           478:      algorithm just added hasn't yet been dispatched, then abort the script
        !           479:      currently running in the worker.
        !           480: 
        !           481:    <li>
        !           482:     <p>Wait a user-agent-defined amount of time.
        !           483: 
        !           484:    <li>
        !           485:     <p>Abort the script currently running in the worker (if any script is
        !           486:      running, then it will be a handler for the <code
        !           487:      title=event-unload>unload</code> event).
        !           488:   </ol>
        !           489: 
        !           490:   <h2 id=creating><span class=secno>3. </span>Creating workers</h2>
        !           491: 
        !           492:   <p class=big-issue>...
        !           493: 
1.1       ihickson  494:   <h2 class=no-num id=references>References</h2>
                    495: 
                    496:   <p class=big-issue>This section will be written in a future
                    497:    draft.<!--XXX-->
                    498: 
                    499:   <h2 class=no-num id=acknowledgements>Acknowledgements</h2>
                    500:   <!-- ACKS -->
                    501: 
                    502:   <p>Thanks to Maciej Stachowiak and Mike Smith for their useful and
                    503:    substantial comments.
1.4     ! ihickson  504: 
        !           505:   <p>Huge thanks to the whole Gears team, who pioneered this technology and
        !           506:    whose experience has been a huge influence on this specification.

Webmaster