diff --git a/lib/internal/blob.js b/lib/internal/blob.js index 82b375da783fe1..a4d89e126617fe 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; @@ -217,6 +219,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 795d4bb6fbdff5..fdcc0177279dad 100644 --- a/test/parallel/test-blob.js +++ b/test/parallel/test-blob.js @@ -184,3 +184,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 + }); +}