BrowserContext.overridePermissions() 方法
🌐 BrowserContext.overridePermissions() method
警告:此 API 现在已过时。
在指定的 origin 内授予此 浏览器上下文 给定的 permissions。
🌐 Grants this browser context the given permissions within the given origin.
语法
🌐 Signature
class BrowserContext {
abstract overridePermissions(
origin: string,
permissions: Permission[],
): Promise<void>;
}
参数
🌐 Parameters
范围 🌐 Parameter | 类型 🌐 Type | 描述 🌐 Description |
|---|---|---|
origin | string | 授予权限的来源,例如 "https://example.com"。 🌐 The origin to grant permissions to, e.g. "https://example.com". |
permissions | 权限[] | 要授予的一组权限。这里未列出的所有权限将自动被拒绝。 🌐 An array of permissions to grant. All permissions that are not listed here will be automatically denied. |
返回:
Promise<void>
示例
🌐 Example
在默认浏览器上下文中覆盖权限:
🌐 Overriding permissions in the default browser context:
const context = browser.defaultBrowserContext();
await context.overridePermissions('https://html5demos.com', ['geolocation']);