Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[giow] (1) Make EventSource support the Anonymous CORS mode.
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=14592

git-svn-id: http://svn.whatwg.org/webapps@6791 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Oct 31, 2011
1 parent 187d566 commit 3012ff5
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 45 deletions.
51 changes: 36 additions & 15 deletions complete.html
Expand Up @@ -240,7 +240,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 30 October 2011</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 31 October 2011</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -79436,9 +79436,10 @@ <h4 id=server-sent-events-intro><span class=secno>11.2.1 </span>Introduction</h4

<h4 id=the-eventsource-interface><span class=secno>11.2.2 </span>The <code><a href=#eventsource>EventSource</a></code> interface</h4>

<pre class=idl>[<a href=#dom-eventsource title=dom-EventSource>Constructor</a>(DOMString url)]
<pre class=idl>[<a href=#dom-eventsource title=dom-EventSource>Constructor</a>(DOMString url, optional <a href=#eventsourceinit>EventSourceInit</a> eventSourceInitDict)]
interface <dfn id=eventsource>EventSource</dfn> : <a href=#eventtarget>EventTarget</a> {
readonly attribute DOMString <a href=#dom-eventsource-url title=dom-EventSource-url>url</a>;
readonly attribute boolean <a href=#dom-eventsource-withcredentials title=dom-EventSource-withCredentials>withCredentials</a>;

// ready state
const unsigned short <a href=#dom-eventsource-connecting title=dom-EventSource-CONNECTING>CONNECTING</a> = 0;
Expand All @@ -79451,35 +79452,51 @@ <h4 id=the-eventsource-interface><span class=secno>11.2.2 </span>The <code><a hr
[TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onmessage title=handler-EventSource-onmessage>onmessage</a>;
[TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onerror title=handler-EventSource-onerror>onerror</a>;
void <a href=#dom-eventsource-close title=dom-EventSource-close>close</a>();
};

dictionary <dfn id=eventsourceinit>EventSourceInit</dfn> {
boolean <dfn id=dom-eventsourceinit-withcredentials title=dom-EventSourceInit-withCredentials>withCredentials</dfn> = false;
};</pre>

<p>The <dfn id=dom-eventsource title=dom-EventSource><code>EventSource(<var title="">url</var>)</code></dfn> constructor takes one argument,
<var title="">url</var>, which specifies the <a href=#url>URL</a> to
which to connect. When the <code>EventSource()</code> constructor is
<p>The <dfn id=dom-eventsource title=dom-EventSource><code>EventSource()</code></dfn>
constructor takes one or two arguments. The first specifies the
<a href=#url>URL</a> to which to connect. The second specifies the
settings, if any, in the form of an <code><a href=#eventsourceinit>EventSourceInit</a></code>
dictionary. When the <code>EventSource()</code> constructor is
invoked, the UA must run these steps:</p>

<ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the
<a href=#url>URL</a> specified in <var title="">url</var>, relative to
the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base
URL">base URL</a>.
<a href=#url>URL</a> specified in the first argument, relative to the
<a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base
URL</a>.
</li>

<li><p>If the previous step failed, then throw a
<code><a href=#syntaxerror>SyntaxError</a></code> exception.</li>

<li><p>Return a new <code><a href=#eventsource>EventSource</a></code> object, and continue
<li><p>Create a new <code><a href=#eventsource>EventSource</a></code> object.</li>

<li><p>Let <var title="">CORS mode</var> be <a href=#attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</a>.</li>

<li><p>If the second argument is present, and the <code title=dom-EventSourceInit-withCredentials><a href=#dom-eventsourceinit-withcredentials>withCredentials</a></code>
dictionary member has the value true, then set <var title="">CORS
mode</var> to <a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use
Credentials</a> and initialize the new <code><a href=#eventsource>EventSource</a></code>
object's <code title=dom-EventSource-withCredentials><a href=#dom-eventsource-withcredentials>withCredentials</a></code>
attribute to true.</li>

<li><p>Return the new <code><a href=#eventsource>EventSource</a></code> object, and continue
these steps in the background (without blocking scripts).</li>

<li>

<p>Do a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the
resulting <a href=#absolute-url>absolute URL</a>, with the <i>mode</i> being
<a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use
Credentials</a>, and the <i title="">origin</i> being the <a href=#entry-script>entry
script</a>'s <a href=#origin>origin</a><!--, and the <i>default origin
behaviour</i> set to <i>fail</i> (though it has no effect in the
"Use Credentials" mode)-->, and process the resource obtained in
this fashion, if any, as described below.</p>
<var title="">CORS mode</var>, and the <i title="">origin</i>
being the <a href=#entry-script>entry script</a>'s <a href=#origin>origin</a><!--, and
the <i>default origin behaviour</i> set to <i>fail</i> (though it
has no effect in the "Use Credentials" mode)-->, and process the
resource obtained in this fashion, if any, as described below.</p>

<p class=note>The definition of the <a href=#fetch title=fetch>fetching</a> algorithm (which is used by CORS) is
such that if the browser is already fetching the resource
Expand All @@ -79500,6 +79517,10 @@ <h4 id=the-eventsource-interface><span class=secno>11.2.2 </span>The <code><a hr
passed to the constructor.</p> <!-- not the result of redirects,
since that would introduce race conditions -->

<p>The <dfn id=dom-eventsource-withcredentials title=dom-EventSource-withCredentials><code>withCredentials</code></dfn>
attribute must return the value to which it was last initialized.
When the object is created, it must be initialized to false.</p>

<p>The <dfn id=dom-eventsource-readystate title=dom-EventSource-readyState><code>readyState</code></dfn>
attribute represents the state of the connection. It can have the
following values:</p>
Expand Down
51 changes: 36 additions & 15 deletions index
Expand Up @@ -240,7 +240,7 @@

<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 30 October 2011</h2>
<h2 class="no-num no-toc">Living Standard &mdash; Last Updated 31 October 2011</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
Expand Down Expand Up @@ -79436,9 +79436,10 @@ source.addEventListener('remove', removeHandler, false);</pre>

<h4 id=the-eventsource-interface><span class=secno>11.2.2 </span>The <code><a href=#eventsource>EventSource</a></code> interface</h4>

<pre class=idl>[<a href=#dom-eventsource title=dom-EventSource>Constructor</a>(DOMString url)]
<pre class=idl>[<a href=#dom-eventsource title=dom-EventSource>Constructor</a>(DOMString url, optional <a href=#eventsourceinit>EventSourceInit</a> eventSourceInitDict)]
interface <dfn id=eventsource>EventSource</dfn> : <a href=#eventtarget>EventTarget</a> {
readonly attribute DOMString <a href=#dom-eventsource-url title=dom-EventSource-url>url</a>;
readonly attribute boolean <a href=#dom-eventsource-withcredentials title=dom-EventSource-withCredentials>withCredentials</a>;

// ready state
const unsigned short <a href=#dom-eventsource-connecting title=dom-EventSource-CONNECTING>CONNECTING</a> = 0;
Expand All @@ -79451,35 +79452,51 @@ interface <dfn id=eventsource>EventSource</dfn> : <a href=#eventtarget>EventTarg
[TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onmessage title=handler-EventSource-onmessage>onmessage</a>;
[TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-eventsource-onerror title=handler-EventSource-onerror>onerror</a>;
void <a href=#dom-eventsource-close title=dom-EventSource-close>close</a>();
};

dictionary <dfn id=eventsourceinit>EventSourceInit</dfn> {
boolean <dfn id=dom-eventsourceinit-withcredentials title=dom-EventSourceInit-withCredentials>withCredentials</dfn> = false;
};</pre>

<p>The <dfn id=dom-eventsource title=dom-EventSource><code>EventSource(<var title="">url</var>)</code></dfn> constructor takes one argument,
<var title="">url</var>, which specifies the <a href=#url>URL</a> to
which to connect. When the <code>EventSource()</code> constructor is
<p>The <dfn id=dom-eventsource title=dom-EventSource><code>EventSource()</code></dfn>
constructor takes one or two arguments. The first specifies the
<a href=#url>URL</a> to which to connect. The second specifies the
settings, if any, in the form of an <code><a href=#eventsourceinit>EventSourceInit</a></code>
dictionary. When the <code>EventSource()</code> constructor is
invoked, the UA must run these steps:</p>

<ol><li><p><a href=#resolve-a-url title="resolve a url">Resolve</a> the
<a href=#url>URL</a> specified in <var title="">url</var>, relative to
the <a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base
URL">base URL</a>.
<a href=#url>URL</a> specified in the first argument, relative to the
<a href=#entry-script>entry script</a>'s <a href="#script's-base-url" title="script's base URL">base
URL</a>.
</li>

<li><p>If the previous step failed, then throw a
<code><a href=#syntaxerror>SyntaxError</a></code> exception.</li>

<li><p>Return a new <code><a href=#eventsource>EventSource</a></code> object, and continue
<li><p>Create a new <code><a href=#eventsource>EventSource</a></code> object.</li>

<li><p>Let <var title="">CORS mode</var> be <a href=#attr-crossorigin-anonymous title=attr-crossorigin-anonymous>Anonymous</a>.</li>

<li><p>If the second argument is present, and the <code title=dom-EventSourceInit-withCredentials><a href=#dom-eventsourceinit-withcredentials>withCredentials</a></code>
dictionary member has the value true, then set <var title="">CORS
mode</var> to <a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use
Credentials</a> and initialize the new <code><a href=#eventsource>EventSource</a></code>
object's <code title=dom-EventSource-withCredentials><a href=#dom-eventsource-withcredentials>withCredentials</a></code>
attribute to true.</li>

<li><p>Return the new <code><a href=#eventsource>EventSource</a></code> object, and continue
these steps in the background (without blocking scripts).</li>

<li>

<p>Do a <a href=#potentially-cors-enabled-fetch>potentially CORS-enabled fetch</a> of the
resulting <a href=#absolute-url>absolute URL</a>, with the <i>mode</i> being
<a href=#attr-crossorigin-use-credentials title=attr-crossorigin-use-credentials>Use
Credentials</a>, and the <i title="">origin</i> being the <a href=#entry-script>entry
script</a>'s <a href=#origin>origin</a><!--, and the <i>default origin
behaviour</i> set to <i>fail</i> (though it has no effect in the
"Use Credentials" mode)-->, and process the resource obtained in
this fashion, if any, as described below.</p>
<var title="">CORS mode</var>, and the <i title="">origin</i>
being the <a href=#entry-script>entry script</a>'s <a href=#origin>origin</a><!--, and
the <i>default origin behaviour</i> set to <i>fail</i> (though it
has no effect in the "Use Credentials" mode)-->, and process the
resource obtained in this fashion, if any, as described below.</p>

<p class=note>The definition of the <a href=#fetch title=fetch>fetching</a> algorithm (which is used by CORS) is
such that if the browser is already fetching the resource
Expand All @@ -79500,6 +79517,10 @@ interface <dfn id=eventsource>EventSource</dfn> : <a href=#eventtarget>EventTarg
passed to the constructor.</p> <!-- not the result of redirects,
since that would introduce race conditions -->

<p>The <dfn id=dom-eventsource-withcredentials title=dom-EventSource-withCredentials><code>withCredentials</code></dfn>
attribute must return the value to which it was last initialized.
When the object is created, it must be initialized to false.</p>

<p>The <dfn id=dom-eventsource-readystate title=dom-EventSource-readyState><code>readyState</code></dfn>
attribute represents the state of the connection. It can have the
following values:</p>
Expand Down
54 changes: 39 additions & 15 deletions source
Expand Up @@ -89813,9 +89813,10 @@ source.addEventListener('remove', removeHandler, false);</pre>

<h4>The <code>EventSource</code> interface</h4>

<pre class="idl">[<span title="dom-EventSource">Constructor</span>(DOMString url)]
<pre class="idl">[<span title="dom-EventSource">Constructor</span>(DOMString url, optional <span>EventSourceInit</span> eventSourceInitDict)]
interface <dfn>EventSource</dfn> : <span>EventTarget</span> {
readonly attribute DOMString <span title="dom-EventSource-url">url</span>;
readonly attribute boolean <span title="dom-EventSource-withCredentials">withCredentials</span>;

// ready state
const unsigned short <span title="dom-EventSource-CONNECTING">CONNECTING</span> = 0;
Expand All @@ -89828,20 +89829,25 @@ interface <dfn>EventSource</dfn> : <span>EventTarget</span> {
[TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-EventSource-onmessage">onmessage</span>;
[TreatNonCallableAsNull] attribute <span>Function</span>? <span title="handler-EventSource-onerror">onerror</span>;
void <span title="dom-EventSource-close">close</span>();
};

dictionary <dfn>EventSourceInit</dfn> {
boolean <dfn title="dom-EventSourceInit-withCredentials">withCredentials</dfn> = false;
};</pre>

<p>The <dfn title="dom-EventSource"><code>EventSource(<var
title="">url</var>)</code></dfn> constructor takes one argument,
<var title="">url</var>, which specifies the <span>URL</span> to
which to connect. When the <code>EventSource()</code> constructor is
<p>The <dfn title="dom-EventSource"><code>EventSource()</code></dfn>
constructor takes one or two arguments. The first specifies the
<span>URL</span> to which to connect. The second specifies the
settings, if any, in the form of an <code>EventSourceInit</code>
dictionary. When the <code>EventSource()</code> constructor is
invoked, the UA must run these steps:</p>

<ol>

<li><p><span title="resolve a url">Resolve</span> the
<span>URL</span> specified in <var title="">url</var>, relative to
the <span>entry script</span>'s <span title="script's base
URL">base URL</span>.
<span>URL</span> specified in the first argument, relative to the
<span>entry script</span>'s <span title="script's base URL">base
URL</span>.
<!--END complete--><!--END epub-->
<a href="#refsHTML">[HTML]</a>
<!--START complete--><!--START epub-->
Expand All @@ -89850,19 +89856,32 @@ interface <dfn>EventSource</dfn> : <span>EventTarget</span> {
<li><p>If the previous step failed, then throw a
<code>SyntaxError</code> exception.</p></li>

<li><p>Return a new <code>EventSource</code> object, and continue
<li><p>Create a new <code>EventSource</code> object.</p></li>

<li><p>Let <var title="">CORS mode</var> be <span
title="attr-crossorigin-anonymous">Anonymous</span>.</p></li>

<li><p>If the second argument is present, and the <code
title="dom-EventSourceInit-withCredentials">withCredentials</code>
dictionary member has the value true, then set <var title="">CORS
mode</var> to <span title="attr-crossorigin-use-credentials">Use
Credentials</span> and initialize the new <code>EventSource</code>
object's <code
title="dom-EventSource-withCredentials">withCredentials</code>
attribute to true.</p></li>

<li><p>Return the new <code>EventSource</code> object, and continue
these steps in the background (without blocking scripts).</p></li>

<li>

<p>Do a <span>potentially CORS-enabled fetch</span> of the
resulting <span>absolute URL</span>, with the <i>mode</i> being
<span title="attr-crossorigin-use-credentials">Use
Credentials</span>, and the <i title="">origin</i> being the <span>entry
script</span>'s <span>origin</span><!--, and the <i>default origin
behaviour</i> set to <i>fail</i> (though it has no effect in the
"Use Credentials" mode)-->, and process the resource obtained in
this fashion, if any, as described below.</p>
<var title="">CORS mode</var>, and the <i title="">origin</i>
being the <span>entry script</span>'s <span>origin</span><!--, and
the <i>default origin behaviour</i> set to <i>fail</i> (though it
has no effect in the "Use Credentials" mode)-->, and process the
resource obtained in this fashion, if any, as described below.</p>

<p class="note">The definition of the <span
title="fetch">fetching</span> algorithm (which is used by CORS) is
Expand All @@ -89888,6 +89907,11 @@ interface <dfn>EventSource</dfn> : <span>EventTarget</span> {
passed to the constructor.</p> <!-- not the result of redirects,
since that would introduce race conditions -->

<p>The <dfn
title="dom-EventSource-withCredentials"><code>withCredentials</code></dfn>
attribute must return the value to which it was last initialized.
When the object is created, it must be initialized to false.</p>

<p>The <dfn
title="dom-EventSource-readyState"><code>readyState</code></dfn>
attribute represents the state of the connection. It can have the
Expand Down

0 comments on commit 3012ff5

Please sign in to comment.