Issue 1:
Electron version: 1.7.3

Operating system: Windows 10

Expected behavior

ipc message from parent to child webview should deliver while both webPreferences['contextIsolation'] = true and webPreferences['sandbox'] = true

Actual behavior

When both webPreferences['contextIsolation'] = true and webPreferences['sandbox'] = true, the ipc message cant deliver from parent to child webview. However, the ipc message delivers without webPreferences['contextIsolation'] = true

How to reproduce

main.js =>

const {app, BrowserWindow, ipcMain} = require('electron')

const path = require('path')

const url = require('url');

app.once('ready', () => {

let mainWin = new BrowserWindow({

show: true

});

mainWin.webContents.on('will-attach-webview', (event, webPreferences, params) => {

// If webPreferences['contextIsolation'] commented out, then you can find the message from child_new.js

webPreferences['contextIsolation'] = true;
webPreferences['sandbox'] = true;

});

mainWin.loadURL(url.format({

pathname: path.join(__dirname, './parent_new.html'),

search: 'url=child_new.html',

protocol: 'file:',

slashes: true

}));

})

=> parent_new.html

<title>Preload Scripts</title>

Open the webview's dev tools
<script>
let url = window.location.href;
var webview = document.createElement("webview");
document.body.appendChild(webview);
webview.setAttribute("id", "webview");
webview.setAttribute("src", url.substring(url.indexOf("=") + 1));

webview.setAttribute("preload", "./child_new.js");
require('./child_new');

webview.addEventListener("ipc-message", function(event) {
console.log('received message from child webview');
// some message received from the webview
webview.send('ipc-parent-to-child', event);
});
</script>
</body>

child_new.js =>

const { ipcRenderer: ipc } = require('electron');

console.log('Hey, this is being run in the context of the webview renderer process');

document.addEventListener('DOMContentLoaded', function(event) {

ipc.sendToHost('renderer_to_main',"please find me : child => parent => child ");

ipc.on('ipc-parent-to-child', (event, props) => {
// This message should show while webPreferences['contextIsolation'] = true and webPreferences['sandbox'] = true
// But this message show ONLY with webPreferences['sandbox'] = true
console.log(`Message received from webview ${JSON.stringify(props)}`);
});

});

child_new.html =>

<html>
<head> </head> <body>
<p id="findMe">
Hello from inside the webview.
</p>
</body> </html>

Issue 2:
Electron version: 1.8.2

Operating system: MacOS, Windows10

Expected behavior

ipc messages from the main process should be sent to the renderer process when both sandbox and contextIsolation are set.

Actual behavior

ipc messages sent in listeners to webview events are not visible in the renderer process.

How to reproduce

$ git clone https://gist.github.com/4f6c4450cff194838e746ce23e60116d.git
$ cd 4f6c4450cff194838e746ce23e60116d/
$ electron main.js

The devtools will open and the console will log one message. But the second message on the ipc ping channel is not observed.

Toggling either sandbox or contextIsolation to false allows the ping to travel to the renderer process. In the 1.7.X branch setting both values to true still allows the message to pass through successfully.