fix: reset SNAP* env variables when launching Firefox (#20692)

Our builds never come from Snap, so Playwright's Firefox should
never consider that it's been installed via SNAP.

Fixes #20555

---------

Signed-off-by: Andrey Lushnikov <aslushnikov@gmail.com>
Co-authored-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Andrey Lushnikov 2023-02-07 01:41:12 -08:00 committed by GitHub
parent 439d3cefcf
commit d3c5430080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,12 @@ export class Firefox extends BrowserType {
_amendEnvironment(env: Env, userDataDir: string, executable: string, browserArguments: string[]): Env {
if (!path.isAbsolute(os.homedir()))
throw new Error(`Cannot launch Firefox with relative home directory. Did you set ${os.platform() === 'win32' ? 'USERPROFILE' : 'HOME'} to a relative path?`);
if (os.platform() === 'linux') {
// Always remove SNAP_NAME and SNAP_INSTANCE_NAME env variables since they
// confuse Firefox: in our case, builds never come from SNAP.
// See https://github.com/microsoft/playwright/issues/20555
return { ...env, SNAP_NAME: undefined, SNAP_INSTANCE_NAME: undefined };
}
return env;
}