A brief example of the latest idea for communicating with PhantomJS from the client-side.
This is the next revision of ideas discussed in a previous Gist:
https://gist.github.com/JamesMGreene/3716654
This example demonstrates shimming in the new communication channels under discussion via existing methods (WebPage#onCallback
and window.callPhantom
).
The example does, however, take advantage of a yet-to-be-implemented EventEmitter API for core modules in the PhantomJS outer context. This API would add the following methods to core modules as appropriate:
on
/addEventListener
off
/removeEventListener
emit
(strictly for triggering handlers within the PhantomJS context)
I'm not sure
dispatchEvent
on other thanwindow
makes sense. We just have to play with different code examples and see what works.I think extra hook is still necessary somewhere in QtWebKit bridge to let us detect and process those custom events. I don't think Qt provides an API for that yet. Also, I like the idea of the capture event listener.