| James Graham | c60e488 | 2014-05-09 10:24:03 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>EventSource: lines and data parsing</title> |
| 5 | <meta rel=help href="http://dev.w3.org/html5/eventsource/#event-stream-interpretation"> |
| 6 | <meta rel=assert title="If the line is empty (a blank line) Dispatch the event, as defined below."> |
| 7 | <meta rel=assert title="If the line starts with a U+003A COLON character (:) Ignore the line."> |
| 8 | <meta rel=assert title="If the line contains a U+003A COLON character (:) |
| 9 | Collect the characters on the line before the first U+003A COLON character (:), and let field be that string. |
| 10 | Collect the characters on the line after the first U+003A COLON character (:), and let value be that string. If value starts with a U+0020 SPACE character, remove it from value. |
| 11 | Process the field using the steps described below, using field as the field name and value as the field value. |
| 12 | "> |
| 13 | <meta rel=assert title="Otherwise, the string is not empty but does not contain a U+003A COLON character (:) |
| 14 | Process the field using the steps described below, using the whole line as the field name, and the empty string as the field value. |
| 15 | "> |
| 16 | |
| 17 | <script src="/resources/testharness.js"></script> |
| 18 | <script src="/resources/testharnessreport.js"></script> |
| 19 | </head> |
| 20 | <body> |
| 21 | <div id="log"></div> |
| 22 | <script> |
| 23 | var test = async_test(document.title); |
| 24 | test.step(function() { |
| 25 | var source = new EventSource("resources/message2.py"), |
| 26 | counter = 0; |
| 27 | source.onmessage = test.step_func(function(e) { |
| 28 | if(counter == 0) { |
| 29 | assert_equals(e.data,"msg\nmsg"); |
| 30 | } else if(counter == 1) { |
| 31 | assert_equals(e.data,""); |
| 32 | } else if(counter == 2) { |
| 33 | assert_equals(e.data,"end"); |
| 34 | source.close(); |
| 35 | test.done(); |
| 36 | } else { |
| 37 | assert_unreached(); |
| 38 | } |
| 39 | counter++; |
| 40 | }); |
| 41 | }); |
| 42 | </script> |
| 43 | </body> |
| 44 | </html> |