Providing an inter-process communication (IPC) mechanism such that a WebPage can explicitly signal back to PhantomJS as a push, thus eliminating/minimizing the need for users to setup polling functions, etc.
In PhantomJS 1.6, @detro added a WebPage onCallback
handler that could be triggered from a webpage client by invoking the specially attached window.callPhantom
function. However, @ariya expressed some discontent with this approach and so the three of us began discussing utilizing an existing API for cross-domain messaging instead: window.postMessage
. (See Discussion for more info.)
PhantomJS currently only allows for a single handler per signal (a separate problem I'm working on over here). As such, automatically attaching internal handler may prevent users from attaching their own handlers for onInitialized
(that's bad) and onCallback
(acceptable, as it's deprecated).
However, I think this could easily be worked around by having a different name for the actual internal handler (i.e. not utilizing page.onInitialized
) but then have that handler include a check for a user-set page.onInitialized
handler function and invoke it if it exists.
cc: @detro, @ariya