Merge pull request #6369 from electron/remote-object-with-no-constructor

Handle remote arguments with no constructor
This commit is contained in:
Cheng Zhao 2016-07-07 09:47:46 +09:00 committed by GitHub
commit 0a64d6ee30
3 changed files with 13 additions and 2 deletions

View file

@ -60,7 +60,7 @@ var wrapArgs = function (args, visited) {
ret = {
type: 'object',
name: value.constructor.name,
name: value.constructor != null ? value.constructor.name : '',
members: []
}
for (prop in value) {

View file

@ -31,9 +31,13 @@ describe('ipc module', function () {
it('should work when object has no prototype', function () {
var a = remote.require(path.join(fixtures, 'module', 'no-prototype.js'))
assert.equal(a.foo.constructor.name, '')
assert.equal(a.foo.bar, 'baz')
assert.equal(a.foo.baz, false)
assert.equal(a.bar, 1234)
assert.equal(a.anonymous.constructor.name, '')
assert.equal(a.getConstructorName(Object.create(null)), '')
assert.equal(a.getConstructorName(new (class {})), '')
})
it('should search module from the user app', function () {

View file

@ -1,4 +1,11 @@
const foo = Object.create(null)
foo.bar = 'baz'
foo.baz = false
module.exports = {foo: foo, bar: 1234}
module.exports = {
foo: foo,
bar: 1234,
anonymous: new (class {}),
getConstructorName: function (value) {
return value.constructor.name
}
}