<ul dir="auto">
<li>Electron Version: 2.0.7</li>
<li>Operating System (Platform and Version): MacOS 10.13.6</li>
<li>Last known working Electron version:</li>
</ul>
<p dir="auto"><strong>Expected Behavior</strong><br>
When a renderer process in a BrowserView is closed, I expect the <code class="notranslate">window.onbeforeunload</code> event to fire.</p>
<p dir="auto"><strong>Actual behavior</strong><br>
It does not fire in a BrowserView renderer.</p>
<p dir="auto"><strong>To Reproduce</strong><br>
Run this code in an Electron fiddle <a href="https://gist.github.com/ccnokes/88d847e32a8a2e6ba1eca15cb9e5bc47">https://gist.github.com/ccnokes/88d847e32a8a2e6ba1eca15cb9e5bc47</a><br>
When the window opens, close it (but don't quit the app)<br>
Note that there's no message received from the renderer<br>
Also note that you can comment in the same code with a <code class="notranslate">onbeforeunload</code> event that works when it's run in a BrowserWindow but not in a BrowserView</p>
<p dir="auto">Let me know if you want a repo.</p>
<p dir="auto">Possibly related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="156326427" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/5661" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/5661/hovercard" href="https://github.com/electron/electron/issues/5661">#5661</a>?</p>
<ul dir="auto">
<li>Output of <code class="notranslate">node_modules/.bin/electron --version</code>: <code class="notranslate">v3.0.7</code></li>
<li>Operating System (Platform and Version): macOS Mojave 10.14.2, <code class="notranslate">Darwin 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64</code></li>
<li>Output of <code class="notranslate">node_modules/.bin/electron --version</code> on last known working Electron version (if applicable): n/a</li>
</ul>
<p dir="auto"><strong>Expected Behavior</strong><br>
Imagine there are two cookies with the same name on the same domain and path:</p>
<ol dir="auto">
<li>manually set using Cookies object</li>
<li>set by server</li>
</ol>
<p dir="auto">I would expect the second cookie to replace the first one when it's received from server.</p>
<p dir="auto"><strong>Actual behavior</strong><br>
Both cookies are sent in the same request.<br>
Request header:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Cookie: MyCookie=1; MyCookie=2"><pre class="notranslate"><code class="notranslate">Cookie: MyCookie=1; MyCookie=2
</code></pre></div>
<p dir="auto">Cookies seen by electron (note the difference in <code class="notranslate">domain</code>):</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="require('electron').remote.session.defaultSession.cookies.get({}, (e,c) =&gt; console.log(JSON.stringify(c, null, 2)))
[
  {
    &quot;name&quot;: &quot;MyCookie&quot;,
    &quot;value&quot;: &quot;1&quot;,
    &quot;domain&quot;: &quot;.localhost&quot;,
    &quot;hostOnly&quot;: false,
    &quot;path&quot;: &quot;/&quot;,
    &quot;secure&quot;: false,
    &quot;httpOnly&quot;: true,
    &quot;session&quot;: true
  },
  {
    &quot;name&quot;: &quot;MyCookie&quot;,
    &quot;value&quot;: &quot;2&quot;,
    &quot;domain&quot;: &quot;localhost&quot;,
    &quot;hostOnly&quot;: true,
    &quot;path&quot;: &quot;/&quot;,
    &quot;secure&quot;: false,
    &quot;httpOnly&quot;: false,
    &quot;session&quot;: true
  }
]"><pre class="notranslate"><span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">remote</span><span class="pl-kos">.</span><span class="pl-c1">session</span><span class="pl-kos">.</span><span class="pl-c1">defaultSession</span><span class="pl-kos">.</span><span class="pl-c1">cookies</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">,</span><span class="pl-s1">c</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-c1">JSON</span><span class="pl-kos">.</span><span class="pl-en">stringify</span><span class="pl-kos">(</span><span class="pl-s1">c</span><span class="pl-kos">,</span> <span class="pl-c1">null</span><span class="pl-kos">,</span> <span class="pl-c1">2</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
<span class="pl-kos">[</span>
  <span class="pl-kos">{</span>
    <span class="pl-s">"name"</span>: <span class="pl-s">"MyCookie"</span><span class="pl-kos">,</span>
    <span class="pl-s">"value"</span>: <span class="pl-s">"1"</span><span class="pl-kos">,</span>
    <span class="pl-s">"domain"</span>: <span class="pl-s">".localhost"</span><span class="pl-kos">,</span>
    <span class="pl-s">"hostOnly"</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-s">"path"</span>: <span class="pl-s">"/"</span><span class="pl-kos">,</span>
    <span class="pl-s">"secure"</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-s">"httpOnly"</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
    <span class="pl-s">"session"</span>: <span class="pl-c1">true</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-kos">{</span>
    <span class="pl-s">"name"</span>: <span class="pl-s">"MyCookie"</span><span class="pl-kos">,</span>
    <span class="pl-s">"value"</span>: <span class="pl-s">"2"</span><span class="pl-kos">,</span>
    <span class="pl-s">"domain"</span>: <span class="pl-s">"localhost"</span><span class="pl-kos">,</span>
    <span class="pl-s">"hostOnly"</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
    <span class="pl-s">"path"</span>: <span class="pl-s">"/"</span><span class="pl-kos">,</span>
    <span class="pl-s">"secure"</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-s">"httpOnly"</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
    <span class="pl-s">"session"</span>: <span class="pl-c1">true</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">]</span></pre></div>
<p dir="auto"><strong>To Reproduce</strong></p>
<ol dir="auto">
<li>set a cookie using <code class="notranslate">electron.remote.session.defaultSession.cookies.set</code></li>
<li>go to a website which gives you the same cookie with another value in response</li>
<li>send another request to this website</li>
<li>check cookies in the last request</li>
</ol>
<p dir="auto"><a href="https://github.com/antelle/electron-quick-start">https://github.com/antelle/electron-quick-start</a></p>
<p dir="auto">If you provide a URL, please list the commands required to clone/setup/run your repo e.g.</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ git clone https://github.com/antelle/electron-quick-start
$ npm install
$ npm start || electron ."><pre class="notranslate">$ git clone https://github.com/antelle/electron-quick-start
$ npm install
$ npm start <span class="pl-k">||</span> electron <span class="pl-c1">.</span></pre></div>
<p dir="auto">After this, wait for 2-3 seconds.<br>
Please note: it will try to start a server on port <code class="notranslate">80</code> and then navigate to <code class="notranslate">http://localhost</code>. If it's not possible, most likely there will be an error.</p>
<p dir="auto"><strong>Screenshots</strong><br>
<code class="notranslate">Cookie</code> header is displayed on this screenshot:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/633557/50741717-63ca9980-1201-11e9-8448-964aa1284686.png"><img width="420" alt="screen shot 2019-01-06 at 22 21 07" src="https://user-images.githubusercontent.com/633557/50741717-63ca9980-1201-11e9-8448-964aa1284686.png" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Additional Information</strong><br>
Browsers should send one cookie, not two of them.<br>
In real life, it results in <a href="https://user-images.githubusercontent.com/20073334/49846238-50f6ad80-fd98-11e8-87f3-dd9f1cb295ff.png" rel="nofollow">"We've detected a problem with you cookie settings"</a> screen returned by Google.</p>