Skip to content

Commit

Permalink
Extract default flags to standalone entity.
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed May 13, 2017
1 parent b6a3ce5 commit 6aa4fbc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 61 deletions.
26 changes: 5 additions & 21 deletions chrome-launcher/chrome-launcher.ts
Expand Up @@ -22,6 +22,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as chromeFinder from './chrome-finder';
import {ask} from './ask';
import {DEFAULT_FLAGS} from './flags';

const mkdirp = require('mkdirp');
import * as net from 'net';
Expand Down Expand Up @@ -57,29 +58,12 @@ export class ChromeLauncher {
this.port = defaults(opts.port, 9222);
}

flags() {
const flags = [
get flags() {
const flags = DEFAULT_FLAGS.concat([
`--remote-debugging-port=${this.port}`,
// Disable built-in Google Translate service
'--disable-translate',
// Disable all chrome extensions entirely
'--disable-extensions',
// Disable various background network services, including extension updating,
// safe browsing service, upgrade detector, translate, UMA
'--disable-background-networking',
// Disable fetching safebrowsing lists, likely redundant due to disable-background-networking
'--safebrowsing-disable-auto-update',
// Disable syncing to a Google account
'--disable-sync',
// Disable reporting to UMA, but allows for collection
'--metrics-recording-only',
// Disable installation of default apps on first run
'--disable-default-apps',
// Skip first run wizards
'--no-first-run',
// Place Chrome profile in a custom location we'll rm -rf later
`--user-data-dir=${this.TMP_PROFILE_DIR}`
];
]);

if (process.platform === 'linux') {
flags.push('--disable-setuid-sandbox');
Expand Down Expand Up @@ -146,7 +130,7 @@ export class ChromeLauncher {
}

const chrome = spawn(
execPath, this.flags(), {detached: true, stdio: ['ignore', this.outFile, this.errFile]});
execPath, this.flags, {detached: true, stdio: ['ignore', this.outFile, this.errFile]});
this.chrome = chrome;

fs.writeFileSync(this.pidFile, chrome.pid.toString());
Expand Down
19 changes: 19 additions & 0 deletions chrome-launcher/flags.ts
@@ -0,0 +1,19 @@
export const DEFAULT_FLAGS = [
// Disable built-in Google Translate service
'--disable-translate',
// Disable all chrome extensions entirely
'--disable-extensions',
// Disable various background network services, including extension updating,
// safe browsing service, upgrade detector, translate, UMA
'--disable-background-networking',
// Disable fetching safebrowsing lists, likely redundant due to disable-background-networking
'--safebrowsing-disable-auto-update',
// Disable syncing to a Google account
'--disable-sync',
// Disable reporting to UMA, but allows for collection
'--metrics-recording-only',
// Disable installation of default apps on first run
'--disable-default-apps',
// Skip first run wizards
'--no-first-run',
];
40 changes: 0 additions & 40 deletions chrome-launcher/test/global-mocha-hooks.js

This file was deleted.

0 comments on commit 6aa4fbc

Please sign in to comment.