Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should complain if passed args', () => {
// $ExpectError no arguments are expected by function type
(defaultArgs('testing...'): Array);
});
});
it('should complain if passed args', () => {
// $ExpectError no arguments are expected by function type
(puppeteer.defaultArgs('testing...'): Array);
});
});
it('should return a string array', () => {
(puppeteer.defaultArgs(): Array);
});
it('should complain if passed args', () => {
export async function evaluatePage (url, matches, timeout = 4000) {
const args = await puppeteer.defaultArgs();
const browser = await puppeteer.launch({
args: [
...args,
'--no-sandbox',
'--disable-setuid-sandbox',
'--enable-experimental-web-platform-features'
]
});
const page = await browser.newPage();
await page.goto(url);
try {
return await new Promise((resolve, reject) => {
page.on('console', msg => {
const text = msg.text();
if (text.match(matches)) {
(async function() {
const targetRevision = process.argv[2];
if (!targetRevision || String(parseInt(targetRevision, 10)) !== targetRevision) {
console.log('The first argument should be a Chromium revision number, like 338865');
return;
}
const info = await downloadChrome(targetRevision);
childProcess.exec(`${info.executablePath} --remote-debugging-port=9227 --user-data-dir=user-data-dir about:blank`);
const browser = await puppeteer.launch({
executablePath: process.env.CHROMIUM_PATH || CHROMIUM_DEFAULT_PATH,
dumpio: true,
defaultViewport: null,
ignoreDefaultArgs: true,
args: puppeteer.defaultArgs({
headless: false,
args: ['--no-default-browser-check', `--custom-devtools-frontend=http://localhost:9227/devtools/`],
userDataDir: 'debugging-user-data-dir'
}).filter(x => !x.startsWith('--enable-automation'))
});
const page = (await browser.pages())[0];
await page.goto('http://localhost:9227');
const chromeVersion = await page.evaluate(async () => {
const data = await fetch('json/version');
const json = await data.json();
const userAgent = json['User-Agent'];
const start = userAgent.indexOf('Chrome/') + 'Chrome/'.length;
return userAgent.substring(start, userAgent.indexOf(' ', start));
});
console.log(`Launched Chromium ${chromeVersion}`);
await page.bringToFront();
static defaultArgs() {
return Puppeteer.defaultArgs();
}
defaultArgs() {
return puppeteer.defaultArgs();
}