HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
2085Further work on the event loop front. (WebSockets, postMessage, MessagePorts, setTimeout)2008-08-19 09:30
@@ -28056,24 +28056,24 @@ menu li:not(:first-child)::before { content: ' | '; }</pre>
   title="dom-registrationMark"><code>registrationMark</code></dfn> DOM
   attribute must <span>reflect</span> the <code
   title="attr-registrationmark">registrationmark</code> content
   attribute.</p>
 
 
 
   <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
   attribute</h5>
 
   <p>The <dfn
   title="dom-originalContent"><code>originalContent</code></dfn> is
   set to a <code>DocumentFragment</code> to hold the original children
   of an element that has been replaced by content generated for a data
   template. Initially, it must be null. Its value is set when the
@@ -40137,20 +40137,28 @@ XXX Once we resolve the style="" issue, address these:
   dispatches a <code title="event-message">message</code> event in the
   algorithms described in the following sections, the <code
   title="dom-MessageEvent-lastEventId">lastEventId</code> attribute
   must be the empty string, the <code
   title="dom-MessageEvent-origin">origin</code> attribute must be the
   empty string, the <code
   title="dom-MessageEvent-source">source</code> attribute must be
   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 -->
 
   <p>This section describes a mechanism for allowing servers to
   dispatch DOM events into documents that expect it. The
   <code>eventsource</code> element provides a simple interface to
   this mechanism.</p>
 
@@ -40207,21 +40215,21 @@ XXX Once we resolve the style="" issue, address these:
    <li><p>If the entry for the new <span>absolute URL</span> has been
    removed from the list, then abort these steps.</p></li>
 
    <li>
 
     <p><span>Fetch</span> the resource identified by that
     <span>absolute URL</span>.</p>
 
     <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>
 
   </ol>
 
   <p>When an event source is removed from the list of event sources
   for an object, if that resource is still being fetched, then the
   relevant connection must be closed.</p>
 
@@ -40795,29 +40803,20 @@ interface <dfn>WebSocket</dfn> {
   title="dom-WebSocket-disconnect">disconnect()</code> method, or by
   the server, or by a network error).</p>
 
   <p class="note">No information regarding why the connection was
   closed is passed to the application in this version of this
   specification.</p>
 
   <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 &mdash; and thus the
-  connection being established &mdash; 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>
   that must be supported by objects implementing the
   <code>WebSocket</code> interface:</p>
 
   <dl>
 
    <dt><dfn title="handler-WebSocket-onopen"><code>onopen</code></dfn></dt>
 
@@ -40835,20 +40834,25 @@ interface <dfn>WebSocket</dfn> {
 
    <dd><p>Must be invoked whenever an <code
    title="event-WebSocket-closed">closed</code> event is targeted at or
    bubbles through the <code>WebSocket</code> object.</p></dd>
 
   </dl>
 
 
   <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>
 
   <h6>Handshake</h6>
 
   <p>When the user agent is to <dfn>establish a Web Socket
   connection</dfn> to <var title="">url</var>, it must run the
   following steps, in the background (without blocking scripts or
   anything like that):</p>
@@ -41269,22 +41273,22 @@ Proxy-authorization: Basic ZWRuYW1vZGU6bm9jYXBlcyE=</pre>
    <li>
 
     <p>Change the <code
     title="dom-WebSocket-readyState">readyState</code> attribute's value
     to <code title="dom-WebSocket-OPEN">OPEN</code> (1).</p>
 
    </li>
 
    <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>
 
    <li>
 
     <p>The <dfn>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>
 
@@ -41386,23 +41390,23 @@ Proxy-authorization: Basic ZWRuYW1vZGU6bm9jYXBlcyE=</pre>
        href="#ws-cd-data">data</a>).</p></li>
 
        <li><p>Interpret <var title="">raw data</var> as a UTF-8
        string, and store that string in <var title="">data</var>.</p>
 
        <li><p>If <var title="">frame type</var> is 0x00, create an
        event that uses the <code>MessageEvent</code> interface, with
        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>
 
      </dd>
 
     </dl>  
 
    </li>
 
    <li><p>Return to the first step to read the next byte.</p></li>
@@ -41627,22 +41631,23 @@ Proxy-authorization: Basic ZWRuYW1vZGU6bm9jYXBlcyE=</pre>
   <p>Servers may <span>close the Web Socket connection</span> whenever
   desired.</p>
 
   <p>User agents should not <span>close the Web Socket
   connection</span> arbitrarily.</p>
 
   <p id="closeWebSocket">When the <span>Web Socket connection is
   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>
 
 
 
   <h3 id="crossDocumentMessages"><dfn>Cross-document messaging</dfn></h3>
 
   <p>Web browsers, for security and privacy reasons, prevent documents
   in different domains from affecting each other; that is, cross-site
   scripting is disallowed.</p>
 
