mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
browser(firefox): roll Firefoxes (#22998)
Fixes https://github.com/microsoft/playwright/issues/15405 Fixes https://github.com/microsoft/playwright/issues/22618
This commit is contained in:
parent
ba0c4951c3
commit
eea7a8e638
@ -21,13 +21,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "firefox",
|
"name": "firefox",
|
||||||
"revision": "1406",
|
"revision": "1408",
|
||||||
"installByDefault": true,
|
"installByDefault": true,
|
||||||
"browserVersion": "113.0"
|
"browserVersion": "113.0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "firefox-beta",
|
"name": "firefox-beta",
|
||||||
"revision": "1408",
|
"revision": "1410",
|
||||||
"installByDefault": false,
|
"installByDefault": false,
|
||||||
"browserVersion": "114.0b3"
|
"browserVersion": "114.0b3"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { kBrowserClosedError } from '../../common/errors';
|
import { kBrowserClosedError } from '../../common/errors';
|
||||||
import { assert } from '../../utils';
|
import { assert, getAsBooleanFromENV } from '../../utils';
|
||||||
import type { BrowserOptions } from '../browser';
|
import type { BrowserOptions } from '../browser';
|
||||||
import { Browser } from '../browser';
|
import { Browser } from '../browser';
|
||||||
import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext';
|
import { assertBrowserContextIsNotOwned, BrowserContext, verifyGeolocation } from '../browserContext';
|
||||||
@ -41,8 +41,14 @@ export class FFBrowser extends Browser {
|
|||||||
const browser = new FFBrowser(connection, options);
|
const browser = new FFBrowser(connection, options);
|
||||||
if ((options as any).__testHookOnConnectToBrowser)
|
if ((options as any).__testHookOnConnectToBrowser)
|
||||||
await (options as any).__testHookOnConnectToBrowser();
|
await (options as any).__testHookOnConnectToBrowser();
|
||||||
|
let firefoxUserPrefs = options.persistent ? {} : options.originalLaunchOptions.firefoxUserPrefs ?? {};
|
||||||
|
if (Object.keys(kBandaidFirefoxUserPrefs).length)
|
||||||
|
firefoxUserPrefs = { ...kBandaidFirefoxUserPrefs, ...firefoxUserPrefs };
|
||||||
const promises: Promise<any>[] = [
|
const promises: Promise<any>[] = [
|
||||||
connection.send('Browser.enable', { attachToDefaultContext: !!options.persistent }),
|
connection.send('Browser.enable', {
|
||||||
|
attachToDefaultContext: !!options.persistent,
|
||||||
|
userPrefs: Object.entries(firefoxUserPrefs).map(([name, value]) => ({ name, value })),
|
||||||
|
}),
|
||||||
browser._initVersion(),
|
browser._initVersion(),
|
||||||
];
|
];
|
||||||
if (options.persistent) {
|
if (options.persistent) {
|
||||||
@ -408,3 +414,8 @@ function toJugglerProxyOptions(proxy: types.ProxySettings) {
|
|||||||
password: proxy.password
|
password: proxy.password
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prefs for quick fixes that didn't make it to the build.
|
||||||
|
// Should all be moved to `playwright.cfg`.
|
||||||
|
const kBandaidFirefoxUserPrefs = {};
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { FFBrowser } from './ffBrowser';
|
import { FFBrowser } from './ffBrowser';
|
||||||
import { kBrowserCloseMessageId } from './ffConnection';
|
import { kBrowserCloseMessageId } from './ffConnection';
|
||||||
@ -26,7 +25,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 { getAsBooleanFromENV, wrapInASCIIBox } from '../../utils';
|
import { wrapInASCIIBox } from '../../utils';
|
||||||
|
|
||||||
export class Firefox extends BrowserType {
|
export class Firefox extends BrowserType {
|
||||||
constructor(playwrightOptions: PlaywrightOptions) {
|
constructor(playwrightOptions: PlaywrightOptions) {
|
||||||
@ -67,17 +66,6 @@ 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');
|
||||||
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) {
|
|
||||||
const lines: string[] = [];
|
|
||||||
for (const [name, value] of Object.entries(firefoxUserPrefs))
|
|
||||||
lines.push(`user_pref(${JSON.stringify(name)}, ${JSON.stringify(value)});`);
|
|
||||||
fs.writeFileSync(path.join(userDataDir, 'user.js'), lines.join('\n'));
|
|
||||||
}
|
|
||||||
const firefoxArguments = ['-no-remote'];
|
const firefoxArguments = ['-no-remote'];
|
||||||
if (headless) {
|
if (headless) {
|
||||||
firefoxArguments.push('-headless');
|
firefoxArguments.push('-headless');
|
||||||
@ -96,14 +84,3 @@ export class Firefox extends BrowserType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefs for quick fixes that didn't make it to the build.
|
|
||||||
// Should all be moved to `playwright.cfg`.
|
|
||||||
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,
|
|
||||||
};
|
|
||||||
|
|||||||
@ -8,6 +8,10 @@ export module Protocol {
|
|||||||
browserContextId?: string;
|
browserContextId?: string;
|
||||||
openerId?: string;
|
openerId?: string;
|
||||||
};
|
};
|
||||||
|
export type UserPreference = {
|
||||||
|
name: string;
|
||||||
|
value: any;
|
||||||
|
};
|
||||||
export type CookieOptions = {
|
export type CookieOptions = {
|
||||||
name: string;
|
name: string;
|
||||||
value: string;
|
value: string;
|
||||||
@ -71,6 +75,10 @@ export module Protocol {
|
|||||||
}
|
}
|
||||||
export type enableParameters = {
|
export type enableParameters = {
|
||||||
attachToDefaultContext: boolean;
|
attachToDefaultContext: boolean;
|
||||||
|
userPrefs?: {
|
||||||
|
name: string;
|
||||||
|
value: any;
|
||||||
|
}[];
|
||||||
};
|
};
|
||||||
export type enableReturnValue = void;
|
export type enableReturnValue = void;
|
||||||
export type createBrowserContextParameters = {
|
export type createBrowserContextParameters = {
|
||||||
|
|||||||
@ -163,7 +163,6 @@ it.describe('screencast', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should work with old options', async ({ browser, browserName, trace, headless, isWindows }, testInfo) => {
|
it('should work with old options', async ({ browser, browserName, trace, headless, isWindows }, testInfo) => {
|
||||||
it.fixme(browserName === 'firefox' && !headless && isWindows, 'https://github.com/microsoft/playwright/issues/22618');
|
|
||||||
const videosPath = testInfo.outputPath('');
|
const videosPath = testInfo.outputPath('');
|
||||||
// Firefox does not have a mobile variant and has a large minimum size (500 on windows and 450 elsewhere).
|
// Firefox does not have a mobile variant and has a large minimum size (500 on windows and 450 elsewhere).
|
||||||
const size = browserName === 'firefox' ? { width: 500, height: 400 } : { width: 320, height: 240 };
|
const size = browserName === 'firefox' ? { width: 500, height: 400 } : { width: 320, height: 240 };
|
||||||
@ -188,7 +187,6 @@ it.describe('screencast', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should capture static page', async ({ browser, browserName, trace, headless, isWindows }, testInfo) => {
|
it('should capture static page', async ({ browser, browserName, trace, headless, isWindows }, testInfo) => {
|
||||||
it.fixme(browserName === 'firefox' && !headless && isWindows, 'https://github.com/microsoft/playwright/issues/22618');
|
|
||||||
// Firefox does not have a mobile variant and has a large minimum size (500 on windows and 450 elsewhere).
|
// Firefox does not have a mobile variant and has a large minimum size (500 on windows and 450 elsewhere).
|
||||||
const size = browserName === 'firefox' ? { width: 500, height: 400 } : { width: 320, height: 240 };
|
const size = browserName === 'firefox' ? { width: 500, height: 400 } : { width: 320, height: 240 };
|
||||||
const context = await browser.newContext({
|
const context = await browser.newContext({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user