<ul dir="auto">
<li>Electron version: 0.36.12 (earliest tested) to 0.37.5 (latest)</li>
<li>Operating system: Windows 8.1</li>
</ul>
<p dir="auto">I am working on a project to test some code in a sandboxed iframe that gives limited access to the parent. The implementation is pretty straight forward. The problem is it works in modern web browsers but not in Electron. It is even verified working in Chrome. And both the jQuery and vanilla JS versions produce the same results.</p>
<p dir="auto">The iframe is created with:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$('&lt;iframe&gt;', {
    src: 'about:blank',
    id:  'ptg-sandbox',
    frameborder: 0,
    scrolling: 'no',
    style: 'width: 0px; height: 0px; display: none;'
}).appendTo('body');"><pre class="notranslate"><span class="pl-en">$</span><span class="pl-kos">(</span><span class="pl-s">'&lt;iframe&gt;'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
    <span class="pl-c1">src</span>: <span class="pl-s">'about:blank'</span><span class="pl-kos">,</span>
    <span class="pl-c1">id</span>:  <span class="pl-s">'ptg-sandbox'</span><span class="pl-kos">,</span>
    <span class="pl-c1">frameborder</span>: <span class="pl-c1">0</span><span class="pl-kos">,</span>
    <span class="pl-c1">scrolling</span>: <span class="pl-s">'no'</span><span class="pl-kos">,</span>
    <span class="pl-c1">style</span>: <span class="pl-s">'width: 0px; height: 0px; display: none;'</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">appendTo</span><span class="pl-kos">(</span><span class="pl-s">'body'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">And then the eval works much like:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$('#ptg-sandbox')[0].contentWindow.eval('alert(&quot;test&quot;);');"><pre class="notranslate"><span class="pl-en">$</span><span class="pl-kos">(</span><span class="pl-s">'#ptg-sandbox'</span><span class="pl-kos">)</span><span class="pl-kos">[</span><span class="pl-c1">0</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-c1">contentWindow</span><span class="pl-kos">.</span><span class="pl-en">eval</span><span class="pl-kos">(</span><span class="pl-s">'alert("test");'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Code is in place to ensure the iframe exists in the DOM before firing the code. So I ruled that out. The expected result should be an alert that says "test". But unfortunately I can't get it and no error is returned. If it helps to know I am also have nodeIntegration set to false for this BrowserWindow.</p>
<p dir="auto">Currently there's no support for <code class="notranslate">alert</code> and <code class="notranslate">confirm</code> dialogs in iframes (see discussion in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="101710943" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/2522" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/2522/hovercard" href="https://github.com/electron/electron/issues/2522">#2522</a>).</p>
<p dir="auto">Once the "Session wide preload script" <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="103406800" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/2605" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/2605/hovercard" href="https://github.com/electron/electron/issues/2605">#2605</a> is ready, I think we should implement a default preload that will add the missing dialogs (kind of like what override.coffee does for the parent window).</p>