11cb0ef41Sopenharmony_ci// META: title=Encoding API: TextDecoder decode() optional arguments 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_citest(t => { 41cb0ef41Sopenharmony_ci const decoder = new TextDecoder(); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci // Just passing nothing. 71cb0ef41Sopenharmony_ci assert_equals( 81cb0ef41Sopenharmony_ci decoder.decode(undefined), '', 91cb0ef41Sopenharmony_ci 'Undefined as first arg should decode to empty string'); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci // Flushing an incomplete sequence. 121cb0ef41Sopenharmony_ci decoder.decode(new Uint8Array([0xc9]), {stream: true}); 131cb0ef41Sopenharmony_ci assert_equals( 141cb0ef41Sopenharmony_ci decoder.decode(undefined), '\uFFFD', 151cb0ef41Sopenharmony_ci 'Undefined as first arg should flush the stream'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci}, 'TextDecoder decode() with explicit undefined'); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_citest(t => { 201cb0ef41Sopenharmony_ci const decoder = new TextDecoder(); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ci // Just passing nothing. 231cb0ef41Sopenharmony_ci assert_equals( 241cb0ef41Sopenharmony_ci decoder.decode(undefined, undefined), '', 251cb0ef41Sopenharmony_ci 'Undefined as first arg should decode to empty string'); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci // Flushing an incomplete sequence. 281cb0ef41Sopenharmony_ci decoder.decode(new Uint8Array([0xc9]), {stream: true}); 291cb0ef41Sopenharmony_ci assert_equals( 301cb0ef41Sopenharmony_ci decoder.decode(undefined, undefined), '\uFFFD', 311cb0ef41Sopenharmony_ci 'Undefined as first arg should flush the stream'); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci}, 'TextDecoder decode() with undefined and undefined'); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_citest(t => { 361cb0ef41Sopenharmony_ci const decoder = new TextDecoder(); 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci // Just passing nothing. 391cb0ef41Sopenharmony_ci assert_equals( 401cb0ef41Sopenharmony_ci decoder.decode(undefined, {}), '', 411cb0ef41Sopenharmony_ci 'Undefined as first arg should decode to empty string'); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci // Flushing an incomplete sequence. 441cb0ef41Sopenharmony_ci decoder.decode(new Uint8Array([0xc9]), {stream: true}); 451cb0ef41Sopenharmony_ci assert_equals( 461cb0ef41Sopenharmony_ci decoder.decode(undefined, {}), '\uFFFD', 471cb0ef41Sopenharmony_ci 'Undefined as first arg should flush the stream'); 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci}, 'TextDecoder decode() with undefined and options'); 50