How to use the chrome-remote-interface/lib/protocol.json.domains.forEach function in chrome-remote-interface

To help you get started, we’ve selected a few chrome-remote-interface examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gwuhaolin / chrome-pool / index.js View on Github external
*/
async function launchChrome(runnerOptions) {
  let runner;
  if (process.env.SHOW_CHROME) {
    runner = await launchWithoutNoise(runnerOptions);
  } else {
    runner = await launchWithHeadless(runnerOptions);
  }
  return runner;
}

/**
 * chrome remote interface protocols data, enable should enable protocols before use
 */
const DomainData = {};
ProtocolDomains.forEach((domain) => {
  const { domain: name, events: domainEvents = [], commands: domainCommands = [] } = domain;
  const hasEnableCommand = domainCommands.findIndex(({ name }) => name === 'enable') >= 0;
  const events = domainEvents.map(({ name }) => name);
  DomainData[name] = {
    hasEnableCommand,
    events,
  }
});

/**
 * ChromePool used to manage chrome tabs, for reuse tab
 * use #new() static method to make a ChromePool, don't use new ChromePool()
 * #new() is a async function, new ChromePool is useable util #ChromePool.new() to be completed
 */
class ChromePool {