Add missing grantable permissions to Chromium browsers
This commit is contained in:
parent
3cd753f6bb
commit
5d4d256ddf
|
|
@ -971,8 +971,11 @@ A permission or an array of permissions to grant. Permissions can be one of the
|
|||
* `'camera'`
|
||||
* `'clipboard-read'`
|
||||
* `'clipboard-write'`
|
||||
* `'display-capture'`
|
||||
* `'geolocation'`
|
||||
* `'gyroscope'`
|
||||
* `'idle-detection'`
|
||||
* `'local-fonts'`
|
||||
* `'magnetometer'`
|
||||
* `'microphone'`
|
||||
* `'midi-sysex'` (system-exclusive midi)
|
||||
|
|
@ -980,6 +983,8 @@ A permission or an array of permissions to grant. Permissions can be one of the
|
|||
* `'notifications'`
|
||||
* `'payment-handler'`
|
||||
* `'storage-access'`
|
||||
* `'usb'`
|
||||
* `'window-management'`
|
||||
|
||||
### option: BrowserContext.grantPermissions.origin
|
||||
* since: v1.8
|
||||
|
|
|
|||
|
|
@ -418,23 +418,30 @@ export class CRBrowserContext extends BrowserContext {
|
|||
|
||||
async doGrantPermissions(origin: string, permissions: string[]) {
|
||||
const webPermissionToProtocol = new Map<string, Protocol.Browser.PermissionType>([
|
||||
['geolocation', 'geolocation'],
|
||||
['midi', 'midi'],
|
||||
['notifications', 'notifications'],
|
||||
['camera', 'videoCapture'],
|
||||
['microphone', 'audioCapture'],
|
||||
['background-sync', 'backgroundSync'],
|
||||
['ambient-light-sensor', 'sensors'],
|
||||
// General permissions
|
||||
['accelerometer', 'sensors'],
|
||||
['gyroscope', 'sensors'],
|
||||
['magnetometer', 'sensors'],
|
||||
['accessibility-events', 'accessibilityEvents'],
|
||||
['ambient-light-sensor', 'sensors'],
|
||||
['background-sync', 'backgroundSync'],
|
||||
['camera', 'videoCapture'],
|
||||
['clipboard-read', 'clipboardReadWrite'],
|
||||
['clipboard-write', 'clipboardSanitizedWrite'],
|
||||
['display-capture', 'displayCapture'],
|
||||
['geolocation', 'geolocation'],
|
||||
['gyroscope', 'sensors'],
|
||||
['magnetometer', 'sensors'],
|
||||
['microphone', 'audioCapture'],
|
||||
['midi', 'midi'],
|
||||
['notifications', 'notifications'],
|
||||
['payment-handler', 'paymentHandler'],
|
||||
// chrome-specific permissions we have.
|
||||
|
||||
// Chrome-specific permissions we have.
|
||||
['idle-detection', 'idleDetection'],
|
||||
['local-fonts', 'localFonts'],
|
||||
['midi-sysex', 'midiSysex'],
|
||||
['storage-access', 'storageAccess'],
|
||||
['usb', 'usb'],
|
||||
['window-management', 'windowManagement'],
|
||||
]);
|
||||
const filtered = permissions.map(permission => {
|
||||
const protocolPermission = webPermissionToProtocol.get(permission);
|
||||
|
|
|
|||
5
packages/playwright-core/types/types.d.ts
vendored
5
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -8969,8 +8969,11 @@ export interface BrowserContext {
|
|||
* - `'camera'`
|
||||
* - `'clipboard-read'`
|
||||
* - `'clipboard-write'`
|
||||
* - `'display-capture'`
|
||||
* - `'geolocation'`
|
||||
* - `'gyroscope'`
|
||||
* - `'idle-detection'`
|
||||
* - `'local-fonts'`
|
||||
* - `'magnetometer'`
|
||||
* - `'microphone'`
|
||||
* - `'midi-sysex'` (system-exclusive midi)
|
||||
|
|
@ -8978,6 +8981,8 @@ export interface BrowserContext {
|
|||
* - `'notifications'`
|
||||
* - `'payment-handler'`
|
||||
* - `'storage-access'`
|
||||
* - `'usb'`
|
||||
* - `'window-management'`
|
||||
* @param options
|
||||
*/
|
||||
grantPermissions(permissions: ReadonlyArray<string>, options?: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue