karma-runner / karma-chrome-launcher

A Karma plugin. Launcher for Chrome and Chrome Canary.
MIT License
469 stars 119 forks source link

Override permissions API? #199

Closed jportella93 closed 5 years ago

jportella93 commented 5 years ago

Hi, thanks for the great package!

I'm trying to access the clipboard-read API to read text copied to clipboard, but it requires a status granted on the Permissions API and I can't figure out how to show the permission prompt and accept it.

I tried starting Chrome Headless with permissions API disabled, but then it just removes the access to the API so I cannot grant access to the clipboard:

  browsers: [
      'CustomChromeHeadless',
    ],
    customLaunchers: {
      'CustomChromeHeadless': {
        base: 'ChromeHeadless',
        flags: [
          '--disable-permissions-api'
          ]
      }
    },

Is there any way I can do something similar to overridePermissions as you can do in Puppeteer?:

const context = browser.defaultBrowserContext();
await context.overridePermissions('http://example.com', ['clipboard-read']);
rogeriopvl commented 5 years ago

Hi @jportella93

AFAIK, there's no flag for that on Chrome (karma-chrome-laucher mainly builds the chrome command with all the configured/necessary flags).

A way to configure this in Chrome is to use the DevTools protocol and Browser.grantPermissions. So maybe you can somehow include that in your setup.

Burtan commented 1 year ago

Did you succeed?