fix(chromium): do not create default page and context in headless (#1247)
This commit is contained in:
parent
b0d037ecfe
commit
e770d706a1
|
|
@ -197,11 +197,13 @@ export class Chromium implements BrowserType {
|
||||||
'--mute-audio'
|
'--mute-audio'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (launchType !== 'persistent')
|
|
||||||
chromeArguments.push('--no-startup-window');
|
|
||||||
chromeArguments.push(...args);
|
chromeArguments.push(...args);
|
||||||
if (args.every(arg => arg.startsWith('-')))
|
if (launchType === 'persistent') {
|
||||||
chromeArguments.push('about:blank');
|
if (args.every(arg => arg.startsWith('-')))
|
||||||
|
chromeArguments.push('about:blank');
|
||||||
|
} else {
|
||||||
|
chromeArguments.push('--no-startup-window');
|
||||||
|
}
|
||||||
|
|
||||||
return chromeArguments;
|
return chromeArguments;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,4 +120,20 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
|
||||||
await rmAsync(downloadsFolder);
|
await rmAsync(downloadsFolder);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('BrowserContext', function() {
|
||||||
|
it('should not create pages automatically', async function() {
|
||||||
|
const browser = await playwright.launch();
|
||||||
|
const browserSession = await browser.createBrowserSession();
|
||||||
|
const targets = [];
|
||||||
|
browserSession.on('Target.targetCreated', async ({targetInfo}) => {
|
||||||
|
if (targetInfo.type !== 'browser')
|
||||||
|
targets.push(targetInfo);
|
||||||
|
});
|
||||||
|
await browserSession.send('Target.setDiscoverTargets', { discover: true });
|
||||||
|
await browser.newContext();
|
||||||
|
await browser.close();
|
||||||
|
expect(targets.length).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue