Core: add location global for non-browsers, fix #1788

This is a simple fix that will also prevent future problems with this.
Of course, it would be nice to add a test, but I think it's a bit beyond the scope at the moment.
Poke #1788.
@timmywil, you're right about the unused. Could you clarify what you meant by "a var module"? I am really curious.