Bug 1735858 [wpt PR 31247] - App history: make it mostly nonfunctional for opaque...
[gecko.git] / testing / web-platform / tests / encoding / textdecoder-arguments.any.js
blobf469dcd30eaf877ffb2d6772a1862800c241f681
1 // META: title=Encoding API: TextDecoder decode() optional arguments
3 test(t => {
4   const decoder = new TextDecoder();
6   // Just passing nothing.
7   assert_equals(
8     decoder.decode(undefined), '',
9     'Undefined as first arg should decode to empty string');
11   // Flushing an incomplete sequence.
12   decoder.decode(new Uint8Array([0xc9]), {stream: true});
13   assert_equals(
14     decoder.decode(undefined), '\uFFFD',
15     'Undefined as first arg should flush the stream');
17 }, 'TextDecoder decode() with explicit undefined');
19 test(t => {
20   const decoder = new TextDecoder();
22   // Just passing nothing.
23   assert_equals(
24     decoder.decode(undefined, undefined), '',
25     'Undefined as first arg should decode to empty string');
27   // Flushing an incomplete sequence.
28   decoder.decode(new Uint8Array([0xc9]), {stream: true});
29   assert_equals(
30     decoder.decode(undefined, undefined), '\uFFFD',
31     'Undefined as first arg should flush the stream');
33 }, 'TextDecoder decode() with undefined and undefined');
35 test(t => {
36   const decoder = new TextDecoder();
38   // Just passing nothing.
39   assert_equals(
40     decoder.decode(undefined, {}), '',
41     'Undefined as first arg should decode to empty string');
43   // Flushing an incomplete sequence.
44   decoder.decode(new Uint8Array([0xc9]), {stream: true});
45   assert_equals(
46     decoder.decode(undefined, {}), '\uFFFD',
47     'Undefined as first arg should flush the stream');
49 }, 'TextDecoder decode() with undefined and options');