chore: share grant permissions init among browser types (#15457)
This commit is contained in:
parent
413258bfac
commit
cc6f415933
|
|
@ -126,6 +126,9 @@ export abstract class BrowserContext extends SdkObject {
|
|||
await this.extendInjectedScript(consoleApiSource.source);
|
||||
if (this._options.serviceWorkers === 'block')
|
||||
await this.addInitScript(`\nnavigator.serviceWorker.register = () => { console.warn('Service Worker registration blocked by Playwright'); };\n`);
|
||||
|
||||
if (this._options.permissions)
|
||||
await this.grantPermissions(this._options.permissions);
|
||||
}
|
||||
|
||||
async _ensureVideosPath() {
|
||||
|
|
|
|||
|
|
@ -331,8 +331,6 @@ export class CRBrowserContext extends BrowserContext {
|
|||
eventsEnabled: true,
|
||||
}));
|
||||
}
|
||||
if (this._options.permissions)
|
||||
promises.push(this.grantPermissions(this._options.permissions));
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,8 +192,6 @@ export class FFBrowserContext extends BrowserContext {
|
|||
promises.push(this._browser._connection.send('Browser.setLocaleOverride', { browserContextId, locale: this._options.locale }));
|
||||
if (this._options.timezoneId)
|
||||
promises.push(this._browser._connection.send('Browser.setTimezoneOverride', { browserContextId, timezoneId: this._options.timezoneId }));
|
||||
if (this._options.permissions)
|
||||
promises.push(this.grantPermissions(this._options.permissions));
|
||||
if (this._options.extraHTTPHeaders || this._options.locale)
|
||||
promises.push(this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || []));
|
||||
if (this._options.httpCredentials)
|
||||
|
|
|
|||
|
|
@ -225,8 +225,6 @@ export class WKBrowserContext extends BrowserContext {
|
|||
promises.push(this._browser._browserSession.send('Playwright.setIgnoreCertificateErrors', { browserContextId, ignore: true }));
|
||||
if (this._options.locale)
|
||||
promises.push(this._browser._browserSession.send('Playwright.setLanguages', { browserContextId, languages: [this._options.locale] }));
|
||||
if (this._options.permissions)
|
||||
promises.push(this.grantPermissions(this._options.permissions));
|
||||
if (this._options.geolocation)
|
||||
promises.push(this.setGeolocation(this._options.geolocation));
|
||||
if (this._options.offline)
|
||||
|
|
|
|||
Loading…
Reference in a new issue