Re: [eventsource-tests][stale-awaiting-submitter-response-tests] new test for EventSource + request cancellation (#285)

@sideshowbarker ,
1) i do not know hot wo modify changes in this pull request
the updated file should look like this:
```
<!DOCTYPE html>
<html>
  <head>
    <title>EventSource: request cancellation</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
    <div id="log"></div>
    <script>
      var test = async_test(null, {timeout: 5000});
      var url = "message.py?sleep=1000&message=" + encodeURIComponent("retry:1000\ndata:abc\n\n");
      var es = new EventSource(url);
      var lastEventTime = 0;
      var lastEventType = "";
      var readyStateAtLastEvent = -1;
      es.onmessage = 
      es.onerror = 
      es.onopen = function (event) {
        lastEventTime = (new Date()).getTime();
        lastEventType = event.type;
        readyStateAtLastEvent = es.readyState;
      };
      setTimeout(function () {
        if (typeof window.stop === "function") {
          window.stop();
        }
      }, 100);
      setTimeout(function () {
        test.step(function () {
          var isActive = ((new Date()).getTime() - lastEventTime) < 2500;
          if (es.readyState === EventSource.CLOSED) {
            var message = "In case EventSource was stopped, it should not be active, and the last event should be an error event.";
            assert_true(!isActive, message);
            assert_true(lastEventType === "error", message);
            assert_true(readyStateAtLastEvent === EventSource.CLOSED, message);
          } else {
            assert_true(isActive, "EventSource is active, but readyState is EventSource.CLOSED.");
          }
        });
        es.close();
        test.done();
      }, 4000);
    </script>
  </body>
</html>
```

and somebody needs to add `sleep` to message.py.
I do not know Python and cannot install it.


View on GitHub: https://github.com/w3c/web-platform-tests/pull/285#issuecomment-47893559

Received on Thursday, 3 July 2014 11:08:51 UTC