Add __dirname and stuffs.

The first patch is to run Play applications in JavaScript console, because of the same reason with one for the plugin test runner.

The latter one is simply to add the `__dirname` property to the Beyond global scope.