Skip to content

Commit

Permalink
fix: also kill Firefox when temporary profile is used (#8233)
Browse files Browse the repository at this point in the history
* fix: also kill Firefox when temporary profile is used

* fix: use separate tests for Puppeteer.launch should filter out ignored default arguments
  • Loading branch information
whimboo authored Apr 19, 2022
1 parent 95c9f39 commit b6504d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/node/BrowserRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion test/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit b6504d7

Please sign in to comment.