<ul dir="auto">
<li>Electron version: 1.7.3</li>
<li>Operating system: Windows 10</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">ipc message from parent to child webview should deliver while both webPreferences['contextIsolation'] = true and webPreferences['sandbox'] = true</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">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</p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto">main.js =&gt;</p>
<p dir="auto">const {app, BrowserWindow, ipcMain} = require('electron')<br>
const path = require('path')<br>
const url = require('url');</p>
<p dir="auto">app.once('ready', () =&gt; {</p>
<p dir="auto">let mainWin = new BrowserWindow({<br>
show: true<br>
});</p>
<p dir="auto">mainWin.webContents.on('will-attach-webview', (event, webPreferences, params) =&gt; {<br>
// If webPreferences['contextIsolation'] commented out, then you can find the message from child_new.js</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  webPreferences['contextIsolation'] = true;
  webPreferences['sandbox'] = true;"><pre class="notranslate"><code class="notranslate">  webPreferences['contextIsolation'] = true;
  webPreferences['sandbox'] = true;
</code></pre></div>
<p dir="auto">});</p>
<p dir="auto">mainWin.loadURL(url.format({<br>
pathname: path.join(__dirname, './parent_new.html'),<br>
search: 'url=child_new.html',<br>
protocol: 'file:',<br>
slashes: true<br>
}));<br>
})</p>
<p dir="auto">=&gt; parent_new.html</p>

    
      &lt;title&gt;Preload Scripts&lt;/title&gt;
    
    
      Open the webview's dev tools
      &lt;script&gt;
        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));
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    webview.setAttribute(&quot;preload&quot;, &quot;./child_new.js&quot;);
    require('./child_new');

    webview.addEventListener(&quot;ipc-message&quot;, function(event) {
      console.log('received message from child webview');
      // some message received from the webview
      webview.send('ipc-parent-to-child', event);
    });
  &lt;/script&gt;
&lt;/body&gt;"><pre class="notranslate"><code class="notranslate">    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);
    });
  &lt;/script&gt;
&lt;/body&gt;
</code></pre></div>

<p dir="auto">child_new.js =&gt;</p>
<p dir="auto">const { ipcRenderer: ipc } = require('electron');</p>
<p dir="auto">console.log('Hey, this is being run in the context of the webview renderer process');</p>
<p dir="auto">document.addEventListener('DOMContentLoaded', function(event) {<br>
ipc.sendToHost('renderer_to_main',"please find me : child =&gt; parent =&gt; child ");</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ipc.on('ipc-parent-to-child', (event, props) =&gt; {
    // 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)}`);
  });"><pre class="notranslate"><code class="notranslate">ipc.on('ipc-parent-to-child', (event, props) =&gt; {
    // 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)}`);
  });
</code></pre></div>
<p dir="auto">});</p>
<p dir="auto">child_new.html =&gt;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;html&gt;
&lt;head&gt; &lt;/head&gt; &lt;body&gt;
  &lt;p id=&quot;findMe&quot;&gt;
    Hello from inside the webview.
  &lt;/p&gt;
&lt;/body&gt; &lt;/html&gt;"><pre class="notranslate"><code class="notranslate">&lt;html&gt;
&lt;head&gt; &lt;/head&gt; &lt;body&gt;
  &lt;p id="findMe"&gt;
    Hello from inside the webview.
  &lt;/p&gt;
&lt;/body&gt; &lt;/html&gt;
</code></pre></div>
<ul dir="auto">
<li>Electron version: 1.8.2</li>
<li>Operating system: MacOS, Windows10</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">ipc messages from the main process should be sent to the renderer process when both <code class="notranslate">sandbox</code> and <code class="notranslate">contextIsolation</code> are set.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">ipc messages sent in listeners to webview events are not visible in the renderer process.</p>
<h3 dir="auto">How to reproduce</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ git clone https://gist.github.com/4f6c4450cff194838e746ce23e60116d.git
$ cd 4f6c4450cff194838e746ce23e60116d/
$ electron main.js "><pre class="notranslate"><code class="notranslate">$ git clone https://gist.github.com/4f6c4450cff194838e746ce23e60116d.git
$ cd 4f6c4450cff194838e746ce23e60116d/
$ electron main.js 
</code></pre></div>
<p dir="auto">The devtools will open and the console will log one message.  But the second message on the ipc <code class="notranslate">ping</code> channel is not observed.</p>
<p dir="auto">Toggling either <code class="notranslate">sandbox</code> or <code class="notranslate">contextIsolation</code> to false allows the <code class="notranslate">ping</code> 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.</p>