Support CommonJS environments by accentuating the need for a window with a document. Fixes #13768.