<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>[] 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: v5.0.1<br>
Operating system: MaxOS 10.14.4</p>
<h3 dir="auto">Expected Behavior</h3>

<p dir="auto">As doc <a href="https://electronjs.org/docs/api/shell#shellopenexternalurl-options" rel="nofollow">https://electronjs.org/docs/api/shell#shellopenexternalurl-options</a></p>
<h3 dir="auto">Actual Behavior</h3>

<p dir="auto">Link opened in the browser, but the browser is not brought to the foreground.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">Upgrade electron to v5.0.1 in <a href="https://github.com/electron/electron-api-demos">https://github.com/electron/electron-api-demos</a></p>
<p dir="auto">And try "open external links" demo</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>
<p dir="auto">Note: related but different issues:</p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="541485582" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/21603" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/21603/hovercard" href="https://github.com/electron/electron/issues/21603">#21603</a> -- that one was using the older (callback) API, but this is using the latest (promise) API (and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="543814618" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/21639" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/21639/hovercard" href="https://github.com/electron/electron/issues/21639">#21639</a> appears to be a duplicate of that)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="439209407" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/18093" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/18093/hovercard" href="https://github.com/electron/electron/issues/18093">#18093</a> -- in that case some output is produced, but here a rejection occurs (and the affected electron versions are different).</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="509162734" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/20634" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/20634/hovercard" href="https://github.com/electron/electron/issues/20634">#20634</a> -- that one never ends, but this one rejects shortly after the call occurs</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>v8.0.0-beta.5 (also happens in 9.0.0-nightly.20191220 &amp; 9.0.0-nightly.20200108)</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Debian (bullseye/sid) x64, 5.3.0 kernel</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>7.1.8, 8.0.0-beta.4, See <a href="https://github.com/electron/electron/issues/21708#issuecomment-573079603" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/21708/hovercard">bisect</a></li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Calling <code class="notranslate">someBrowserWindow.webContents.printToPDF</code> should not throw exception / generate promise rejection.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">Calling <code class="notranslate">someBrowserWindow.webContents.printToPDF</code> rejects with <code class="notranslate">[Error: Failed to generate PDF]</code>.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">Fiddle: <a href="https://gist.github.com/jacobq/cc5e5e1736b88cb32604f55369afd1c7">https://gist.github.com/jacobq/cc5e5e1736b88cb32604f55369afd1c7</a><br>
Repo: <a href="https://github.com/jacobq/electron-quick-start/tree/bug/print-to-pdf">https://github.com/jacobq/electron-quick-start/tree/bug/print-to-pdf</a></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="mainWindow.webContents.once('did-finish-load', async function() {
  try {
    const pdfData = await mainWindow.webContents.printToPDF({})
    console.log('Got PDF data --&gt;', pdfData) // never gets here
  } catch(e) {
    // output --&gt; Call to printToPDF threw exception [Error: Failed to generate PDF]
    console.error('Call to printToPDF threw exception', e)
  }
});"><pre class="notranslate"><span class="pl-s1">mainWindow</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-en">once</span><span class="pl-kos">(</span><span class="pl-s">'did-finish-load'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-k">function</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">try</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">pdfData</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">mainWindow</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-en">printToPDF</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</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-s">'Got PDF data --&gt;'</span><span class="pl-kos">,</span> <span class="pl-s1">pdfData</span><span class="pl-kos">)</span> <span class="pl-c">// never gets here</span>
  <span class="pl-kos">}</span> <span class="pl-k">catch</span><span class="pl-kos">(</span><span class="pl-s1">e</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-c">// output --&gt; Call to printToPDF threw exception [Error: Failed to generate PDF]</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">error</span><span class="pl-kos">(</span><span class="pl-s">'Call to printToPDF threw exception'</span><span class="pl-kos">,</span> <span class="pl-s1">e</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></pre></div>