Skip to content
Browse files

readme

  • Loading branch information...
1 parent d330fbb commit 43e017e0c6df457d13fcc8711527044e41d1e9cf @Yaffle committed Feb 2, 2013
Showing with 33 additions and 60 deletions.
  1. +20 −49 README.md
  2. +3 −1 tests/server.js
  3. +10 −10 tests/tests.js
View
69 README.md
@@ -1,64 +1,35 @@
EventSource polyfill - http://www.w3.org/TR/eventsource/
========================================================
- Browser support:
- ----------------
+Browser support:
+----------------
- IE 8+, Firefox 3.5+, Chrome 6+, Safari 5+, Opera 12+
+* IE 8+, Firefox 3.5+, Chrome 6+, Safari 5+, Opera 12+
+* It works on Mobile Safari, Android Browser, Opera Mobile, Chrome for Android, Firefox for Android
- It works on Mobile Safari, Android Browser, Opera Mobile, Chrome for Android, Firefox for Android
+Advantages:
+-----------
- Advantages:
- -----------
+* Simple server-side code
+* Cross-domain requests support ("withCredentials" is not supported in IE8-IE9)
- * Simple server-side code - you don't need any library.
- * Based on latest specification
- * Polyfill is independent from document methods, so you can use it in a Web Worker's
- * Cross-domain requests support ("withCredentials" is not supported in IE8-IE9)
+Server-side requirements:
+-------------------------
- Server-side requirements:
- -------------------------
+* "Last-Event-ID" is sent in a query string (CORS + "Last-Event-ID" header is not supported by all browsers)
+* It is required to send two kilobyte padding for IE at the top of the response stream
+* You need to send "comment" messages each 15-30 seconds, this messages will be used as heartbeat to detect disconnects - see https://bugzilla.mozilla.org/show_bug.cgi?id=444328
- * "Last-Event-ID" is sent in a query string (CORS + "Last-Event-ID" header is not supported by all browsers)
- * Answer to preflight request is required (see example)
- * It is required to send two kilobyte padding for IE at the top of the response stream - see http://blogs.msdn.com/b/ieinternals/archive/2010/04/06/comet-streaming-in-internet-explorer-with-xmlhttprequest-and-xdomainrequest.aspx?PageIndex=1
- * you need to send "comment" message each 15-30 seconds
- * do not use the null character, some browsers have problems with it
+Specification:
+--------------
- Specification:
- --------------
+* http://www.w3.org/TR/eventsource/
- * http://www.w3.org/TR/eventsource/
-
- Other EventSource polyfills:
- ----------------------------
-
- * https://github.com/remy/polyfills/blob/master/EventSource.js by Remy Sharp
- * https://github.com/rwldrn/jquery.eventsource by rick waldron
-
- Native EventSource bugs (this shim replaces native browsers EventSource object):
- --------------------------------------------------------------------------------
- CORS
- * Firefox 11
- * Chrome 26 (WebKit 537.27)
- * Opera 12
-
- lastEventId shouldn't be set when connection dropped without data dispatch - http://www.w3.org/Bugs/Public/show_bug.cgi?id=13761
- * https://bugzilla.mozilla.org/show_bug.cgi?id=710546
- * Opera DSK-353296, Opera DSK-346814
-
- http://www.w3.org/Bugs/Public/show_bug.cgi?id=14331
- * DSK-362330 - Opera
- * https://code.google.com/p/chromium/issues/detail?id=125190 - Chrome/Safari (resolved)
- * DSK-362337 - Opera bug with event-stream with "message", "error", "open" events (minor)
- * http://code.google.com/p/chromium/issues/detail?id=86230 - Crhome bug with small "retry" (minor)
-
- * http://lists.w3.org/Archives/Public/public-webapps/2012AprJun/0388.html
+Other EventSource polyfills:
+----------------------------
- * http://code.google.com/p/chromium/issues/detail?id=114475
- * https://bugzilla.mozilla.org/show_bug.cgi?id=654579#c9
- * https://bugzilla.mozilla.org/show_bug.cgi?id=444328
- * https://bugzilla.mozilla.org/show_bug.cgi?id=721306
+* https://github.com/remy/polyfills/blob/master/EventSource.js by Remy Sharp
+* https://github.com/rwldrn/jquery.eventsource by rick waldron
EXAMPLE
-------
View
4 tests/server.js
@@ -110,7 +110,9 @@ function onTest(response, lastEventId, test, cookies) {
response.end();
}
if (test === 12) {
- response.write("data: \x00\ud800\udc01\n\n");
+ response.write("data: a\n\n");
+ response.write("data: \x00\n\n");
+ response.write("data: b\n\n");
response.end();
}
}
View
20 tests/tests.js
@@ -108,6 +108,7 @@ window.onload = function () {
};
});
+ // native EventSource is buggy in Opera, FF < 11, Chrome < ?
asyncTest('EventSource test next', function () {
var es = new EventSource(url + '?test=1');
var closeCount = 0;
@@ -232,6 +233,7 @@ window.onload = function () {
};
});
+ // Native EventSource + CORS: Opera 12, Firefox 11, Chrome 26 (WebKit 537.27)
asyncTest('EventSource CORS', function () {
var es = new EventSource(url4CORS + '?test=8');
@@ -251,7 +253,7 @@ window.onload = function () {
};
});
- // Opera 11, 12 fails this tests (Chrome 17, Firefox 11, Safari 5.1 - ok)
+ // buggy with native EventSource in Opera - DSK-362337
asyncTest('event-stream with "message", "error", "open" events', function () {
var es = new EventSource(url + '?test=11');
var s = '';
@@ -271,23 +273,21 @@ window.onload = function () {
};
});
- /*
- IE 8 - 9 issue
+ //IE 8 - 9 issue, Native EventSource in Opera 12
asyncTest('event-stream null character', function () {
var es = new EventSource(url + '?test=12');
var ok = false;
es.addEventListener('message', function (event) {
- ok = event.data === "\x00\ud800\udc01";
+ if (event.data === "\x00") {
+ ok = true;
+ }
});
es.onerror = function (event) {
- if (!event.data) {// !(event instanceof MessageEvent)
- strictEqual(true, ok);
- start();
- es.close();
- }
+ es.close();
+ strictEqual(true, ok);
+ start();
};
});
- */
asyncTest('EventSource retry delay - see http://code.google.com/p/chromium/issues/detail?id=86230', function () {
var es = new EventSource(url + '?test=800');

0 comments on commit 43e017e

Please sign in to comment.
Something went wrong with that request. Please try again.