Skip to content

Commit a7ba592

Browse files
committed
buffer: add @@toStringTag to Blob
This commit adds the toStringTag to the Blob class to match the behavior of Chrome and Firefox. PR-URL: #37336 Fixes: #37337 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0177d4c commit a7ba592

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/internal/blob.js

+7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
const {
44
ArrayFrom,
5+
ObjectDefineProperty,
56
ObjectSetPrototypeOf,
67
PromiseResolve,
78
RegExpPrototypeTest,
89
StringPrototypeToLowerCase,
910
Symbol,
1011
SymbolIterator,
12+
SymbolToStringTag,
1113
Uint8Array,
1214
} = primordials;
1315

@@ -217,6 +219,11 @@ class Blob extends JSTransferable {
217219
}
218220
}
219221

222+
ObjectDefineProperty(Blob.prototype, SymbolToStringTag, {
223+
configurable: true,
224+
value: 'Blob',
225+
});
226+
220227
InternalBlob.prototype.constructor = Blob;
221228
ObjectSetPrototypeOf(
222229
InternalBlob.prototype,

test/parallel/test-blob.js

+11
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,14 @@ assert.throws(() => new Blob(['test', 1]), {
184184
const b = new Blob(['hello'], { type: '\x01' });
185185
assert.strictEqual(b.type, '');
186186
}
187+
188+
{
189+
const descriptor =
190+
Object.getOwnPropertyDescriptor(Blob.prototype, Symbol.toStringTag);
191+
assert.deepStrictEqual(descriptor, {
192+
configurable: true,
193+
enumerable: false,
194+
value: 'Blob',
195+
writable: false
196+
});
197+
}

0 commit comments

Comments
 (0)