Browse Source

Add tests for setting remote function properties

Kevin Sawicki 8 years ago
parent
commit
ec44a5d198
3 changed files with 16 additions and 0 deletions
  1. 2 0
      lib/renderer/api/remote.js
  2. 4 0
      spec/api-ipc-spec.js
  3. 10 0
      spec/fixtures/module/property.js

+ 2 - 0
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

+ 4 - 0
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

+ 10 - 0
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}`
+}