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/addEventListeneroff/removeEventListeneremit(strictly for triggering handlers within the PhantomJS context)
I would argue that we may need not any kind of
window.top.parentoverride (my suggestions was either and not both parent and CustomEvent). Perhaps we can get away by having a special name of the custom event, e.g.:which means that the event can be emitted in any place, wherever
dispatchEventis available.Any other kind of mapping for the convention, e.g.
phantomjs:foo->page.on("foo", ...), is also a further possibility.