Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chrome-pool

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-pool - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

48

index.js

@@ -5,2 +5,3 @@ 'use strict';

const chrome = require('chrome-remote-interface');
const ProtocolDomains = require('chrome-remote-interface/lib/protocol.json').domains;

@@ -24,25 +25,12 @@ /**

// https://chromedevtools.github.io/devtools-protocol/
const ShouldEnableBeforeUseProtocolNames = {
'Animation': true,
'ApplicationCache': true,
'CSS': true,
'CacheStorage': true,
'Console': true,
'DOM': true,
'DOMStorage': true,
'Database': true,
'Debugger': true,
'HeapProfiler': true,
'IndexedDB': true,
'Inspector': true,
'LayerTree': true,
'Log': true,
'Network': true,
'Overlay': true,
'Page': true,
'Profiler': true,
'Security': true,
'ServiceWorker': true,
}
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,
}
});

@@ -78,3 +66,3 @@ /**

chromePoll.protocols.forEach(name => {
if (ShouldEnableBeforeUseProtocolNames[name]) {
if (DomainData[name].hasEnableCommand) {
chromePoll.shouldEnabledProtocol.add(name);

@@ -178,6 +166,16 @@ }

let tab = this.tabs[tabId];
tab.free = true;
// navigate this tab to blank to release this tab's resource
// https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-navigate
tab.free = true;
tab.protocol.Page.navigate({ url: 'about:blank' });
// remove all listeners to fix MaxListenersExceededWarning: Possible EventEmitter memory leak detected
this.protocols.forEach((domainName) => {
const { events } = DomainData[domainName];
events.forEach((eventName) => {
tab.protocol.removeAllListeners(`${domainName}.${eventName}`);
});
})
if (this.requireResolveTasks.length > 0) {

@@ -184,0 +182,0 @@ const resolve = this.requireResolveTasks.shift();

@@ -8,2 +8,3 @@ 'use strict';

describe('#ChromePool', function () {
this.timeout(5000);

@@ -10,0 +11,0 @@ it('#new() #destroyPoll()', async () => {

{
"name": "chrome-pool",
"version": "1.0.6",
"version": "1.0.7",
"description": "headless chrome tabs manage pool",

@@ -5,0 +5,0 @@ "keywords": [

@@ -60,2 +60,3 @@ [![Npm Package](https://img.shields.io/npm/v/chrome-pool.svg?style=flat-square)](https://www.npmjs.com/package/chrome-pool)

```
`release` will all resource used by this tab include removeAllListeners.

@@ -62,0 +63,0 @@ see [test](./index.test.js) for more use case.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc