Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
helpers.getWebviews = async function getWebviews (adb, {
androidDeviceSocket = null,
ensureWebviewsHavePages = null,
webviewDevtoolsPort = null
} = {}) {
logger.debug('Getting a list of available webviews');
let webviewProcs = await webviewsFromProcs(adb, androidDeviceSocket);
if (ensureWebviewsHavePages) {
logger.info('Retrieved potential webviews; will filter out ones with no active pages');
webviewProcs = await asyncfilter(webviewProcs,
async (wp) => await webviewHasPages(adb, wp, webviewDevtoolsPort),
false /*ensure serial operation*/);
} else {
logger.info('Not checking whether webviews have active pages; use the ' +
"'ensureWebviewsHavePages' cap to turn this check on");
}
// webviewProcs contains procs, which we only care about for ensuring
// presence of pages above, so we can now discard them and rely on just the
// webview names
let webviews = webviewProcs.map((wp) => wp.webview);
if (androidDeviceSocket) {
return webviews;
}