Another approach is to put some code in `listener` to look for a string where phantomjs says that it's ready.