Fixes #1543 - window.location.origin not always defined, appears to be browser+scenario dependent.
Merge branch 'tilovell/1543-windowlocationoriginJSbug' into dev