From ec44a5d1986508ae0b08383b699112c5d27f72d3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Aug 2016 14:21:50 -0700 Subject: [PATCH] Add tests for setting remote function properties --- lib/renderer/api/remote.js | 2 ++ spec/api-ipc-spec.js | 4 ++++ spec/fixtures/module/property.js | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index af741f924f32..d29be811b41e 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -154,6 +154,8 @@ const setObjectPrototype = function (ref, object, metaId, descriptor) { // Wrap function in Proxy for accessing remote properties const proxyFunctionProperties = function (remoteMemberFunction, metaId, name) { let loaded = false + + // Lazily load function properties const loadRemoteProperties = () => { if (loaded) return loaded = true diff --git a/spec/api-ipc-spec.js b/spec/api-ipc-spec.js index 51147888e1ae..2e6fa0d2deeb 100644 --- a/spec/api-ipc-spec.js +++ b/spec/api-ipc-spec.js @@ -148,6 +148,10 @@ describe('ipc module', function () { assert.equal(property.property, 1127) property.property = 1007 assert.equal(property.property, 1007) + assert.equal(property.getFunctionProperty(), 'foo-browser') + property.func.property = 'bar' + assert.equal(property.getFunctionProperty(), 'bar-browser') + var property2 = remote.require(path.join(fixtures, 'module', 'property.js')) assert.equal(property2.property, 1007) property.property = 1127 diff --git a/spec/fixtures/module/property.js b/spec/fixtures/module/property.js index 88e596f73083..e570ca9351a9 100644 --- a/spec/fixtures/module/property.js +++ b/spec/fixtures/module/property.js @@ -1 +1,11 @@ exports.property = 1127 + +function func () { + +} +func.property = 'foo' +exports.func = func + +exports.getFunctionProperty = () => { + return `${func.property}-${process.type}` +}