Skip to content

Commit

Permalink
[wpt] Fix response-cancel-stream.html flakiness
Browse files Browse the repository at this point in the history
Currently the test expects that one one read call makes the response
body stream closed, which is not always true. With this change, the test
reads the body stream till the end.

Bug: 603396
Change-Id: I41b6fbb465945702c6374835f2b4f632a1bc2c5c
Reviewed-on: https://chromium-review.googlesource.com/648869
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499445}
  • Loading branch information
yutakahirano authored and chromium-wpt-export-bot committed Sep 4, 2017
1 parent fc6ae44 commit a8da658
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions fetch/api/response/response-cancel-stream.html
Expand Up @@ -12,7 +12,6 @@
<body>
<script src="../resources/utils.js"></script>
<script>

promise_test(function(test) {
return new Response(new Blob([], { "type" : "text/plain" })).body.cancel();
}, "Cancelling a starting blob Response stream");
Expand Down Expand Up @@ -51,16 +50,19 @@
}, "Cancelling a loading Response stream");

promise_test(function() {
async function readAll(reader) {
while (true) {
const {value, done} = await reader.read();
if (done)
return;
}
}

return fetch(RESOURCES_DIR + "top.txt").then(function(response) {
var reader = response.body.getReader();
var closedPromise = reader.closed.then(function() {
return reader.cancel();
});
reader.read();
return closedPromise;
return readAll(reader).then(() => reader.cancel());
});
}, "Cancelling a closed Response stream");

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

0 comments on commit a8da658

Please sign in to comment.