This commit fixes an error when user deletes "window" global JS variable. Instead of relying on "window" or "globalThis" to dispatch "load" and "unload" events, we are default to global scope of the worker.