From f6befbe7647df93fd6ef27cac25c5da542a62f88 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 16 Mar 2017 14:21:23 -0300 Subject: [PATCH] Expose lib/renderer/api/remote.js to sandboxed renderer --- lib/renderer/api/remote.js | 5 ++++- lib/sandboxed_renderer/api/exports/electron.js | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index 8277e16..dea3f40 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -1,6 +1,9 @@ 'use strict' -const {Buffer} = require('buffer') +// Note: Don't use destructuring assignment for `Buffer`, or we'll hit a +// browserify bug that makes the statement invalid, throwing an error in +// sandboxed renderer. +const Buffer = require('buffer').Buffer const v8Util = process.atomBinding('v8_util') const {ipcRenderer, isPromise, CallbacksRegistry} = require('electron') const resolvePromise = Promise.resolve.bind(Promise) diff --git a/lib/sandboxed_renderer/api/exports/electron.js b/lib/sandboxed_renderer/api/exports/electron.js index 3a09caa..2a1d341 100644 --- a/lib/sandboxed_renderer/api/exports/electron.js +++ b/lib/sandboxed_renderer/api/exports/electron.js @@ -4,5 +4,21 @@ Object.defineProperties(exports, { get: function () { return require('../ipc-renderer') } + }, + remote: { + enumerable: true, + get: function () { + return require('../../../renderer/api/remote') + } + }, + CallbacksRegistry: { + get: function () { + return require('../../../common/api/callbacks-registry') + } + }, + isPromise: { + get: function () { + return require('../../../common/api/is-promise') + } } }) -- 2.7.4