@@ -41755,30 +41760,20 @@ function receiver(e) {
    <li>
 
     <p>Return from the <code
     title="dom-window-postMessage-2">postMessage()</code> method, but
     asynchronously continue running these steps.</p>
 
    </li>
 
    <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
     context</span> of the <code>Window</code> object on which the
     method was invoked does not have the <span>same origin</span> as
     <var title="">targetOrigin</var>, then abort these steps
     silently.</p>
 
    </li>
 
@@ -41800,23 +41795,25 @@ function receiver(e) {
     view</span> of the <span>browsing context</span> for which the
     <code>Document</code> object with which the script is associated
     is the <span>active document</span><!--, if there is one, or null
     otherwise-->.</p><!-- I think there always is one, because scripts
     can't run and see a Window without that being the case. -->
 
    </li>
 
    <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>
 
   </ol>
 
 
   <h4>Posting message ports</h4>
 
   <p>When a script invokes the <dfn
@@ -41865,30 +41862,20 @@ function receiver(e) {
    <li>
 
     <p>Return from the <code
     title="dom-window-postMessage-3">postMessage()</code> method, but
     asynchronously continue running these steps.</p>
 
    </li>
 
    <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
     context</span> of the <code>Window</code> object on which the
     method was invoked does not have the <span>same origin</span> as
     <var title="">targetOrigin</var>, then abort these steps
     silently.</p>
 
    </li>
 
@@ -41918,23 +41905,25 @@ function receiver(e) {
    <li> <!-- NEW STEP -->
  
     <p>Let the <code
     title="dom-MessageEvent-messagePort">messagePort</code> attribute
     of the event be the <var title="">new port</var>.</p>
 
    </li>
 
    <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>
 
   </ol>
 
   <p class="note">These steps, with the exception of the second and
   third steps and the penultimate step, are identical to those in the
   previous section.</p>
 
@@ -42241,57 +42230,71 @@ interface <dfn>MessageChannel</dfn> {
    title="">target port</var>.</p></li>
 
   </ol>
 
   <hr>
 
   <p>The <dfn title="dom-MessagePort-start"><code>start()</code></dfn>
   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>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 &mdash; 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>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>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>
   method, when called on a port <var title="">local port</var> that is
   entangled with another port, must cause the user agents to run the
   following steps:</p>
 
   <ol>
 
    <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>
 
   <hr>
 
   <p>The following are the <span>event handler DOM attributes</span>
   that must be supported by objects implementing the
   <code>MessagePort</code> interface:</p>
 
   <dl>
@@ -42341,24 +42344,25 @@ interface <dfn>MessageChannel</dfn> {
   port:</p>
 
   <ol>
 
    <li><p>Let <var title="">surviving port</var> be the port with
    which the <code>MessagePort</code> object in question is
    entangled.</p></li>
 
    <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>
 
 
 
   <h5>Ports and garbage collection</h5>
 
   <p>User agents must act as if <code>MessagePort</code> objects have
   a strong reference to their entangled <code>MessagePort</code>
   object.</p>
@@ -50390,22 +50394,23 @@ xh|section xh|section xh|section xh|section xh|section xh|h1 { /* same styles as
 
   <p>Embedding 3D imagery into XHTML documents is the domain of X3D,
   or technologies based on X3D that are namespace-aware.</p>
 
   <!-- <p>XXX example here</p> -->
 
 
 
   <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>
 
 <pre class="idl">[NoInterfaceObject] interface <dfn>WindowTimers</dfn> {
   // timers
   long <span title="dom-windowtimers-setTimeout">setTimeout</span>(in <span>TimeoutHandler</span> handler, in long timeout);
   long <span title="dom-windowtimers-setTimeout">setTimeout</span>(in <span>TimeoutHandler</span> handler, in long timeout, <var title="">arguments...</var>);
   long <span title="dom-windowtimers-setTimeout">setTimeout</span>(in DOMString code, in long timeout);
   long <span title="dom-windowtimers-setTimeout">setTimeout</span>(in DOMString code, in long timeout, in DOMString language);
@@ -50426,65 +50431,63 @@ interface <dfn>TimeoutHandler</dfn> {
   and <code title="dom-windowtimers-setInterval">setInterval</code>
   methods allow authors to schedule timer-based events.</p>
 
   <p>The <dfn
   title="dom-windowtimers-setTimeout"><code>setTimeout(<var
   title="">handler</var>, <var title="">timeout</var>[, <var
   title="">arguments...</var>])</code></dfn> method takes a reference
   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>
 
   <p>The <dfn
   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 -->
 
   <p>The <dfn
   title="dom-windowtimers-clearTimeout"><code>clearTimeout()</code></dfn>
   and <dfn
   title="dom-windowtimers-clearInterval"><code>clearInterval()</code></dfn>
   methods take one integer (the value returned by <code
   title="dom-windowtimers-setTimeout">setTimeout()</code> and <code
   title="dom-windowtimers-setInterval">setInterval()</code>
   respectively) and must cancel the specified timeout. When called
   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>
 
   <p class="big-issue">List of elements</p>
 
   <p class="big-issue">List of attributes</p>

|