mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(Launcher): introduce appMode option
The patch introduces a new appMode option to the launcher. This is an experimental option, thus we don't document it.
This commit is contained in:
committed by
Andrey Lushnikov
parent
1c292e9253
commit
a6cf8237b8
@@ -40,13 +40,15 @@ const DEFAULT_ARGS = [
|
||||
'--disable-prompt-on-repost',
|
||||
'--disable-sync',
|
||||
'--disable-translate',
|
||||
'--enable-automation',
|
||||
'--enable-devtools-experiments',
|
||||
'--metrics-recording-only',
|
||||
'--no-first-run',
|
||||
'--password-store=basic',
|
||||
'--remote-debugging-port=0',
|
||||
'--safebrowsing-disable-auto-update',
|
||||
];
|
||||
|
||||
const AUTOMATION_ARGS = [
|
||||
'--enable-automation',
|
||||
'--password-store=basic',
|
||||
'--use-mock-keychain',
|
||||
];
|
||||
|
||||
@@ -56,9 +58,14 @@ class Launcher {
|
||||
* @return {!Promise<!Browser>}
|
||||
*/
|
||||
static async launch(options) {
|
||||
options = options || {};
|
||||
options = Object.assign({}, options || {});
|
||||
let temporaryUserDataDir = null;
|
||||
const chromeArguments = [].concat(DEFAULT_ARGS);
|
||||
if (options.appMode)
|
||||
options.headless = false;
|
||||
else
|
||||
chromeArguments.push(...AUTOMATION_ARGS);
|
||||
|
||||
if (!options.args || !options.args.some(arg => arg.startsWith('--user-data-dir'))) {
|
||||
if (!options.userDataDir)
|
||||
temporaryUserDataDir = fs.mkdtempSync(CHROME_PROFILE_PATH);
|
||||
@@ -105,7 +112,7 @@ class Launcher {
|
||||
const connectionDelay = options.slowMo || 0;
|
||||
const browserWSEndpoint = await waitForWSEndpoint(chromeProcess, options.timeout || 30 * 1000);
|
||||
const connection = await Connection.create(browserWSEndpoint, connectionDelay);
|
||||
return new Browser(connection, !!options.ignoreHTTPSErrors, killChrome);
|
||||
return new Browser(connection, options, killChrome);
|
||||
} catch (e) {
|
||||
killChrome();
|
||||
throw e;
|
||||
@@ -150,12 +157,12 @@ class Launcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} options
|
||||
* @param {!Object=} options
|
||||
* @return {!Promise<!Browser>}
|
||||
*/
|
||||
static async connect({browserWSEndpoint, ignoreHTTPSErrors = false}) {
|
||||
const connection = await Connection.create(browserWSEndpoint);
|
||||
return new Browser(connection, !!ignoreHTTPSErrors);
|
||||
static async connect(options = {}) {
|
||||
const connection = await Connection.create(options.browserWSEndpoint);
|
||||
return new Browser(connection, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user