[html5] r2085 - [] (0) Further work on the event loop front. (WebSockets, postMessage, MessagePo [...]

whatwg at whatwg.org whatwg at whatwg.org
Tue Aug 19 02:30:42 PDT 2008


Author: ianh
Date: 2008-08-19 02:30:40 -0700 (Tue, 19 Aug 2008)
New Revision: 2085

Modified:
   index
   source
Log:
[] (0) Further work on the event loop front. (WebSockets, postMessage, MessagePorts, setTimeout)

Modified: index
===================================================================
--- index	2008-08-19 09:00:41 UTC (rev 2084)
+++ index	2008-08-19 09:30:40 UTC (rev 2085)
@@ -30850,10 +30850,10 @@
   <h4 id=processing1><span class=secno>4.12.6 </span>Processing model</h4>
   <!-- ua side -->
 
-  <p>The <span>event source</span> for all <a href="#tasks"
+  <p>The <a href="#task-source">task source</a> for all <a href="#tasks"
    title=concept-task>tasks</a> <a href="#queue" title="queue a
    task">queued</a> by algorithms in this section and its subsections is the
-   <dfn id=template1>template event source</dfn>.
+   <dfn id=template1>template task source</dfn>.
 
   <h5 id=the-originalcontent><span class=secno>4.12.6.1. </span>The <code
    title=dom-originalContent><a
@@ -42875,6 +42875,17 @@
    title=dom-MessageEvent-messagePort><a
    href="#messageport">messagePort</a></code> attribute must be null.
 
+  <hr>
+
+  <p><a href="#tasks" title=concept-task>Tasks</a> in <a
+   href="#server-sent">server-sent events</a> and <a href="#web-sockets">Web
+   Sockets</a> use their own <a href="#task-source" title="task source">task
+   sources</a>, but the <a href="#task-source">task source</a> for the <a
+   href="#tasks" title=concept-task>tasks</a> in <a
+   href="#cross-document">cross-document messaging</a> and <a
+   href="#channel0">channel messaging</a> is the <dfn id=posted>posted
+   message task source</dfn>.
+
   <h3 id=server-sent-events><span class=secno>7.2 </span><dfn
    id=server-sent>Server-sent events</dfn></h3>
   <!-- eventsource -->
@@ -42942,8 +42953,9 @@
      href="#absolute">absolute URL</a>.</p>
 
     <p>As data is received, the <a href="#tasks" title=concept-task>tasks</a>
-     queued by the <span>networking event source</span> to handle the data
-     must consist of following the rules given in the following sections.</p>
+     queued by the <a href="#networking">networking task source</a> to handle
+     the data must consist of following the rules given in the following
+     sections.</p>
   </ol>
 
   <p>When an event source is removed from the list of event sources for an
@@ -43446,8 +43458,8 @@
    <dt><dfn id=open3 title=dom-WebSocket-OPEN><code>OPEN</code></dfn>
     (numeric value 1)
 
-   <dd>The <a href="#web-socket">Web Socket connection is established</a> and
-    communication is possible.
+   <dd>The <a href="#web-socket0">Web Socket connection is established</a>
+    and communication is possible.
 
    <dt><dfn id=closed title=dom-WebSocket-CLOSED><code>CLOSED</code></dfn>
     (numeric value 2)
@@ -43484,7 +43496,7 @@
   <h4 id=websocket><span class=secno>7.3.3 </span>WebSocket Events</h4>
 
   <p>The <dfn id=open4 title=event-WebSocket-open><code>open</code></dfn>
-   event is fired when the <a href="#web-socket">Web Socket connection is
+   event is fired when the <a href="#web-socket0">Web Socket connection is
    established</a>.
 
   <p>The <dfn id=close1 title=event-WebSocket-close><code>close</code></dfn>
@@ -43499,16 +43511,6 @@
   <p>The <code title=event-message><a href="#message2">message</a></code>
    event is fired when when data is received for a connection.
 
-  <p>Events that would be fired during script execution (e.g. between the
-   <code><a href="#websocket0">WebSocket</a></code> object being created
-   — and thus the connection being established — and the current
-   script completing; or, during the execution of a <code
-   title=event-message><a href="#message2">message</a></code> event handler)
-   must be buffered, and those events queued up and each one individually
-   fired after the script has completed.</p>
-  <!-- XXX make this more generic
-  -->
-
   <hr>
 
   <p>The following are the <a href="#event6">event handler DOM attributes</a>
@@ -43544,6 +43546,11 @@
 
   <h4 id=the-web><span class=secno>7.3.4 </span>The Web Socket protocol</h4>
 
+  <p>The <a href="#task-source">task source</a> for all <a href="#tasks"
+   title=concept-task>tasks</a> <a href="#queue" title="queue a
+   task">queued</a> by algorithms in this section and its subsections is the
+   <dfn id=web-socket>Web Socket task source</dfn>.
+
   <h5 id=client-side><span class=secno>7.3.4.1. </span>Client-side
    requirements</h5>
 
@@ -43904,13 +43911,14 @@
      title=dom-WebSocket-OPEN><a href="#open3">OPEN</a></code> (1).</p>
 
    <li>
-    <p><a href="#firing2">Fire a simple event</a> named <code
-     title=event-WebSocket-open><a href="#open4">open</a></code> at the
-     <code><a href="#websocket0">WebSocket</a></code> object.</p>
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> named <code title=event-WebSocket-open><a
+     href="#open4">open</a></code> at the <code><a
+     href="#websocket0">WebSocket</a></code> object.</p>
 
    <li>
-    <p>The <dfn id=web-socket>Web Socket connection is established</dfn>. Now
-     the user agent must send and receive to and from the connection as
+    <p>The <dfn id=web-socket0>Web Socket connection is established</dfn>.
+     Now the user agent must send and receive to and from the connection as
      described in the next section.</p>
   </ol>
 
@@ -43922,7 +43930,7 @@
 
   <h6 id=data-framing><span class=secno>7.3.4.1.2. </span>Data framing</h6>
 
-  <p>Once a <a href="#web-socket">Web Socket connection is established</a>,
+  <p>Once a <a href="#web-socket0">Web Socket connection is established</a>,
    the user agent must run through the following state machine for the bytes
    sent by the server.
 
@@ -43931,7 +43939,7 @@
     <p>Try to read a byte from the server. Let <var title="">frame type</var>
      be that byte.</p>
 
-    <p>If no byte could be read because the <a href="#web-socket0">Web Socket
+    <p>If no byte could be read because the <a href="#web-socket1">Web Socket
      connection is closed</a>, then abort.</p>
 
    <li>
@@ -43944,7 +43952,7 @@
 
      <dd>
       <p>Run these steps. If at any point during these steps a read is
-       attempted but fails because the <a href="#web-socket0">Web Socket
+       attempted but fails because the <a href="#web-socket1">Web Socket
        connection is closed</a>, then abort.</p>
 
       <ol>
@@ -43984,7 +43992,7 @@
 
      <dd>
       <p>Run these steps. If at any point during these steps a read is
-       attempted but fails because the <a href="#web-socket0">Web Socket
+       attempted but fails because the <a href="#web-socket1">Web Socket
        connection is closed</a>, then abort.</p>
 
       <ol>
@@ -44011,9 +44019,10 @@
          href="#message2">message</a></code>, which does not bubble, is
          cancelable, has no default action, and whose <code
          title=dom-MessageEvent-data><a href="#data4">data</a></code>
-         attribute is set to <var title="">data</var>, and dispatch it at the
-         <code><a href="#websocket0">WebSocket</a></code> object. Otherwise,
-         discard the data.
+         attribute is set to <var title="">data</var>, and <a
+         href="#queue">queue a task</a> to dispatch it at the <code><a
+         href="#websocket0">WebSocket</a></code> object. Otherwise, discard
+         the data.
       </ol>
     </dl>
 
@@ -44027,7 +44036,7 @@
 
   <hr>
 
-  <p>Once a <a href="#web-socket">Web Socket connection is established</a>,
+  <p>Once a <a href="#web-socket0">Web Socket connection is established</a>,
    the user agent must use the following steps to <dfn id=send->send <var
    title="">data</var> using the Web Socket</dfn>:
 
@@ -44212,7 +44221,7 @@
   <p>To <dfn id=close2>close the Web Socket connection</dfn>, either the user
    agent or the server closes the TCP/IP connection. There is no closing
    handshake. Whether the user agent or the server closes the connection, it
-   is said that the <dfn id=web-socket0>Web Socket connection is
+   is said that the <dfn id=web-socket1>Web Socket connection is
    closed</dfn>.
 
   <p>Servers may <a href="#close2">close the Web Socket connection</a>
@@ -44221,14 +44230,15 @@
   <p>User agents should not <a href="#close2">close the Web Socket
    connection</a> arbitrarily.
 
-  <p id=closeWebSocket>When the <a href="#web-socket0">Web Socket connection
+  <p id=closeWebSocket>When the <a href="#web-socket1">Web Socket connection
    is closed</a>, the <code title=dom-WebSocket-readyState><a
    href="#readystate1">readyState</a></code> attribute's value must be
    changed to <code title=dom-WebSocket-CLOSED><a
    href="#closed">CLOSED</a></code> (2), and the user agent must <a
-   href="#firing2">fire a simple event</a> named <code
-   title=event-WebSocket-close><a href="#close1">close</a></code> at the
-   <code><a href="#websocket0">WebSocket</a></code> object.
+   href="#queue">queue a task</a> to <a href="#firing2">fire a simple
+   event</a> named <code title=event-WebSocket-close><a
+   href="#close1">close</a></code> at the <code><a
+   href="#websocket0">WebSocket</a></code> object.
 
   <h3 id=crossDocumentMessages><span class=secno>7.4 </span><dfn
    id=cross-document>Cross-document messaging</dfn></h3>
@@ -44336,14 +44346,6 @@
      continue running these steps.</p>
 
    <li>
-    <p>Wait for all scripts in the <a href="#unit-of">unit of related
-     browsing contexts</a> to which the <code><a
-     href="#window">Window</a></code> object on which the method was invoked
-     belongs to have finished executing any pending scripts.</p>
-    <!-- XXX define this in terms of the
-    event queue -->
-
-   <li>
     <p>If the <var title="">targetOrigin</var> argument has a value other
      than a single literal U+002A ASTERISK character ("*"), and the <a
      href="#active">active document</a> of the <a href="#browsing1">browsing
@@ -44379,9 +44381,11 @@
     
 
    <li>
-    <p>Dispatch the event created in the previous step at the <code><a
-     href="#window">Window</a></code> object on which the method was invoked.</p>
-    <!-- XXX define this in terms of the event queue -->
+    <p><a href="#queue">Queue a task</a> to dispatch the event created in the
+     previous step at the <code><a href="#window">Window</a></code> object on
+     which the method was invoked. The <a href="#task-source">task source</a>
+     for this <a href="#tasks" title=concept-task>task</a> is the <a
+     href="#posted">posted message task source</a>.</p>
     <!-- XXX apply any body/window dispatch decisions here -->
   </ol>
 
@@ -44423,14 +44427,6 @@
      continue running these steps.</p>
 
    <li>
-    <p>Wait for all scripts in the <a href="#unit-of">unit of related
-     browsing contexts</a> to which the <code><a
-     href="#window">Window</a></code> object on which the method was invoked
-     belongs to have finished executing any pending scripts.</p>
-    <!-- XXX define this in terms of the
-    event queue -->
-
-   <li>
     <p>If the <var title="">targetOrigin</var> argument has a value other
      than a single literal U+002A ASTERISK character ("*"), and the <a
      href="#active">active document</a> of the <a href="#browsing1">browsing
@@ -44471,9 +44467,11 @@
      <var title="">new port</var>.</p>
 
    <li>
-    <p>Dispatch the event created in the previous step at the <code><a
-     href="#window">Window</a></code> object on which the method was invoked.</p>
-    <!-- XXX define this in terms of the event queue -->
+    <p><a href="#queue">Queue a task</a> to dispatch the event created in the
+     previous step at the <code><a href="#window">Window</a></code> object on
+     which the method was invoked. The <a href="#task-source">task source</a>
+     for this <a href="#tasks" title=concept-task>task</a> is the <a
+     href="#posted">posted message task source</a>.</p>
     <!-- XXX apply any body/window dispatch decisions here -->
   </ol>
 
@@ -44804,23 +44802,32 @@
    its port's <a href="#port-message">port message queue</a>, if it is not
    already open.
 
-  <p>When a port's <a href="#port-message">port message queue</a> is open and
-   contains an event, the user agent must, at the earliest opportunity, after
-   any scripts have finished executing<!-- XXX queue -->, dispatch the first
+  <p>When a port's <a href="#port-message">port message queue</a> is open,
+   contains an event, and its owner is <a href="#available" title="port owner
+   available">available</a>, the user agent must <a href="#queue">queue a
+   task</a> in the <a href="#event3">event loop</a> to dispatch the first
    event in the queue on the <code><a
    href="#messageport0">MessagePort</a></code> object, and remove the event
-   from the queue.
+   from the queue. The <a href="#task-source">task source</a> for this <a
+   href="#tasks" title=concept-task>task</a> is the <a href="#posted">posted
+   message task source</a>.
 
-  <p>If the <code><a href="#messageport0">MessagePort</a></code> is owned by
-   a <code><a href="#window">Window</a></code> object and the
+  <p>A <code><a href="#messageport0">MessagePort</a></code>'s owner is <dfn
+   id=available title="port owner available">available</dfn> if the <code><a
+   href="#messageport0">MessagePort</a></code> is owned by an object other
+   than a <code><a href="#window">Window</a></code> object, or if it is owned
+   by a <code><a href="#window">Window</a></code> object and the
    <code>Document</code> that was the <a href="#active">active document</a>
    in that <a href="#browsing1">browsing context</a> when the <code><a
-   href="#messageport0">MessagePort</a></code> was created is not <a
-   href="#fully">fully active</a>, then an opportunity doesn't exist —
-   events in such cases must only be dispatched once the
-   <code>Document</code> in question becomes <a href="#fully">fully
-   active</a>. If that doesn't happen before that <code>Document</code> is
-   discarded, then the events are lost.
+   href="#messageport0">MessagePort</a></code> was created is <a
+   href="#fully">fully active</a>. If that <code>Document</code> is discarded
+   before the port's owner becomes available, then the events are lost.</p>
+  <!-- XXX when we have sorted out the global object mess, if that
+  makes this easier to fix, then fix it better. (e.g. maybe just say
+  that callback tasks aren't processed if they involve firing a
+  callback that wouldn't fire because the code is swapped out? not
+  sure how you'd handle prioritisation, i guess you'd just pretend
+  those events weren't there for the time being) -->
 
   <hr>
 
@@ -44834,14 +44841,20 @@
     <p>Unentangle the two ports.
 
    <li>
-    <p>At the next available opportunity, after any scripts have finished
-     executing<!-- XXX queue -->, <a href="#firing2">fire a simple event</a>
-     called <code title=event-unload>unload</code> at each of the message
-     ports. If the two message ports are in the same <a href="#unit-of">unit
-     of related browsing contexts</a>, then the port on which the method was
-     called must receive the event first.
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> called <code title=event-unload>unload</code> at the port on
+     which the method was called.
+
+   <li>
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> called <code title=event-unload>unload</code> at the other
+     port.
   </ol>
 
+  <p>The <a href="#task-source">task source</a> for the two <a href="#tasks"
+   title=concept-task>tasks</a> above is the <a href="#posted">posted message
+   task source</a>.
+
   <p>If the method is called on a port that is not entangled, then the method
    must do nothing.
 
@@ -44911,10 +44924,11 @@
     <p>Unentangle the two ports.
 
    <li>
-    <p>At the next available opportunity, after any scripts have finished
-     executing<!-- XXX queue -->, <a href="#firing2">fire a simple event</a>
-     called <code title=event-unload>unload</code> at <var title="">surviving
-     port</var>.
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> called <code title=event-unload>unload</code> at <var
+     title="">surviving port</var>. The <a href="#task-source">task
+     source</a> for this <a href="#tasks" title=concept-task>task</a> is the
+     <a href="#posted">posted message task source</a>.
   </ol>
 
   <h5 id=ports0><span class=secno>7.5.3.2. </span>Ports and garbage
@@ -55461,8 +55475,9 @@
 
   <h3 id=timers><span class=secno>10.4 </span>Timers</h3>
 
-  <p class=big-issue>This section is expected to be moved to the Window
-   Object specification in due course.
+  <p class=big-issue>This section is expected to be moved to its own
+   specification in due course. It needs a lot of work to actually make it
+   into a semi-decent spec.
 
   <p>Objects that implement the <code><a href="#window">Window</a></code>
    interface must also implement the <code><a
@@ -55501,19 +55516,22 @@
    <code><a href="#timeouthandler">TimeoutHandler</a></code> object and a
    length of time in milliseconds. It must return a handle to the timeout
    created, and then asynchronously wait <var title="">timeout</var>
-   milliseconds and then invoke <code>handleEvent()</code> on the <var
-   title="">handler</var> object. If any <var title="">arguments...</var>
-   were provided, they must be passed to the <var title="">handler</var> as
-   arguments to the <code>handleEvent()</code> function.
+   milliseconds and then <a href="#queue">queue a task</a> to invoke
+   <code>handleEvent()</code> on the <var title="">handler</var> object. If
+   any <var title="">arguments...</var> were provided, they must be passed to
+   the <var title="">handler</var> as arguments to the
+   <code>handleEvent()</code> function.
 
   <p>Alternatively, <dfn id=settimeout0 title=""><code>setTimeout(<var
    title="">code</var>, <var title="">timeout</var>[, <var
    title="">language</var>])</code></dfn> may be used. This variant takes a
    string instead of a <code><a
-   href="#timeouthandler">TimeoutHandler</a></code> object. That string must
-   be parsed using the specified <var title="">language</var> (defaulting to
-   ECMAScript if the third argument is omitted) and executed in the scope of
-   the <a href="#browsing1">browsing context</a> associated with the <code><a
+   href="#timeouthandler">TimeoutHandler</a></code> object. <span
+   title=big-issue>define the actual requirements for this method, as with
+   the previous one.</span> That string must be parsed using the specified
+   <var title="">language</var> (defaulting to ECMAScript if the third
+   argument is omitted) and executed in the scope of the <a
+   href="#browsing1">browsing context</a> associated with the <code><a
    href="#window">Window</a></code> object on which the <code
    title=setTimeout>setTimeout()</code> method was invoked.
 
@@ -55523,9 +55541,10 @@
    title=dom-windowtimers-setInterval><code>setInterval(...)</code></dfn>
    variants must work in the same way as the <code>setTimeout</code> variants
    except that if <var title="">timeout</var> is a value greater than zero,
-   the <var title="">handler</var> or <code><a href="#code">code</a></code>
-   must be invoked again every <var title="">timeout</var> milliseconds, not
-   just the once.</p>
+   the <a href="#tasks" title=concept-task>task</a> that invokes the <var
+   title="">handler</var> or <code><a href="#code">code</a></code> must be <a
+   href="#queue" title="queue a task">queued</a> again every <var
+   title="">timeout</var> milliseconds, not just the once.</p>
   <!-- so
   setInterval(x) and setInterval(x, 0) are equivalent to setTimeout(x)
   and setTimeout(x, 0) respectively -->
@@ -55543,10 +55562,6 @@
    correspond to an active timeout or interval, the methods must return
    without doing anything.
 
-  <p>Timeouts must never fire while another script is executing. (Thus the
-   HTML scripting model is strictly single-threaded and not reentrant.)</p>
-  <!-- XXX queue -->
-
   <h2 class=no-num id=index>Index</h2>
 
   <p><em>This section is non-normative.</em>

Modified: source
===================================================================
--- source	2008-08-19 09:00:41 UTC (rev 2084)
+++ source	2008-08-19 09:30:40 UTC (rev 2085)
@@ -28063,10 +28063,10 @@
   <h4>Processing model</h4>
   <!-- ua side -->
 
-  <p>The <span>event source</span> for all <span
+  <p>The <span>task source</span> for all <span
   title="concept-task">tasks</span> <span title="queue a
   task">queued</span> by algorithms in this section and its
-  subsections is the <dfn>template event source</dfn>.</p>
+  subsections is the <dfn>template task source</dfn>.</p>
 
 
   <h5>The <code title="dom-originalContent">originalContent</code> DOM
@@ -40144,8 +40144,16 @@
   null, and the <code title="dom-MessageEvent-messagePort">messagePort</code>
   attribute must be null.</p>
 
+  <hr>
 
+  <p><span title="concept-task">Tasks</span> in <span>server-sent
+  events</span> and <span>Web Sockets</span> use their own <span
+  title="task source">task sources</span>, but the <span>task
+  source</span> for the <span title="concept-task">tasks</span> in
+  <span>cross-document messaging</span> and <span>channel
+  messaging</span> is the <dfn>posted message task source</dfn>.</p>
 
+
   <h3 id="server-sent-events"><dfn>Server-sent events</dfn></h3>
   <!-- eventsource -->
 
@@ -40214,7 +40222,7 @@
 
     <p>As data is received, the <span
     title="concept-task">tasks</span> queued by the <span>networking
-    event source</span> to handle the data must consist of following
+    task source</span> to handle the data must consist of following
     the rules given in the following sections.</p>
 
    </li>
@@ -40802,15 +40810,6 @@
   <p>The <code title="event-message">message</code> event is fired
   when when data is received for a connection.</p>
 
-  <p>Events that would be fired during script execution (e.g. between
-  the <code>WebSocket</code> object being created — and thus the
-  connection being established — and the current script
-  completing; or, during the execution of a <code
-  title="event-message">message</code> event handler) must be
-  buffered, and those events queued up and each one individually fired
-  after the script has completed.</p> <!-- XXX make this more generic
-  -->
-
   <hr>
 
   <p>The following are the <span>event handler DOM attributes</span>
@@ -40842,6 +40841,11 @@
 
   <h4>The Web Socket protocol</h4>
 
+  <p>The <span>task source</span> for all <span
+  title="concept-task">tasks</span> <span title="queue a
+  task">queued</span> by algorithms in this section and its
+  subsections is the <dfn>Web Socket task source</dfn>.</p>
+
   <h5>Client-side requirements</h5>
 
   <p><em>This section only applies to user agents.</em></p>
@@ -41276,8 +41280,8 @@
 
    <li>
 
-    <p><span>Fire a simple event</span> named <code
-    title="event-WebSocket-open">open</code> at the
+    <p><span>Queue a task</span> to <span>fire a simple event</span>
+    named <code title="event-WebSocket-open">open</code> at the
     <code>WebSocket</code> object.</p>
 
    </li>
@@ -41393,9 +41397,9 @@
        the event name <code title="event-message">message</code>,
        which does not bubble, is cancelable, has no default action,
        and whose <code title="dom-MessageEvent-data">data</code>
-       attribute is set to <var title="">data</var>, and dispatch it
-       at the <code>WebSocket</code> object. Otherwise, discard the
-       data.</p></li>
+       attribute is set to <var title="">data</var>, and <span>queue a
+       task</span> to dispatch it at the <code>WebSocket</code>
+       object. Otherwise, discard the data.</p></li>
 
       </ol>
 
@@ -41634,8 +41638,9 @@
   closed</span>, the <code
   title="dom-WebSocket-readyState">readyState</code> attribute's value
   must be changed to <code title="dom-WebSocket-CLOSED">CLOSED</code>
-  (2), and the user agent must <span>fire a simple event</span> named
-  <code title="event-WebSocket-close">close</code> at the
+  (2), and the user agent must <span>queue a task</span> to <span>fire
+  a simple event</span> named <code
+  title="event-WebSocket-close">close</code> at the
   <code>WebSocket</code> object.</p>
 
 
@@ -41762,16 +41767,6 @@
 
    <li>
 
-    <p>Wait for all scripts in the <span>unit of related browsing
-    contexts</span> to which the <code>Window</code> object on
-    which the method was invoked belongs to have finished executing
-    any pending scripts.</p> <!-- XXX define this in terms of the
-    event queue -->
-
-   </li>
-
-   <li>
-
     <p>If the <var title="">targetOrigin</var> argument has a value
     other than a single literal U+002A ASTERISK character ("*"), and
     the <span>active document</span> of the <span>browsing
@@ -41807,9 +41802,11 @@
 
    <li>
 
-    <p>Dispatch the event created in the previous step at the
-    <code>Window</code> object on which the method was invoked.</p>
-    <!-- XXX define this in terms of the event queue -->
+    <p><span>Queue a task</span> to dispatch the event created in the
+    previous step at the <code>Window</code> object on which the
+    method was invoked. The <span>task source</span> for this <span
+    title="concept-task">task</span> is the <span>posted message task
+    source</span>.</p>
     <!-- XXX apply any body/window dispatch decisions here -->
 
    </li>
@@ -41872,16 +41869,6 @@
 
    <li>
 
-    <p>Wait for all scripts in the <span>unit of related browsing
-    contexts</span> to which the <code>Window</code> object on
-    which the method was invoked belongs to have finished executing
-    any pending scripts.</p> <!-- XXX define this in terms of the
-    event queue -->
-
-   </li>
-
-   <li>
-
     <p>If the <var title="">targetOrigin</var> argument has a value
     other than a single literal U+002A ASTERISK character ("*"), and
     the <span>active document</span> of the <span>browsing
@@ -41925,9 +41912,11 @@
 
    <li>
 
-    <p>Dispatch the event created in the previous step at the
-    <code>Window</code> object on which the method was invoked.</p>
-    <!-- XXX define this in terms of the event queue -->
+    <p><span>Queue a task</span> to dispatch the event created in the
+    previous step at the <code>Window</code> object on which the
+    method was invoked. The <span>task source</span> for this <span
+    title="concept-task">task</span> is the <span>posted message task
+    source</span>.</p>
     <!-- XXX apply any body/window dispatch decisions here -->
 
    </li>
@@ -42248,23 +42237,32 @@
   method must open its port's <span>port message queue</span>, if it
   is not already open.</p>
 
-  <p>When a port's <span>port message queue</span> is open and
-  contains an event, the user agent must, at the earliest opportunity,
-  after any scripts have finished executing<!-- XXX queue -->,
-  dispatch the first event in the queue on the
-  <code>MessagePort</code> object, and remove the event from the
-  queue.</p>
+  <p>When a port's <span>port message queue</span> is open, contains
+  an event, and its owner is <span title="port owner
+  available">available</span>, the user agent must <span>queue a
+  task</span> in the <span>event loop</span> to dispatch the first
+  event in the queue on the <code>MessagePort</code> object, and
+  remove the event from the queue.  The <span>task source</span> for
+  this <span title="concept-task">task</span> is the <span>posted
+  message task source</span>.</p>
 
-  <p>If the <code>MessagePort</code> is owned by a <code>Window</code>
-  object and the <code>Document</code> that was the <span>active
-  document</span> in that <span>browsing context</span> when the
-  <code>MessagePort</code> was created is not <span>fully
-  active</span>, then an opportunity doesn't exist — events in
-  such cases must only be dispatched once the <code>Document</code> in
-  question becomes <span>fully active</span>. If that doesn't happen
-  before that <code>Document</code> is discarded, then the events are
-  lost.</p>
+  <p>A <code>MessagePort</code>'s owner is <dfn title="port owner
+  available">available</dfn> if the <code>MessagePort</code> is owned
+  by an object other than a <code>Window</code> object, or if it is
+  owned by a <code>Window</code> object and the <code>Document</code>
+  that was the <span>active document</span> in that <span>browsing
+  context</span> when the <code>MessagePort</code> was created is
+  <span>fully active</span>. If that <code>Document</code> is
+  discarded before the port's owner becomes available, then the events
+  are lost.</p>
 
+  <!-- XXX when we have sorted out the global object mess, if that
+  makes this easier to fix, then fix it better. (e.g. maybe just say
+  that callback tasks aren't processed if they involve firing a
+  callback that wouldn't fire because the code is swapped out? not
+  sure how you'd handle prioritisation, i guess you'd just pretend
+  those events weren't there for the time being) -->
+
   <hr>
 
   <p>The <dfn title="dom-MessagePort-close"><code>close()</code></dfn>
@@ -42276,15 +42274,20 @@
 
    <li><p>Unentangle the two ports.</p></li>
 
-   <li><p>At the next available opportunity, after any scripts have
-   finished executing<!-- XXX queue -->, <span>fire a simple
-   event</span> called <code title="event-unload">unload</code> at
-   each of the message ports. If the two message ports are in the same
-   <span>unit of related browsing contexts</span>, then the port on
-   which the method was called must receive the event first.</p></li>
+   <li><p><span>Queue a task</span> to <span>fire a simple
+   event</span> called <code title="event-unload">unload</code> at the
+   port on which the method was called.</p></li>
 
+   <li><p><span>Queue a task</span> to <span>fire a simple
+   event</span> called <code title="event-unload">unload</code> at the
+   other port.</p></li>
+
   </ol>
 
+  <p>The <span>task source</span> for the two <span
+  title="concept-task">tasks</span> above is the <span>posted message
+  task source</span>.
+
   <p>If the method is called on a port that is not entangled, then the
   method must do nothing.</p>
 
@@ -42348,10 +42351,11 @@
 
    <li><p>Unentangle the two ports.</p></li>
 
-   <li><p>At the next available opportunity, after any scripts have
-   finished executing<!-- XXX queue -->, <span>fire a simple
+   <li><p><span>Queue a task</span> to <span>fire a simple
    event</span> called <code title="event-unload">unload</code> at
-   <var title="">surviving port</var>.</p></li>
+   <var title="">surviving port</var>.  The <span>task source</span>
+   for this <span title="concept-task">task</span> is the <span>posted
+   message task source</span>.</p></li>
 
   </ol>
 
@@ -50397,8 +50401,9 @@
 
   <h3 id="timers">Timers</h3>
 
-  <p class="big-issue">This section is expected to be moved to the
-  Window Object specification in due course.</p>
+  <p class="big-issue">This section is expected to be moved to its own
+  specification in due course. It needs a lot of work to actually make
+  it into a semi-decent spec.</p>
 
   <p>Objects that implement the <code>Window</code> interface must
   also implement the <code>WindowTimers</code> interface:</p>
@@ -50433,22 +50438,23 @@
   to a <code>TimeoutHandler</code> object and a length of time in
   milliseconds. It must return a handle to the timeout created, and
   then asynchronously wait <var title="">timeout</var> milliseconds
-  and then invoke <code>handleEvent()</code> on the <var
-  title="">handler</var> object. If any <var
-  title="">arguments...</var> were provided, they must be passed to
-  the <var title="">handler</var> as arguments to the
-  <code>handleEvent()</code> function.</p>
+  and then <span>queue a task</span> to invoke
+  <code>handleEvent()</code> on the <var title="">handler</var>
+  object. If any <var title="">arguments...</var> were provided, they
+  must be passed to the <var title="">handler</var> as arguments to
+  the <code>handleEvent()</code> function.</p>
 
   <p>Alternatively, <dfn title=""><code>setTimeout(<var
   title="">code</var>, <var title="">timeout</var>[, <var
   title="">language</var>])</code></dfn> may be used. This variant
-  takes a string instead of a <code>TimeoutHandler</code> object. That
-  string must be parsed using the specified <var
-  title="">language</var> (defaulting to ECMAScript if the third
-  argument is omitted) and executed in the scope of the <span>browsing
-  context</span> associated with the <code>Window</code> object on
-  which the <code title="setTimeout">setTimeout()</code> method was
-  invoked.</p>
+  takes a string instead of a <code>TimeoutHandler</code>
+  object. <span title="big-issue">define the actual requirements for
+  this method, as with the previous one.</span> That string must be
+  parsed using the specified <var title="">language</var> (defaulting
+  to ECMAScript if the third argument is omitted) and executed in the
+  scope of the <span>browsing context</span> associated with the
+  <code>Window</code> object on which the <code
+  title="setTimeout">setTimeout()</code> method was invoked.</p>
 
   <p class="big-issue">Need to define <var title="">language</var>
   values.</p>
@@ -50457,8 +50463,9 @@
   title="dom-windowtimers-setInterval"><code>setInterval(...)</code></dfn>
   variants must work in the same way as the <code>setTimeout</code>
   variants except that if <var title="">timeout</var> is a value
-  greater than zero, the <var title="">handler</var> or
-  <code>code</code> must be invoked again every <var
+  greater than zero, the <span title="concept-task">task</span> that
+  invokes the <var title="">handler</var> or <code>code</code> must be
+  <span title="queue a task">queued</span> again every <var
   title="">timeout</var> milliseconds, not just the once.</p> <!-- so
   setInterval(x) and setInterval(x, 0) are equivalent to setTimeout(x)
   and setTimeout(x, 0) respectively -->
@@ -50474,13 +50481,9 @@
   with a value that does not correspond to an active timeout or
   interval, the methods must return without doing anything.</p>
 
-  <p>Timeouts must never fire while another script is executing. (Thus
-  the HTML scripting model is strictly single-threaded and not
-  reentrant.)</p><!-- XXX queue -->
 
 
 
-
   <h2 class="no-num">Index</h2>
 
   <p><em>This section is non-normative.</em></p>




More information about the Commit-Watchers mailing list