fix(electron): make sure user arguments go first (#29204)

This commit is contained in:
Yury Semikhatsky 2024-01-29 15:00:12 -08:00 committed by GitHub
parent 82f40d0802
commit ad6e40538a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -135,12 +135,13 @@ export class Electron extends SdkObject {
controller.setLogName('browser');
return controller.run(async progress => {
let app: ElectronApplication | undefined = undefined;
// --remote-debugging-port=0 must be the last playwright's argument, loader.ts relies on it.
const electronArguments = ['--inspect=0', '--remote-debugging-port=0', ...args];
if (os.platform() === 'linux') {
const runningAsRoot = process.geteuid && process.geteuid() === 0;
if (runningAsRoot && electronArguments.indexOf('--no-sandbox') === -1)
electronArguments.push('--no-sandbox');
electronArguments.unshift('--no-sandbox');
}
const artifactsDir = await fs.promises.mkdtemp(ARTIFACTS_FOLDER);

View File

@ -17,9 +17,10 @@
const { app } = require('electron');
const { chromiumSwitches } = require('../chromium/chromiumSwitches');
// [Electron, -r, loader.js, --inspect=0, --remote-debugging-port=0, ...args]
process.argv.splice(1, 4);
// Always pass user arguments first, see https://github.com/microsoft/playwright/issues/16614 and
// https://github.com/microsoft/playwright/issues/29198.
// [Electron, -r, loader.js[, --no-sandbox>], --inspect=0, --remote-debugging-port=0, ...args]
process.argv.splice(1, process.argv.indexOf('--remote-debugging-port=0'));
for (const arg of chromiumSwitches) {
const match = arg.match(/--([^=]*)=?(.*)/)!;