diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index 8277e16c2182..60a34785be75 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -175,6 +175,9 @@ const proxyFunctionProperties = function (remoteMemberFunction, metaId, name) { return true }, get: (target, property, receiver) => { + if (property === 'toString' && typeof target.toString === 'function') { + return target.toString.bind(target) + } if (!target.hasOwnProperty(property)) loadRemoteProperties() return target[property] }, diff --git a/spec/api-ipc-spec.js b/spec/api-ipc-spec.js index e812eb5fef2a..f86d06507c1b 100644 --- a/spec/api-ipc-spec.js +++ b/spec/api-ipc-spec.js @@ -161,6 +161,11 @@ describe('ipc module', function () { assert.equal(typeof remote.clipboard.readText, 'function') assert.equal(typeof remote.shell.openExternal, 'function') }) + + it('returns toString() of original function via toString()', function () { + var readText = remote.clipboard.readText + assert(readText.toString().startsWith('function')) + }) }) describe('remote object in renderer', function () {