mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
chore(ext/web): use a non-resource stream for textDecoderStreamCleansUpOnCancel (#21181)
Follow-up fix to #21074
This commit is contained in:
parent
25950baed3
commit
65b9150f83
1 changed files with 16 additions and 4 deletions
|
@ -1,5 +1,10 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assert, assertEquals, assertThrows } from "./test_util.ts";
|
import {
|
||||||
|
assert,
|
||||||
|
assertEquals,
|
||||||
|
assertStrictEquals,
|
||||||
|
assertThrows,
|
||||||
|
} from "./test_util.ts";
|
||||||
|
|
||||||
Deno.test(function btoaSuccess() {
|
Deno.test(function btoaSuccess() {
|
||||||
const text = "hello world";
|
const text = "hello world";
|
||||||
|
@ -323,9 +328,15 @@ Deno.test(function binaryEncode() {
|
||||||
Deno.test(
|
Deno.test(
|
||||||
{ permissions: { read: true } },
|
{ permissions: { read: true } },
|
||||||
async function textDecoderStreamCleansUpOnCancel() {
|
async function textDecoderStreamCleansUpOnCancel() {
|
||||||
const filename = "cli/tests/testdata/assets/hello.txt";
|
let cancelled = false;
|
||||||
const file = await Deno.open(filename);
|
const readable = new ReadableStream({
|
||||||
const readable = file.readable.pipeThrough(new TextDecoderStream());
|
start: (controller) => {
|
||||||
|
controller.enqueue(new Uint8Array(12));
|
||||||
|
},
|
||||||
|
cancel: () => {
|
||||||
|
cancelled = true;
|
||||||
|
},
|
||||||
|
}).pipeThrough(new TextDecoderStream());
|
||||||
const chunks = [];
|
const chunks = [];
|
||||||
for await (const chunk of readable) {
|
for await (const chunk of readable) {
|
||||||
chunks.push(chunk);
|
chunks.push(chunk);
|
||||||
|
@ -334,5 +345,6 @@ Deno.test(
|
||||||
}
|
}
|
||||||
assertEquals(chunks.length, 1);
|
assertEquals(chunks.length, 1);
|
||||||
assertEquals(chunks[0].length, 12);
|
assertEquals(chunks[0].length, 12);
|
||||||
|
assertStrictEquals(cancelled, true);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue