Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
const context = await browser.createIncognitoBrowserContext()
// Set-up page entity
const page = await context.newPage()
if (options.userAgent) {
await page.setUserAgent(options.userAgent)
}
if (options.width && options.height) {
await page.setViewport({
width: options.width,
height: options.height,
})
}
if (options.device) {
if (puppeteer.devices[options.device]) {
await page.emulate(puppeteer.devices[options.device])
} else {
throw new Error(`${options.device} - unknown Device option!`)
}
}
page.on('error', msg => {
throw msg
})
const client = await page.target().createCDPSession()
// Enable Network Emulation
if (options.emulateNetworkConditions) {
await client.send('Network.emulateNetworkConditions', {
offline: options.offline,
latency: options.latency,
downloadThroughput: megabitsToBytes(options.downloadThroughput),
const context = await browser.createIncognitoBrowserContext()
// Set-up page entity
const page = await context.newPage()
if (options.userAgent) {
await page.setUserAgent(options.userAgent)
}
if (options.width && options.height) {
await page.setViewport({
width: options.width,
height: options.height,
})
}
if (options.device) {
if (puppeteer.devices[options.device]) {
await page.emulate(puppeteer.devices[options.device])
} else {
throw new Error(`${options.device} - unknown Device option!`)
}
}
page.on('error', msg => {
throw msg
})
const client = await page.target().createCDPSession()
// Enable Network Emulation
if (options.emulateNetworkConditions) {
await client.send('Network.emulateNetworkConditions', {
offline: options.offline,
latency: options.latency,
downloadThroughput: megabitsToBytes(options.downloadThroughput),
uploadThroughput: megabitsToBytes(options.uploadThroughput),