<p dir="auto">I've come across a strange bug on 64-bit Windows where <code class="notranslate">instanceof</code> does not behave correctly in the browser frame when using it against an object whose prototype inherits from a function defined in a different module under <code class="notranslate">node_modules</code>.</p>
<h3 dir="auto">Example</h3>
<p dir="auto">For example, let's say there are two functions <code class="notranslate">B</code> and <code class="notranslate">D</code> and these files:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test.js"><pre class="notranslate"><code class="notranslate">test.js
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="d.js (contains the D function)"><pre class="notranslate"><code class="notranslate">d.js (contains the D function)
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="node_modules/b_module/b.js (contains the B function)"><pre class="notranslate"><code class="notranslate">node_modules/b_module/b.js (contains the B function)
</code></pre></div>
<p dir="auto">If <code class="notranslate">D</code>'s prototype points to an instance of <code class="notranslate">B</code> and both <code class="notranslate">B</code> and <code class="notranslate">D</code> are <code class="notranslate">require</code>d into <code class="notranslate">test.js</code>, then on Windows, if test.js uses instaneof to check whether D inherits from B, it will return <code class="notranslate">false</code>.</p>
<h3 dir="auto">Code samples</h3>
<p dir="auto">I've gone ahead and created a sample project with the code here to see the bug in action:<br>
<a href="https://github.com/jameslk/electron-instanceof-bug">https://github.com/jameslk/electron-instanceof-bug</a></p>
<p dir="auto">Here's some screenshots showing the discrepency:</p>
<h3 dir="auto">Running NodeJS:</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/774411/7486563/44b92418-f364-11e4-8526-fcd1974a792a.png"><img src="https://cloud.githubusercontent.com/assets/774411/7486563/44b92418-f364-11e4-8526-fcd1974a792a.png" alt="screen shot 2015-05-05 at 8 05 20 pm" style="max-width: 100%;"></a></p>
<h3 dir="auto">Running ElectronJS on Windows (from the browser frame dev tools):</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/774411/7486696/31499992-f366-11e4-9d0a-9c2e406a8386.png"><img src="https://cloud.githubusercontent.com/assets/774411/7486696/31499992-f366-11e4-9d0a-9c2e406a8386.png" alt="screen-shot-2015-05-05-at-8 06 59-pm-2" style="max-width: 100%;"></a></p>
<h3 dir="auto">Running ElectronJS on Mac</h3>
<p dir="auto">This bug only appears to happen under Windows. I tried it on Mac and got the expected results.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/774411/7486634/3e47840c-f365-11e4-9359-20ba432bf2f9.png"><img src="https://cloud.githubusercontent.com/assets/774411/7486634/3e47840c-f365-11e4-9359-20ba432bf2f9.png" alt="screen shot 2015-05-05 at 8 27 34 pm" style="max-width: 100%;"></a></p>
<p dir="auto">I have not tested Linux yet.</p>
<p dir="auto">Minimal test case for this issue is here: <a href="https://github.com/KamilSzot/atom-shell-windows-bash-problem">https://github.com/KamilSzot/atom-shell-windows-bash-problem</a></p>
<p dir="auto">Windows bash attempts to use slashes instead of backslashes and that probably interferes somehow with path calculations. Maybe there's some point there is a relative path calculated between directory where atom-shell lies and where the application lies?</p>