11cb0ef41Sopenharmony_ci// META: global=window,worker 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci'use strict'; 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst badChunks = [ 61cb0ef41Sopenharmony_ci { 71cb0ef41Sopenharmony_ci name: 'undefined', 81cb0ef41Sopenharmony_ci value: undefined 91cb0ef41Sopenharmony_ci }, 101cb0ef41Sopenharmony_ci { 111cb0ef41Sopenharmony_ci name: 'null', 121cb0ef41Sopenharmony_ci value: null 131cb0ef41Sopenharmony_ci }, 141cb0ef41Sopenharmony_ci { 151cb0ef41Sopenharmony_ci name: 'numeric', 161cb0ef41Sopenharmony_ci value: 3.14 171cb0ef41Sopenharmony_ci }, 181cb0ef41Sopenharmony_ci { 191cb0ef41Sopenharmony_ci name: 'object, not BufferSource', 201cb0ef41Sopenharmony_ci value: {} 211cb0ef41Sopenharmony_ci }, 221cb0ef41Sopenharmony_ci { 231cb0ef41Sopenharmony_ci name: 'array', 241cb0ef41Sopenharmony_ci value: [65] 251cb0ef41Sopenharmony_ci } 261cb0ef41Sopenharmony_ci]; 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_cifor (const chunk of badChunks) { 291cb0ef41Sopenharmony_ci promise_test(async t => { 301cb0ef41Sopenharmony_ci const tds = new TextDecoderStream(); 311cb0ef41Sopenharmony_ci const reader = tds.readable.getReader(); 321cb0ef41Sopenharmony_ci const writer = tds.writable.getWriter(); 331cb0ef41Sopenharmony_ci const writePromise = writer.write(chunk.value); 341cb0ef41Sopenharmony_ci const readPromise = reader.read(); 351cb0ef41Sopenharmony_ci await promise_rejects_js(t, TypeError, writePromise, 'write should reject'); 361cb0ef41Sopenharmony_ci await promise_rejects_js(t, TypeError, readPromise, 'read should reject'); 371cb0ef41Sopenharmony_ci }, `chunk of type ${chunk.name} should error the stream`); 381cb0ef41Sopenharmony_ci} 39