fix: also kill Firefox when temporary profile is used (#8233)

* fix: also kill Firefox when temporary profile is used

* fix: use separate tests for Puppeteer.launch should filter out ignored default arguments
This commit is contained in:
Henrik Skupin 2022-04-19 14:09:23 +02:00 committed by GitHub
parent 95c9f392e2
commit b6504d7186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -164,7 +164,7 @@ export class BrowserRunner {
close(): Promise<void> {
if (this._closed) return Promise.resolve();
if (this._isTempUserDataDir && this._product !== 'firefox') {
if (this._isTempUserDataDir) {
this.kill();
} else if (this.connection) {
// Attempt to close the browser gracefully

View File

@ -404,7 +404,7 @@ describe('Launcher specs', function () {
await page.close();
await browser.close();
});
it('should filter out ignored default arguments', async () => {
itChromeOnly('should filter out ignored default arguments', async () => {
const { defaultBrowserOptions, puppeteer } = getTestState();
// Make sure we launch with `--enable-automation` by default.
const defaultArgs = puppeteer.defaultArgs();
@ -423,6 +423,25 @@ describe('Launcher specs', function () {
expect(spawnargs.indexOf(defaultArgs[2])).toBe(-1);
await browser.close();
});
itFirefoxOnly('should filter out ignored default arguments', async () => {
const { defaultBrowserOptions, puppeteer } = getTestState();
const defaultArgs = puppeteer.defaultArgs();
const browser = await puppeteer.launch(
Object.assign({}, defaultBrowserOptions, {
// Only the first argument is fixed, others are optional.
ignoreDefaultArgs: [defaultArgs[0]],
})
);
const spawnargs = browser.process().spawnargs;
if (!spawnargs) {
throw new Error('spawnargs not present');
}
expect(spawnargs.indexOf(defaultArgs[0])).toBe(-1);
expect(spawnargs.indexOf(defaultArgs[1])).not.toBe(-1);
await browser.close();
});
it('should have default URL when launching browser', async function () {
const { defaultBrowserOptions, puppeteer } = getTestState();
const browser = await puppeteer.launch(defaultBrowserOptions);