I am developing a cross-domain RPC library for which I want to do some unit-testing using qunit.
In order to do the testing properly I’ve setup a grunt file that launches a node.js server and phantomjs to load the test rpc.html as described here (using a server task so that different domains can be simulated, localhost and 127.0.0.1). This test opens an iframe with frame.html that mocks the RPC commands which are asserted within rpc.html.
So far all good. The problem I am encountering is that whenever a JS error occurs within frame.html it is not outputted to the console. Only errors that happen in rpc.html are shown. Although outputs of console.log() etc are working in frame.html.
Is there a way I can get all JavaScript errors to be shown that occur in frame.html, including parse errors and such?
Thank you in advance.
PhantomJS supports
onErrorevent handlers in itspageobjects, so that information about JavaScript exceptions can be intercepted and handled as appropriate.AFAIK, you should possibly also check if loaded web-pages do not have their own
window.onerror, because if they return true, the errors will be treated as handled.