| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2979c58 commit 150c0f1
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,6 +87,15 @@ assert.throws(() => new Blob({}), { | |||
| 87 | 87 | })); | |
| 88 | 88 | } | |
| 89 | 89 | ||
| 90 | + { | ||
| 91 | + const b = new Blob(['hello', new Uint8Array([0xed, 0xa0, 0x88])]); | ||
| 92 | + assert.strictEqual(b.size, 8); | ||
| 93 | + b.text().then(common.mustCall((text) => { | ||
| 94 | + assert.strictEqual(text, 'hello\ufffd\ufffd\ufffd'); | ||
| 95 | + assert.strictEqual(text.length, 8); | ||
| 96 | + })); | ||
| 97 | + } | ||
| 98 | + | ||
| 90 | 99 | { | |
| 91 | 100 | const b = new Blob( | |
| 92 | 101 | [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ const { | |||
| 13 | 13 | } = require('stream/consumers'); | |
| 14 | 14 | ||
| 15 | 15 | const { | |
| 16 | + Readable, | ||
| 16 | 17 | PassThrough | |
| 17 | 18 | } = require('stream'); | |
| 18 | 19 | ||
@@ -73,6 +74,19 @@ const kArrayBuffer = | |||
| 73 | 74 | setTimeout(() => passthrough.end('there'), 10); | |
| 74 | 75 | } | |
| 75 | 76 | ||
| 77 | + { | ||
| 78 | + const readable = new Readable({ | ||
| 79 | + read() {} | ||
| 80 | + }); | ||
| 81 | + | ||
| 82 | + text(readable).then((data) => { | ||
| 83 | + assert.strictEqual(data, 'foo\ufffd\ufffd\ufffd'); | ||
| 84 | + }); | ||
| 85 | + | ||
| 86 | + readable.push(new Uint8Array([0x66, 0x6f, 0x6f, 0xed, 0xa0, 0x80])); | ||
| 87 | + readable.push(null); | ||
| 88 | + } | ||
| 89 | + | ||
| 76 | 90 | { | |
| 77 | 91 | const passthrough = new PassThrough(); | |
| 78 | 92 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,3 +191,11 @@ if (common.hasIntl) { | |||
| 191 | 191 | } | |
| 192 | 192 | ); | |
| 193 | 193 | } | |
| 194 | + | ||
| 195 | + // Test TextDecoder for incomplete UTF-8 byte sequence. | ||
| 196 | + { | ||
| 197 | + const decoder = new TextDecoder(); | ||
| 198 | + const chunk = new Uint8Array([0x66, 0x6f, 0x6f, 0xed]); | ||
| 199 | + const str = decoder.decode(chunk); | ||
| 200 | + assert.strictEqual(str, 'foo\ufffd'); | ||
| 201 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments