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'`
|
* `'camera'`
|
||||||
* `'clipboard-read'`
|
* `'clipboard-read'`
|
||||||
* `'clipboard-write'`
|
* `'clipboard-write'`
|
||||||
|
* `'display-capture'`
|
||||||
* `'geolocation'`
|
* `'geolocation'`
|
||||||
* `'gyroscope'`
|
* `'gyroscope'`
|
||||||
|
* `'idle-detection'`
|
||||||
|
* `'local-fonts'`
|
||||||
* `'magnetometer'`
|
* `'magnetometer'`
|
||||||
* `'microphone'`
|
* `'microphone'`
|
||||||
* `'midi-sysex'` (system-exclusive midi)
|
* `'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'`
|
* `'notifications'`
|
||||||
* `'payment-handler'`
|
* `'payment-handler'`
|
||||||
* `'storage-access'`
|
* `'storage-access'`
|
||||||
|
* `'usb'`
|
||||||
|
* `'window-management'`
|
||||||
|
|
||||||
### option: BrowserContext.grantPermissions.origin
|
### option: BrowserContext.grantPermissions.origin
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
|
|
|
||||||
|
|
@ -418,23 +418,30 @@ export class CRBrowserContext extends BrowserContext {
|
||||||
|
|
||||||
async doGrantPermissions(origin: string, permissions: string[]) {
|
async doGrantPermissions(origin: string, permissions: string[]) {
|
||||||
const webPermissionToProtocol = new Map<string, Protocol.Browser.PermissionType>([
|
const webPermissionToProtocol = new Map<string, Protocol.Browser.PermissionType>([
|
||||||
['geolocation', 'geolocation'],
|
// General permissions
|
||||||
['midi', 'midi'],
|
|
||||||
['notifications', 'notifications'],
|
|
||||||
['camera', 'videoCapture'],
|
|
||||||
['microphone', 'audioCapture'],
|
|
||||||
['background-sync', 'backgroundSync'],
|
|
||||||
['ambient-light-sensor', 'sensors'],
|
|
||||||
['accelerometer', 'sensors'],
|
['accelerometer', 'sensors'],
|
||||||
['gyroscope', 'sensors'],
|
|
||||||
['magnetometer', 'sensors'],
|
|
||||||
['accessibility-events', 'accessibilityEvents'],
|
['accessibility-events', 'accessibilityEvents'],
|
||||||
|
['ambient-light-sensor', 'sensors'],
|
||||||
|
['background-sync', 'backgroundSync'],
|
||||||
|
['camera', 'videoCapture'],
|
||||||
['clipboard-read', 'clipboardReadWrite'],
|
['clipboard-read', 'clipboardReadWrite'],
|
||||||
['clipboard-write', 'clipboardSanitizedWrite'],
|
['clipboard-write', 'clipboardSanitizedWrite'],
|
||||||
|
['display-capture', 'displayCapture'],
|
||||||
|
['geolocation', 'geolocation'],
|
||||||
|
['gyroscope', 'sensors'],
|
||||||
|
['magnetometer', 'sensors'],
|
||||||
|
['microphone', 'audioCapture'],
|
||||||
|
['midi', 'midi'],
|
||||||
|
['notifications', 'notifications'],
|
||||||
['payment-handler', 'paymentHandler'],
|
['payment-handler', 'paymentHandler'],
|
||||||
// chrome-specific permissions we have.
|
|
||||||
|
// Chrome-specific permissions we have.
|
||||||
|
['idle-detection', 'idleDetection'],
|
||||||
|
['local-fonts', 'localFonts'],
|
||||||
['midi-sysex', 'midiSysex'],
|
['midi-sysex', 'midiSysex'],
|
||||||
['storage-access', 'storageAccess'],
|
['storage-access', 'storageAccess'],
|
||||||
|
['usb', 'usb'],
|
||||||
|
['window-management', 'windowManagement'],
|
||||||
]);
|
]);
|
||||||
const filtered = permissions.map(permission => {
|
const filtered = permissions.map(permission => {
|
||||||
const protocolPermission = webPermissionToProtocol.get(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'`
|
* - `'camera'`
|
||||||
* - `'clipboard-read'`
|
* - `'clipboard-read'`
|
||||||
* - `'clipboard-write'`
|
* - `'clipboard-write'`
|
||||||
|
* - `'display-capture'`
|
||||||
* - `'geolocation'`
|
* - `'geolocation'`
|
||||||
* - `'gyroscope'`
|
* - `'gyroscope'`
|
||||||
|
* - `'idle-detection'`
|
||||||
|
* - `'local-fonts'`
|
||||||
* - `'magnetometer'`
|
* - `'magnetometer'`
|
||||||
* - `'microphone'`
|
* - `'microphone'`
|
||||||
* - `'midi-sysex'` (system-exclusive midi)
|
* - `'midi-sysex'` (system-exclusive midi)
|
||||||
|
|
@ -8978,6 +8981,8 @@ export interface BrowserContext {
|
||||||
* - `'notifications'`
|
* - `'notifications'`
|
||||||
* - `'payment-handler'`
|
* - `'payment-handler'`
|
||||||
* - `'storage-access'`
|
* - `'storage-access'`
|
||||||
|
* - `'usb'`
|
||||||
|
* - `'window-management'`
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
grantPermissions(permissions: ReadonlyArray<string>, options?: {
|
grantPermissions(permissions: ReadonlyArray<string>, options?: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue