From 818738ce840be9e6c0463fe43dd40d392b5f6168 Mon Sep 17 00:00:00 2001 From: Todd Wolfson Date: Fri, 17 Mar 2017 08:21:37 -0700 Subject: [PATCH] :bug: Add toString support to remote functions --- lib/renderer/api/remote.js | 3 +++ spec/api-ipc-spec.js | 5 +++++ 2 files changed, 8 insertions(+) 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 () {