feat(firefox): process.env.PLAYWRIGHT_DISABLE_FIREFOX_CROSS_PROCESS (#18458)

This commit is contained in:
Dmitry Gozman 2022-10-31 15:19:10 -07:00 committed by GitHub
parent 84aa67a7fc
commit 9cc5ca0cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,7 @@ import type { ConnectionTransport } from '../transport';
import type { BrowserOptions, PlaywrightOptions } from '../browser'; import type { BrowserOptions, PlaywrightOptions } from '../browser';
import type * as types from '../types'; import type * as types from '../types';
import { rewriteErrorMessage } from '../../utils/stackTrace'; import { rewriteErrorMessage } from '../../utils/stackTrace';
import { wrapInASCIIBox } from '../../utils'; import { getAsBooleanFromENV, wrapInASCIIBox } from '../../utils';
export class Firefox extends BrowserType { export class Firefox extends BrowserType {
constructor(playwrightOptions: PlaywrightOptions) { constructor(playwrightOptions: PlaywrightOptions) {
@ -61,7 +61,11 @@ export class Firefox extends BrowserType {
throw new Error('Pass userDataDir parameter to `browserType.launchPersistentContext(userDataDir, ...)` instead of specifying --profile argument'); throw new Error('Pass userDataDir parameter to `browserType.launchPersistentContext(userDataDir, ...)` instead of specifying --profile argument');
if (args.find(arg => arg.startsWith('-juggler'))) if (args.find(arg => arg.startsWith('-juggler')))
throw new Error('Use the port parameter instead of -juggler argument'); throw new Error('Use the port parameter instead of -juggler argument');
const firefoxUserPrefs = isPersistent ? undefined : { ...kBandaidFirefoxUserPrefs, ...options.firefoxUserPrefs }; let firefoxUserPrefs = isPersistent ? undefined : options.firefoxUserPrefs;
if (getAsBooleanFromENV('PLAYWRIGHT_DISABLE_FIREFOX_CROSS_PROCESS'))
firefoxUserPrefs = { ...kDisableFissionFirefoxUserPrefs, ...firefoxUserPrefs };
if (Object.keys(kBandaidFirefoxUserPrefs).length)
firefoxUserPrefs = { ...kBandaidFirefoxUserPrefs, ...firefoxUserPrefs };
if (firefoxUserPrefs) { if (firefoxUserPrefs) {
const lines: string[] = []; const lines: string[] = [];
for (const [name, value] of Object.entries(firefoxUserPrefs)) for (const [name, value] of Object.entries(firefoxUserPrefs))
@ -90,3 +94,11 @@ export class Firefox extends BrowserType {
// Should all be moved to `playwright.cfg`. // Should all be moved to `playwright.cfg`.
const kBandaidFirefoxUserPrefs = { const kBandaidFirefoxUserPrefs = {
}; };
const kDisableFissionFirefoxUserPrefs = {
'browser.tabs.remote.useCrossOriginEmbedderPolicy': false,
'browser.tabs.remote.useCrossOriginOpenerPolicy': false,
'browser.tabs.remote.separatePrivilegedMozillaWebContentProcess': false,
'fission.autostart': false,
'browser.tabs.remote.systemTriggeredAboutBlankAnywhere': true,
};