Merge pull request #9240 from electron/backport-remote-fixes

Backport 1.4 remote module bug fixes to 1.3
This commit is contained in:
Kevin Sawicki
2017-04-20 14:49:50 -07:00
committed by GitHub
4 changed files with 25 additions and 7 deletions

View File

@@ -95,6 +95,8 @@ const wrapArgs = function (args, visited) {
// The |ref| will be kept referenced by |members|.
// This matches |getObjectMemebers| in rpc-server.
const setObjectMembers = function (ref, object, metaId, members) {
if (!Array.isArray(members)) return
for (let member of members) {
if (object.hasOwnProperty(member.name)) continue
@@ -165,6 +167,11 @@ const proxyFunctionProperties = function (remoteMemberFunction, metaId, name) {
}
return new Proxy(remoteMemberFunction, {
set: (target, property, value, receiver) => {
if (property !== 'ref') loadRemoteProperties()
target[property] = value
return true
},
get: (target, property, receiver) => {
if (!target.hasOwnProperty(property)) loadRemoteProperties()
return target[property]

View File

@@ -69,6 +69,10 @@ describe('ipc module', function () {
assert.ok(Object.keys(a.foo).includes('bar'))
assert.ok(Object.keys(a.foo).includes('nested'))
assert.ok(Object.keys(a.foo).includes('method1'))
a = remote.require(path.join(fixtures, 'module', 'function-with-missing-properties.js')).setup()
assert.equal(a.bar(), true)
assert.equal(a.bar.baz, undefined)
})
it('should work with static class members', function () {

View File

@@ -94,13 +94,7 @@ describe('chromium feature', function () {
})
describe('navigator.mediaDevices', function () {
if (process.env.TRAVIS === 'true') {
return
}
if (isCI && process.platform === 'linux') {
return
}
if (isCI && process.platform === 'win32') {
if (isCI) {
return
}

View File

@@ -0,0 +1,13 @@
exports.setup = function () {
const foo = {}
foo.bar = function () {
return delete foo.bar.baz && delete foo.bar
}
foo.bar.baz = function () {
return 3
}
return foo
}