Skip to content

navigator.permissions.query does not reflect that all perms are denied (via session.setPermission(Check|Request)Handler) #19891

@bughit

Description

@bughit

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • x86 v4.2.9
    • x86 v7.0.0-beta.3
  • Operating System:
    • win7 sp1 x64

Expected Behavior

When all perms are denied in chrome, both navigator.mediaDevices.getUserMedia({audio: true}) and navigator.permissions.query({name: 'microphone'}) report denials.

The electron facility for denying chrome perms is session.setPermission(Check|Request)Handler so it's expected that when all perms are denied, navigator.permissions.query({name: 'microphone'}) would return "denied".

Actual Behavior

navigator.permissions.query({name: 'microphone'}) returns {state: 'granted'}

It doesn't actually have this perm as navigator.mediaDevices.getUserMedia({audio: true}) correctly throws "permission denied"

To Reproduce

  • run the app
    'use strict';
    
    const {app, BrowserWindow} = require('electron');
    
    let win;
    
    
    app.on('ready', () => {
    
      win = new BrowserWindow({
        width: 1440,
        height: 900,
        useContentSize: true,
        webPreferences: {
          nodeIntegration: false,
        },
      });
    
      win.webContents.session.setPermissionCheckHandler((webCont, perm, origin, details) => {
        console.log('ChromePermissionCheck %s %O', perm, details);
        return false;
      });
    
      win.webContents.session.setPermissionRequestHandler((webCont, perm, callback, details) => {
        console.log('ChromePermissionRequest %s %O', perm, details);
        callback(false);
      });
    
      win.webContents.openDevTools({mode: 'right'});
    
      win.loadURL('https://example.org/');
    
    });
  • eval await navigator.permissions.query({name: 'microphone'}) in the devtools console

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions