diff --git a/lib/internal/blob.js b/lib/internal/blob.js index accfdf9539c1d2..9b60171e65aef0 100644 --- a/lib/internal/blob.js +++ b/lib/internal/blob.js @@ -2,12 +2,14 @@ const { ArrayFrom, + ObjectDefineProperty, ObjectSetPrototypeOf, PromiseResolve, RegExpPrototypeTest, StringPrototypeToLowerCase, Symbol, SymbolIterator, + SymbolToStringTag, Uint8Array, } = primordials; @@ -219,6 +221,11 @@ class Blob extends JSTransferable { } } +ObjectDefineProperty(Blob.prototype, SymbolToStringTag, { + configurable: true, + value: 'Blob', +}); + InternalBlob.prototype.constructor = Blob; ObjectSetPrototypeOf( InternalBlob.prototype, diff --git a/test/parallel/test-blob.js b/test/parallel/test-blob.js index b32cacdda723a9..eef9d3dbd1e1d4 100644 --- a/test/parallel/test-blob.js +++ b/test/parallel/test-blob.js @@ -185,3 +185,14 @@ assert.throws(() => new Blob(['test', 1]), { const b = new Blob(['hello'], { type: '\x01' }); assert.strictEqual(b.type, ''); } + +{ + const descriptor = + Object.getOwnPropertyDescriptor(Blob.prototype, Symbol.toStringTag); + assert.deepStrictEqual(descriptor, { + configurable: true, + enumerable: false, + value: 'Blob', + writable: false + }); +}