Call mainFun even if window and document aren't defined in javascript runtime

This allows Javascript runtimes without those objects to run code generated by Idris.

/cc @raichoo