Title: [121195] trunk
- Revision
- 121195
- Author
- [email protected]
- Date
- 2012-06-25 16:59:55 -0700 (Mon, 25 Jun 2012)
Log Message
EventSource: Events should not be dispatched after close()
https://bugs.webkit.org/show_bug.cgi?id=85346
Patch by Pablo Flouret <[email protected]> on 2012-06-25
Reviewed by Adam Barth.
Source/WebCore:
Spec changed to make sure that no events are dispatched after close() is
called, even if more data was received before the call to close().
See,
https://www.w3.org/Bugs/Public/show_bug.cgi?id=14331#c5
http://html5.org/tools/web-apps-tracker?from=6771&to=6772
Firefox behaves like this already.
Test: http/tests/eventsource/eventsource-events-after-close.html
* page/EventSource.cpp:
(WebCore::EventSource::parseEventStream):
LayoutTests:
* http/tests/eventsource/eventsource-events-after-close-expected.txt: Added.
* http/tests/eventsource/eventsource-events-after-close.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (121194 => 121195)
--- trunk/LayoutTests/ChangeLog 2012-06-25 23:53:10 UTC (rev 121194)
+++ trunk/LayoutTests/ChangeLog 2012-06-25 23:59:55 UTC (rev 121195)
@@ -1,3 +1,13 @@
+2012-06-25 Pablo Flouret <[email protected]>
+
+ EventSource: Events should not be dispatched after close()
+ https://bugs.webkit.org/show_bug.cgi?id=85346
+
+ Reviewed by Adam Barth.
+
+ * http/tests/eventsource/eventsource-events-after-close-expected.txt: Added.
+ * http/tests/eventsource/eventsource-events-after-close.html: Added.
+
2012-06-25 Dirk Pranke <[email protected]>
remove support for chromium vista from tools
Added: trunk/LayoutTests/http/tests/eventsource/eventsource-events-after-close-expected.txt (0 => 121195)
--- trunk/LayoutTests/http/tests/eventsource/eventsource-events-after-close-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/eventsource/eventsource-events-after-close-expected.txt 2012-06-25 23:59:55 UTC (rev 121195)
@@ -0,0 +1,4 @@
+Test that no more message events are fired after EventSource.close() is called, even if it means discarding events that were already processed. Passes if only one message is received.
+
+Got message #1
+
Added: trunk/LayoutTests/http/tests/eventsource/eventsource-events-after-close.html (0 => 121195)
--- trunk/LayoutTests/http/tests/eventsource/eventsource-events-after-close.html (rev 0)
+++ trunk/LayoutTests/http/tests/eventsource/eventsource-events-after-close.html 2012-06-25 23:59:55 UTC (rev 121195)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<p>
+ Test that no more message events are fired after EventSource.close() is called, even if it
+ means discarding events that were already processed.
+ Passes if only one message is received.
+</p>
+<pre id=log></pre>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
+
+ var log = document.getElementById("log");
+ var es = new EventSource("resources/event-stream.php");
+ var counter = 0;
+ es.addEventListener('message', function (e) {
+ log.innerHTML += "Got message #" + ++counter + "\n";
+
+ if (counter > 1)
+ log.innerHTML += "FAIL. Handler called after the source was closed explicitely.\n";
+
+ es.close();
+
+ setTimeout(function () {
+ // Need to wait to see if we're called again.
+ // event-stream.php sends a bunch of events before flushing, so if close() didn't take
+ // effect we'd get a second message practically instantaneously, waiting 100ms should be ok.
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }, 100);
+ }, false);
+
+</script>
Modified: trunk/Source/WebCore/ChangeLog (121194 => 121195)
--- trunk/Source/WebCore/ChangeLog 2012-06-25 23:53:10 UTC (rev 121194)
+++ trunk/Source/WebCore/ChangeLog 2012-06-25 23:59:55 UTC (rev 121195)
@@ -1,3 +1,24 @@
+2012-06-25 Pablo Flouret <[email protected]>
+
+ EventSource: Events should not be dispatched after close()
+ https://bugs.webkit.org/show_bug.cgi?id=85346
+
+ Reviewed by Adam Barth.
+
+ Spec changed to make sure that no events are dispatched after close() is
+ called, even if more data was received before the call to close().
+
+ See,
+ https://www.w3.org/Bugs/Public/show_bug.cgi?id=14331#c5
+ http://html5.org/tools/web-apps-tracker?from=6771&to=6772
+
+ Firefox behaves like this already.
+
+ Test: http/tests/eventsource/eventsource-events-after-close.html
+
+ * page/EventSource.cpp:
+ (WebCore::EventSource::parseEventStream):
+
2012-06-25 Mike West <[email protected]>
Fixing compilation failure in StyleResolver.cpp/CSSParser.cpp
Modified: trunk/Source/WebCore/page/EventSource.cpp (121194 => 121195)
--- trunk/Source/WebCore/page/EventSource.cpp 2012-06-25 23:53:10 UTC (rev 121194)
+++ trunk/Source/WebCore/page/EventSource.cpp 2012-06-25 23:59:55 UTC (rev 121195)
@@ -315,6 +315,11 @@
parseEventStreamLine(bufPos, fieldLength, lineLength);
bufPos += lineLength + 1;
+
+ // EventSource.close() might've been called by one of the message event handlers.
+ // Per spec, no further messages should be fired after that.
+ if (m_state == CLOSED)
+ break;
}
if (bufPos == bufSize)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes