<ul dir="auto">
<li>Electron version: tested on 1.6.2, but same on all versions</li>
<li>Operating system: All</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">When you subclass <code class="notranslate">BrowserWindow</code>, you shoud be able to use instances of these subclasses as arguments for <code class="notranslate">dialog.showMessageBox</code>.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">When you subclass <code class="notranslate">BrowserWindow</code>, you cannot use instances of these subclasses as arguments for <code class="notranslate">dialog.showMessageBox</code> .</p>
<h3 dir="auto">How to reproduce</h3>
<ul dir="auto">
<li>Subclass <code class="notranslate">BrowserWindow</code> with a custom constructor.</li>
<li>Try using an instance of that class as argument of <code class="notranslate">dialog.showMessageBox</code>.</li>
<li>You get an empty message box.</li>
</ul>
<h3 dir="auto">What actually happens.</h3>
<p dir="auto">The code at <code class="notranslate">lib/browser/api/dialog.js:24</code> checks for <code class="notranslate">window.constructor !== BrowserWindow</code>.<br>
In that case, the first argument is interpreted as an options argument.<br>
It should instead use the <code class="notranslate">instanceof</code> operator.<br>
With a quick search on the repo, this happens at at least 3 places of electron's code :</p>
<p dir="auto"><a href="https://github.com/electron/electron/blob/d4a8a64ba7be50906ed5116669b7c06d8da3574f/lib/browser/api/menu-item.js">https://github.com/electron/electron/blob/d4a8a64ba7be50906ed5116669b7c06d8da3574f/lib/browser/api/menu-item.js</a> line 15 which checks for <code class="notranslate">Menu</code> constructor<br>
<a href="https://github.com/electron/electron/blob/d01250eceb6d567378df1de44b5631246c1a523b/lib/browser/api/menu.js">https://github.com/electron/electron/blob/d01250eceb6d567378df1de44b5631246c1a523b/lib/browser/api/menu.js</a> line 150 which checks for <code class="notranslate">BrowserWindow</code> constructor<br>
<a href="https://github.com/electron/electron/blob/8c2cf03f378008baf2cb31050795ac9c929411b0/lib/browser/api/dialog.js">https://github.com/electron/electron/blob/8c2cf03f378008baf2cb31050795ac9c929411b0/lib/browser/api/dialog.js</a> line 24 which checks for <code class="notranslate">BrowserWindow</code> constructor</p>
<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<p dir="auto">Electron Version: 6.0.7<br>
Operating System: macOS 10.13.6<br>
(also verified on Windows 10)</p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">I expect to be able to abort Bluetooth scanning (initiated by calling requestDevice()) even if there are no scan results.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">Currently it is only possible to abort a scan by calling the callback provided by the webContents event 'select-bluetooth-device' (in the main process). However, if there are no scan results the callback is never called and there is no callback to use.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">Start scanning by calling requestDevice() in an environment with no BLE devices (or with a filter that does not match any devices).</p>
<h3 dir="auto">Additional Information</h3>
<p dir="auto">One solution would be to trigger 'select-bluetooth-device' with an empty list immediately when requestDevice is called. This would be backwards compatible and have the least impact on the current API.</p>
<p dir="auto">Personally, I would prefer if the callback was provided in some other way. It does not make sense of providing the callback repeatedly in the 'select-bluetooth-device' event as the callback usage is not related to an individual scan result but rather to the ongoing scanning process.</p>