summaryrefslogtreecommitdiffstats
path: root/dom/streams/test/xpcshell/response.js
blob: ead1be527f1955d96eb18b34aa2a509f510bbe23 (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 (test) {
  return new Response(new Blob([], { type: "text/plain" })).body.cancel();
});

add_task(function (test) {
  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 (test) {
  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, value }) {
    if (!done) {
      return reader.read().then(readMore);
    }
    return undefined;
  });
  return closedPromise;
});