Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: LayoutTests/http/tests/eventsource/eventsource-events-after-close.html

Issue 347043002: Rework EventSource tests for better Worker test coverage. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move out CORS tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE HTML>
2 <p> 2 <script src="/js-test-resources/js-test.js"></script>
3 Test that no more message events are fired after EventSource.close() is call ed, even if it 3 <script src="script-tests/eventsource-events-after-close.js"></script>
4 means discarding events that were already processed.
5 Passes if only one message is received.
6 </p>
7 <pre id=log></pre>
8 <script>
9 if (window.testRunner) {
10 testRunner.dumpAsText();
11 testRunner.waitUntilDone();
12 }
13
14 var log = document.getElementById("log");
15 var es = new EventSource("resources/event-stream.php");
16 var counter = 0;
17 es.addEventListener('message', function (e) {
18 log.innerHTML += "Got message #" + ++counter + "\n";
19
20 if (counter > 1)
21 log.innerHTML += "FAIL. Handler called after the source was closed e xplicitely.\n";
22
23 es.close();
24
25 setTimeout(function () {
26 // Need to wait to see if we're called again.
27 // event-stream.php sends a bunch of events before flushing, so if c lose() didn't take
28 // effect we'd get a second message practically instantaneously, wai ting 100ms should be ok.
29 if (window.testRunner)
30 testRunner.notifyDone();
31 }, 100);
32 }, false);
33
34 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698