New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

run-headless-chromium

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

run-headless-chromium - npm Package Compare versions

Comparing version 0.0.14 to 0.1.0

headless-chromium.js

3

package.json
{
"name": "run-headless-chromium",
"version": "0.0.14",
"version": "0.1.0",
"description": "Run Chromium or Google Chrome in headless mode and forward the JS console output to the standard output.",
"author": "Rob Wu <rob@robwu.nl> (https://robwu.nl/)",
"bin": "./run-headless-chromium.js",
"main": "./headless-chromium.js",
"license": "MIT",

@@ -8,0 +9,0 @@ "repository": "https://github.com/CodeYellowBV/run-headless-chromium",

@@ -86,4 +86,33 @@ Starts Chromium or Google Chrome in headless mode (using Xvfb) and forwards the output from JavaScript console to stdout.

### Node.js
The following example shows how to start `run-headless-chromium` from Node.js,
and terminate the process in a graceful way. Note that the page from the example
does not call `console.info('All tests completed!0')`, so the browser would stay
around indefinitely if we do not explicitly kill it.
```javascript
// spawn has the same API as child_process.spawn, minus the command argument.
// See the "spawn" method at https://nodejs.org/api/child_process.html
var spawnHeadlessChromium = require('run-headless-chromium').spawn;
var proc = spawnHeadlessChromium([
// Flags forwarded to Chromium:
'https://example.com/some_page_that_does_not_print_exit_message',
], {
stdio: 'inherit',
});
proc.on('close', function() {
clearTimeout(delayedExit);
console.log('Headless Chromium exited!');
});
var delayedExit = setTimeout(function() {
console.log('Chrome did not exit within a few seconds, sending SIGINT...');
// Graceful exit - allow run-headless-chromium to exit Chrome and Xvfb.
proc.kill('SIGINT');
// If you do proc.kill(); then Chrome and Xvfb may still hang around.
}, 5000);
```
## License
MIT
#!/usr/bin/env node
'use strict';
if (require.main !== module) {
throw new Error('This is not a requirable module. Use child_process to launch this module!');
}
var os = require('os');

@@ -150,2 +146,11 @@ var path = require('path');

});
process.once('SIGINT', function() {
if (!crProcessExited) {
// This should trigger the 'exit' event on crProcess, which in turn
// cleans up Xvfb.
crProcess.kill();
}
// If `crProcessExited` is true and we received the event, then we
// are still in the process of exiting Xvfb. So ignore the signal.
});
_toggle_crProcessEvents(true);

@@ -152,0 +157,0 @@ function _toggle_crProcessEvents(register) {

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