Skip to content

Commit b74cc91

Browse files
author
Andreu Botella
authored
Fix TextDecoderStream's behavior when processing the end of stream
This change fixes TextDecoderStream's "flush and enqueue" algorithm to handle the end of the stream in the same way as a call to TextDecoder's decode() method with no parameters. Tests: web-platform-tests/wpt#29481. Fixes #263.
1 parent 5c7f056 commit b74cc91

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

encoding.bs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,23 +1810,35 @@ steps:
18101810
<li><p>Let <var>output</var> be the <a for=/>I/O queue</a> of scalar values
18111811
« <a>end-of-queue</a> ».
18121812

1813-
<li><p>Let <var>result</var> be the result of <a>processing an item</a> with <a>end-of-queue</a>,
1814-
<var>decoder</var>'s <a for=TextDecoderCommon>decoder</a>, <var>decoder</var>'s
1815-
<a for=TextDecoderCommon>I/O queue</a>, <var>output</var>, and <var>decoder</var>'s
1816-
<a for=TextDecoderCommon>error mode</a>.
1817-
18181813
<li>
1819-
<p>If <var>result</var> is <a>finished</a>, then:
1814+
<p>While true:
18201815

18211816
<ol>
1822-
<li><p>Let <var>outputChunk</var> be the result of running <a>serialize I/O queue</a> with
1823-
<var>decoder</var> and <var>output</var>.
1817+
<li><p>Let <var>item</var> be the result of <a>reading</a> from <var>decoder</var>'s
1818+
<a for=TextDecoderCommon>I/O queue</a>.
18241819

1825-
<li><p>If <var>outputChunk</var> is non-empty, then <a for=TransformStream>enqueue</a>
1826-
<var>outputChunk</var> in <var>decoder</var>'s <a for=GenericTransformStream>transform</a>.
1827-
</ol>
1820+
<li><p>Let <var>result</var> be the result of <a>processing an item</a> with <var>item</var>,
1821+
<var>decoder</var>'s <a for=TextDecoderCommon>decoder</a>, <var>decoder</var>'s
1822+
<a for=TextDecoderCommon>I/O queue</a>, <var>output</var>, and <var>decoder</var>'s
1823+
<a for=TextDecoderCommon>error mode</a>.
18281824

1829-
<li><p>Otherwise, <a>throw</a> a {{TypeError}}.
1825+
<li>
1826+
<p>If <var>result</var> is <a>finished</a>, then:
1827+
1828+
<ol>
1829+
<li><p>Let <var>outputChunk</var> be the result of running <a>serialize I/O queue</a> with
1830+
<var>decoder</var> and <var>output</var>.
1831+
1832+
<li><p>If <var>outputChunk</var> is non-empty, then <a for=TransformStream>enqueue</a>
1833+
<var>outputChunk</var> in <var>decoder</var>'s <a for=GenericTransformStream>transform</a>.
1834+
1835+
<li><p>Return.
1836+
</ol>
1837+
</li>
1838+
1839+
<li><p>Otherwise, if <var>result</var> is <a>error</a>, <a>throw</a> a {{TypeError}}.
1840+
</ol>
1841+
</li>
18301842
</ol>
18311843

18321844

0 commit comments

Comments
 (0)