<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>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>x86 v4.2.9</li>
<li>x86 v7.0.0-beta.3</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>win7 sp1 x64</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">When all perms are denied in chrome, both <code class="notranslate">navigator.mediaDevices.getUserMedia({audio: true})</code> and <code class="notranslate">navigator.permissions.query({name: 'microphone'})</code> report denials.</p>
<p dir="auto">The electron facility for denying chrome perms is <code class="notranslate">session.setPermission(Check|Request)Handler</code> so it's expected that when all perms are denied, <code class="notranslate">navigator.permissions.query({name: 'microphone'})</code> would return "denied".</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto"><code class="notranslate">navigator.permissions.query({name: 'microphone'})</code> returns <code class="notranslate">{state: 'granted'}</code></p>
<p dir="auto">It doesn't actually have this perm as <code class="notranslate">navigator.mediaDevices.getUserMedia({audio: true})</code> correctly throws "permission denied"</p>
<h3 dir="auto">To Reproduce</h3>
<ul dir="auto">
<li>run the app
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="'use strict';

const {app, BrowserWindow} = require('electron');

let win;


app.on('ready', () =&gt; {

  win = new BrowserWindow({
    width: 1440,
    height: 900,
    useContentSize: true,
    webPreferences: {
      nodeIntegration: false,
    },
  });

  win.webContents.session.setPermissionCheckHandler((webCont, perm, origin, details) =&gt; {
    console.log('ChromePermissionCheck %s %O', perm, details);
    return false;
  });

  win.webContents.session.setPermissionRequestHandler((webCont, perm, callback, details) =&gt; {
    console.log('ChromePermissionRequest %s %O', perm, details);
    callback(false);
  });

  win.webContents.openDevTools({mode: 'right'});

  win.loadURL('https://example.org/');

});"><pre class="notranslate"><span class="pl-s">'use strict'</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-kos">{</span>app<span class="pl-kos">,</span> BrowserWindow<span class="pl-kos">}</span> <span class="pl-c1">=</span> <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-k">let</span> <span class="pl-s1">win</span><span class="pl-kos">;</span>


<span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'ready'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>

  <span class="pl-s1">win</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">BrowserWindow</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
    <span class="pl-c1">width</span>: <span class="pl-c1">1440</span><span class="pl-kos">,</span>
    <span class="pl-c1">height</span>: <span class="pl-c1">900</span><span class="pl-kos">,</span>
    <span class="pl-c1">useContentSize</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
    <span class="pl-c1">webPreferences</span>: <span class="pl-kos">{</span>
      <span class="pl-c1">nodeIntegration</span>: <span class="pl-c1">false</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-kos">;</span>

  <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-c1">session</span><span class="pl-kos">.</span><span class="pl-en">setPermissionCheckHandler</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">webCont</span><span class="pl-kos">,</span> <span class="pl-s1">perm</span><span class="pl-kos">,</span> <span class="pl-s1">origin</span><span class="pl-kos">,</span> <span class="pl-s1">details</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</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">'ChromePermissionCheck %s %O'</span><span class="pl-kos">,</span> <span class="pl-s1">perm</span><span class="pl-kos">,</span> <span class="pl-s1">details</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">return</span> <span class="pl-c1">false</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">win</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-c1">session</span><span class="pl-kos">.</span><span class="pl-en">setPermissionRequestHandler</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">webCont</span><span class="pl-kos">,</span> <span class="pl-s1">perm</span><span class="pl-kos">,</span> <span class="pl-s1">callback</span><span class="pl-kos">,</span> <span class="pl-s1">details</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</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">'ChromePermissionRequest %s %O'</span><span class="pl-kos">,</span> <span class="pl-s1">perm</span><span class="pl-kos">,</span> <span class="pl-s1">details</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">callback</span><span class="pl-kos">(</span><span class="pl-c1">false</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">win</span><span class="pl-kos">.</span><span class="pl-c1">webContents</span><span class="pl-kos">.</span><span class="pl-en">openDevTools</span><span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-c1">mode</span>: <span class="pl-s">'right'</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-s1">win</span><span class="pl-kos">.</span><span class="pl-en">loadURL</span><span class="pl-kos">(</span><span class="pl-s">'https://example.org/'</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>
</li>
<li>eval <code class="notranslate">await navigator.permissions.query({name: 'microphone'})</code> in the devtools console</li>
</ul>
<h3 dir="auto">Screenshots</h3>

<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/895588/63536544-d9aa1980-c4e1-11e9-82fb-7f12cb1b11ac.png"><img src="https://user-images.githubusercontent.com/895588/63536544-d9aa1980-c4e1-11e9-82fb-7f12cb1b11ac.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">See </p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/electron/electron/blob/54ad38526095f4a415ad75a1757feae4336c9db4/atom/browser/atom_permission_manager.cc#L213">electron/atom/browser/atom_permission_manager.cc</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 213
      in
      <a data-pjax="true" class="commit-tease-sha" href="/electron/electron/commit/54ad38526095f4a415ad75a1757feae4336c9db4">54ad385</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L213" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="213"></td>
          <td id="LC213" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> blink::mojom::PermissionStatus <span class="pl-en">AtomPermissionManager::GetPermissionStatus</span>( </td>
        </tr>
    </tbody></table>
  </div>
</div>
 and <div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/electron/electron/blob/54ad38526095f4a415ad75a1757feae4336c9db4/atom/browser/atom_permission_manager.cc#L246">electron/atom/browser/atom_permission_manager.cc</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 246
      in
      <a data-pjax="true" class="commit-tease-sha" href="/electron/electron/commit/54ad38526095f4a415ad75a1757feae4336c9db4">54ad385</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L246" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="246"></td>
          <td id="LC246" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-en">AtomPermissionManager::GetPermissionStatusForFrame</span>( </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">Should probably call out to </p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/electron/electron/blob/54ad38526095f4a415ad75a1757feae4336c9db4/atom/browser/atom_permission_manager.cc#L231">electron/atom/browser/atom_permission_manager.cc</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 231
      in
      <a data-pjax="true" class="commit-tease-sha" href="/electron/electron/commit/54ad38526095f4a415ad75a1757feae4336c9db4">54ad385</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L231" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="231"></td>
          <td id="LC231" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">bool</span> <span class="pl-en">AtomPermissionManager::CheckPermissionWithDetails</span>( </td>
        </tr>
    </tbody></table>
  </div>
</div>
 and be documented as such<p></p>