mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Merge pull request #9240 from electron/backport-remote-fixes
Backport 1.4 remote module bug fixes to 1.3
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
13
spec/fixtures/module/function-with-missing-properties.js
vendored
Normal file
13
spec/fixtures/module/function-with-missing-properties.js
vendored
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user