chore: share grant permissions init among browser types (#15457)

This commit is contained in:
Pavel Feldman 2022-07-07 10:39:05 -08:00 committed by GitHub
parent 413258bfac
commit cc6f415933
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 6 deletions

View file

@ -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() {

View file

@ -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);
}

View file

@ -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)

View file

@ -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)