Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
run-headless-chromium
Advanced tools
Run Chromium or Google Chrome in headless mode and forward the JS console output to the standard output.
Starts Chromium or Google Chrome in headless mode (using Xvfb) and forwards the output from JavaScript console to stdout.
Xvfb only works on Linux and OS X; Windows is not supported.
./run-headless-chromium.js [options]
All [options]
are directly passed to Chromium. All console messages are forwarded to the
standard output of this process. Every message generated by console.log
, console.warn
, etc.
is printed with a newline character at the end, unless the message ends with \x03\b
. This is
a special character sequence interpreted as "not end of newline".
In addition to the JavaScript messages, errors from Chromium are also printed in the console. This behavior can be controlled by two environment variables:
LOG_CR_VERBOSITY
- Only print messages from Chromium with this verbosity level.INFO|WARNING|ERROR|ERROR_REPORT|FATAL|VERBOSE|UNKNOWN
,
defaults to ERROR|ERROR_REPORT|FATAL
. Use LOG_CR_VERBOSITY=.
to show all messages.LOG_CR_HIDE_PATTERN
- Exclude messages matching this pattern (case-insensitive).kwallet
.CHROMIUM_EXE_PATH
- Set the path to the Chromium / Google Chrome executable.Any webpage that is loaded using run-headless-chromium can close Chromium and exit the process
by sending the magic string console.log("All tests completed!");
.
Insert an integer at the end of the string to change the exit code of this program from 0 to
some other integer within the 0 - 255 range.
Headless Chromium is ideal for unit testing, e.g. with Jasmine:
<script src="jasmine/lib/jasmine-core/jasmine.js"></script>
<script src="jasmine/src/console/ConsoleReporter.js"></script>
<script>
var jasmineEnv = jasmine.getEnv();
var consoleReporter = new jasmine.ConsoleReporter(
function print(message) {
// Append magic bytes to signal that the line has not ended yet.
// This is needed because ConsoleReporter will add the trailing newlines
// if desired, i.e. it expects console.log to behave as print, not println.
console.log(message + '\x03\b');
},
function onComplete(runner) {
// 0 = success, 1 = failure
var exitCode = runner.results().failedCount > 0 ? 1 : 0;
// Magic string to signal completion of the tests
console.info('All tests completed!' + exitCode);
},
// showColors (whether to generate colorful output)
true
);
jasmineEnv.addReporter(consoleReporter);
jasmineEnv.execute();
</script>
<script src="jasmine/lib/jasmine-core/jasmine.js"></script>
<script src="jasmine/lib/console/console.js"></script>
<script>
var jasmineEnv = jasmine.getEnv();
var consoleReporter = new jasmine.ConsoleReporter({
print: function print(message) {
console.log(message + '\x03\b');
},
onComplete: function onComplete(isSuccess) {
var exitCode = isSuccess ? 0 : 1;
console.info('All tests completed!' + exitCode);
},
showColors: true
});
jasmineEnv.addReporter(consoleReporter);
jasmineEnv.execute();
</script>
MIT
FAQs
Run Chromium or Google Chrome in headless mode and forward the JS console output to the standard output.
The npm package run-headless-chromium receives a total of 444 weekly downloads. As such, run-headless-chromium popularity was classified as not popular.
We found that run-headless-chromium demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.