|
@@ -3,6 +3,7 @@
|
|
|
const electron = require('electron')
|
|
|
const { EventEmitter } = require('events')
|
|
|
const fs = require('fs')
|
|
|
+const util = require('util')
|
|
|
const v8Util = process.atomBinding('v8_util')
|
|
|
const eventBinding = process.atomBinding('event')
|
|
|
|
|
@@ -495,12 +496,14 @@ ipcMainUtils.handle('ELECTRON_BROWSER_CLIPBOARD_WRITE_FIND_TEXT', function (even
|
|
|
return electron.clipboard.writeFindText(text)
|
|
|
})
|
|
|
|
|
|
-const getPreloadScript = function (preloadPath) {
|
|
|
+const readFile = util.promisify(fs.readFile)
|
|
|
+
|
|
|
+const getPreloadScript = async function (preloadPath) {
|
|
|
let preloadSrc = null
|
|
|
let preloadError = null
|
|
|
if (preloadPath) {
|
|
|
try {
|
|
|
- preloadSrc = fs.readFileSync(preloadPath).toString()
|
|
|
+ preloadSrc = (await readFile(preloadPath)).toString()
|
|
|
} catch (err) {
|
|
|
preloadError = errorUtils.serialize(err)
|
|
|
}
|
|
@@ -508,14 +511,14 @@ const getPreloadScript = function (preloadPath) {
|
|
|
return { preloadPath, preloadSrc, preloadError }
|
|
|
}
|
|
|
|
|
|
-ipcMainInternal.on('ELECTRON_BROWSER_SANDBOX_LOAD', function (event) {
|
|
|
+ipcMainUtils.handle('ELECTRON_BROWSER_SANDBOX_LOAD', async function (event) {
|
|
|
const preloadPaths = [
|
|
|
...(event.sender.session ? event.sender.session.getPreloads() : []),
|
|
|
event.sender._getPreloadPath()
|
|
|
]
|
|
|
|
|
|
- event.returnValue = {
|
|
|
- preloadScripts: preloadPaths.map(path => getPreloadScript(path)),
|
|
|
+ return {
|
|
|
+ preloadScripts: await Promise.all(preloadPaths.map(path => getPreloadScript(path))),
|
|
|
isRemoteModuleEnabled: isRemoteModuleEnabled(event.sender),
|
|
|
isWebViewTagEnabled: guestViewManager.isWebViewTagEnabled(event.sender),
|
|
|
process: {
|