repositorypackage
0.0.0-20240223211520-370e96cf88e8
Repository: https://github.com/niklasfasching/headless.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
- Example #+begin_src bash $ headless -c " console.log('yolo'); window.close(1); " yolo exit status 1 #+end_src
- Motivation I want to run js in a headless browser from bash - e.g. to automate running my clientside js tests. There's a lot of js test runners and libraries for controlling headless browsers out there already. But those are huge and the [[https://chromedevtools.github.io/devtools-protocol/][devtools protocol]] provides us with all we need:
- [[https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-navigate][Page.navigate]] + [[https://chromedevtools.github.io/devtools-protocol/tot/Page/#event-frameStoppedLoading][Page.frameStoppedLoading]] to open a page containing the script to run as well as some setup code
- [[https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#event-exceptionThrown][Runtime.ExceptionThrown]] notifies us of uncaught exceptions
- [[https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-addBinding][Runtime.addBinding]] + [[https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#event-bindingCalled][Runtime.bindingCalled]] + [[https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-evaluate][Runtime.evaluate]] with a sprinkle of reflection to bridge the gap between between go and js