• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// META: global=window,worker
2// META: script=resources/readable-stream-from-array.js
3// META: script=resources/readable-stream-to-array.js
4
5'use strict';
6
7const inputBytes = [229];
8
9promise_test(async () => {
10  const input = readableStreamFromArray([new Uint8Array(inputBytes)]);
11  const output = input.pipeThrough(new TextDecoderStream());
12  const array = await readableStreamToArray(output);
13  assert_array_equals(array, ['\uFFFD'], 'array should have one element');
14}, 'incomplete input with error mode "replacement" should end with a ' +
15   'replacement character');
16
17promise_test(async t => {
18  const input = readableStreamFromArray([new Uint8Array(inputBytes)]);
19  const output = input.pipeThrough(new TextDecoderStream(
20      'utf-8', {fatal: true}));
21  const reader = output.getReader();
22  await promise_rejects_js(t, TypeError, reader.read(),
23                        'read should reject');
24}, 'incomplete input with error mode "fatal" should error the stream');
25