<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Fetch: retrieve response's body progressively</title>
    <meta name="help" href="https://fetch.spec.whatwg.org/#main-fetch">
    <meta name="help" href="https://fetch.spec.whatwg.org/#http-fetch">
    <meta name="author" title="Canon Research France" href="https://www.crf.canon.fr">
    <script src="/js-test-resources/testharness.js"></script>
    <script src="/js-test-resources/testharnessreport.js"></script>
  </head>
  <body>
    <script>
        
var test = async_test("Ensuring that fetch response body promise is not fulfilled when window is closed");
test.step(function() {
    var url = "/resources/download-json-with-delay.py?iteration=5&delay=1000";
    fetch(url).then(test.step_func(function(response) {
        assert_equals(response.status, 200);
        response.text().then(test.step_func(function(buffer) {
            assert_unreached();
        }), test.step_func(function() {
            assert_unreached();
        }));
        setTimeout(function() { test.done(); }, 100);
    }), test.step_func(function() {
        assert_unreached();
    }));
});

    </script>
  </body>
</html>
