Merge pull request #6369 from electron/remote-object-with-no-constructor
Handle remote arguments with no constructor
This commit is contained in:
commit
0a64d6ee30
3 changed files with 13 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
9
spec/fixtures/module/no-prototype.js
vendored
9
spec/fixtures/module/no-prototype.js
vendored
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue