tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

textdecoder-arguments.any.js (1520B)


      1 // META: global=window,dedicatedworker,shadowrealm
      2 // META: title=Encoding API: TextDecoder decode() optional arguments
      3 
      4 test(t => {
      5  const decoder = new TextDecoder();
      6 
      7  // Just passing nothing.
      8  assert_equals(
      9    decoder.decode(undefined), '',
     10    'Undefined as first arg should decode to empty string');
     11 
     12  // Flushing an incomplete sequence.
     13  decoder.decode(new Uint8Array([0xc9]), {stream: true});
     14  assert_equals(
     15    decoder.decode(undefined), '\uFFFD',
     16    'Undefined as first arg should flush the stream');
     17 
     18 }, 'TextDecoder decode() with explicit undefined');
     19 
     20 test(t => {
     21  const decoder = new TextDecoder();
     22 
     23  // Just passing nothing.
     24  assert_equals(
     25    decoder.decode(undefined, undefined), '',
     26    'Undefined as first arg should decode to empty string');
     27 
     28  // Flushing an incomplete sequence.
     29  decoder.decode(new Uint8Array([0xc9]), {stream: true});
     30  assert_equals(
     31    decoder.decode(undefined, undefined), '\uFFFD',
     32    'Undefined as first arg should flush the stream');
     33 
     34 }, 'TextDecoder decode() with undefined and undefined');
     35 
     36 test(t => {
     37  const decoder = new TextDecoder();
     38 
     39  // Just passing nothing.
     40  assert_equals(
     41    decoder.decode(undefined, {}), '',
     42    'Undefined as first arg should decode to empty string');
     43 
     44  // Flushing an incomplete sequence.
     45  decoder.decode(new Uint8Array([0xc9]), {stream: true});
     46  assert_equals(
     47    decoder.decode(undefined, {}), '\uFFFD',
     48    'Undefined as first arg should flush the stream');
     49 
     50 }, 'TextDecoder decode() with undefined and options');