diff --git a/lib/browser/rpc-server.js b/lib/browser/rpc-server.js index fe264cceee..fa9841aeec 100644 --- a/lib/browser/rpc-server.js +++ b/lib/browser/rpc-server.js @@ -6,6 +6,8 @@ const {ipcMain, isPromise} = electron const objectsRegistry = require('./objects-registry') +const hasProp = {}.hasOwnProperty + // The internal properties of Function. const FUNCTION_PROPERTIES = [ 'length', 'name', 'arguments', 'caller', 'prototype' @@ -67,7 +69,7 @@ let valueToMeta = function (sender, value, optimizeSimpleObject = false) { meta.type = 'date' } else if (isPromise(value)) { meta.type = 'promise' - } else if (value.hasOwnProperty('callee') && value.length != null) { + } else if (hasProp.call(value, 'callee') && value.length != null) { // Treat the arguments object as array. meta.type = 'array' } else if (optimizeSimpleObject && v8Util.getHiddenValue(value, 'simple')) { diff --git a/spec/api-ipc-spec.js b/spec/api-ipc-spec.js index 102b23ece5..22c2edde08 100644 --- a/spec/api-ipc-spec.js +++ b/spec/api-ipc-spec.js @@ -32,6 +32,13 @@ describe('ipc module', function () { assert.equal(a.id, 1127) }) + it.only('should work when object has no prototype', function () { + var a = remote.require(path.join(fixtures, 'module', 'no-prototype.js')) + assert.equal(a.foo.bar, 'baz') + assert.equal(a.foo.baz, false) + assert.equal(a.bar, 1234) + }) + it('should search module from the user app', function () { comparePaths(path.normalize(remote.process.mainModule.filename), path.resolve(__dirname, 'static', 'main.js')) comparePaths(path.normalize(remote.process.mainModule.paths[0]), path.resolve(__dirname, 'static', 'node_modules')) diff --git a/spec/fixtures/module/no-prototype.js b/spec/fixtures/module/no-prototype.js new file mode 100644 index 0000000000..f298925b80 --- /dev/null +++ b/spec/fixtures/module/no-prototype.js @@ -0,0 +1,4 @@ +const foo = Object.create(null) +foo.bar = 'baz' +foo.baz = false +module.exports = {foo: foo, bar: 1234}