Fixes #13760. Pass window, not this to the main IIFE. Closes gh-1238