summaryrefslogtreecommitdiffstats
path: root/dom/streams/test/xpcshell/response.js
blob: 884cbfea295264b7b1d94e85ea6b2c71e7f13237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"use strict";

add_task(async function () {
  return new Response(new Blob([], { type: "text/plain" })).body.cancel();
});

add_task(function () {
  var response = new Response(
    new Blob(["This is data"], { type: "text/plain" })
  );
  var reader = response.body.getReader();
  reader.read();
  return reader.cancel();
});

add_task(function () {
  var response = new Response(new Blob(["T"], { type: "text/plain" }));
  var reader = response.body.getReader();

  var closedPromise = reader.closed.then(function () {
    return reader.cancel();
  });
  reader.read().then(function readMore({ done }) {
    if (!done) {
      return reader.read().then(readMore);
    }
    return undefined;
  });
  return closedPromise;
});