:bug: Add toString support to remote functions
authorTodd Wolfson <todd@twolfson.com>
Fri, 17 Mar 2017 15:21:37 +0000 (08:21 -0700)
committerTodd Wolfson <todd@twolfson.com>
Fri, 17 Mar 2017 15:21:37 +0000 (08:21 -0700)
lib/renderer/api/remote.js
spec/api-ipc-spec.js

index 8277e16..60a3478 100644 (file)
@@ -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]
     },
index e812eb5..f86d065 100644 (file)
@@ -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 () {