bensu / doo

doo is a library and lein plugin to run cljs.test on different js environments.
Eclipse Public License 1.0
324 stars 63 forks source link

Add support for JFX WebKit Component #138

Open plexus opened 7 years ago

plexus commented 7 years ago

Since Java 8 any Java distribution comes with a complete Webkit inside it as part of JFX. (docs)

It would be fantastic to have support for that in doo, since it would give people a complete headless browser without having to install anything extra.

The Sparkledriver library already provides a nice Clojure interface.

I might get to this myself, but I'm not familiar with the doo sources, and it might be a while before I find the time, so just leaving this here in case someone else wants to tackle this.

plexus commented 7 years ago

A few notes to myself for later reference:

Running some JS code with SparkleDriver looks like this

(require '[sparkledriver.core :refer [with-browser make-browser]]) 
(with-browser [browser (make-browser)]
  ;; needs a DOM loaded to work, data uri for <html></html>
  (fetch! browser "data:text/html;charset=utf-8;base64,PGh0bWw+PC9odG1sPg==")
  (.executeScript browser (slurp "file-path") (into-array String []))

See the JBrowserDriver docs for getting results back from JavaScript.

To handle the jfx case in doo it might be enough to have a big (if (= :sparkledriver js-env) here https://github.com/bensu/doo/blob/master/library/src/doo/core.clj#L262 and fall back to the regular shelling out if the env isn’t sparkledriver/jfx. (thanks @martinklepsch for the tip).