Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 53b06a2

Browse files
Closure Teamcopybara-github
authored andcommitted
The global scope in Workers is called self instead of window. However to be more generic we can use globalThis instead.
RELNOTES: Fix errors in errorhandler.js in Worker contexts PiperOrigin-RevId: 504290713 Change-Id: I6f8f8db4c80a85814bd083693227334627e86f02
1 parent 41a3ba0 commit 53b06a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

closure/goog/debug/errorhandler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ goog.debug.ErrorHandler.prototype.protectWindowSetInterval = function() {
217217
*/
218218
goog.debug.ErrorHandler.prototype.catchUnhandledRejections = function(win) {
219219
'use strict';
220-
win = win || goog.global['window'];
220+
win = win || goog.global['window'] || goog.global['globalThis'];
221221
if ('onunhandledrejection' in win) {
222222
win.onunhandledrejection = (event) => {
223223
// event.reason contains the rejection reason. When an Error is
@@ -238,7 +238,7 @@ goog.debug.ErrorHandler.prototype.catchUnhandledRejections = function(win) {
238238
goog.debug.ErrorHandler.prototype.protectWindowRequestAnimationFrame =
239239
function() {
240240
'use strict';
241-
var win = goog.global['window'];
241+
const win = goog.global['window'] || goog.global['globalThis'];
242242
var fnNames = [
243243
'requestAnimationFrame', 'mozRequestAnimationFrame', 'webkitAnimationFrame',
244244
'msRequestAnimationFrame'
@@ -261,7 +261,7 @@ goog.debug.ErrorHandler.prototype.protectWindowRequestAnimationFrame =
261261
goog.debug.ErrorHandler.prototype.protectWindowFunctionsHelper_ = function(
262262
fnName) {
263263
'use strict';
264-
var win = goog.global['window'];
264+
const win = goog.global['window'] || goog.global['globalThis'];
265265
var originalFn = win[fnName];
266266
if (!originalFn) throw new Error(fnName + ' not on global?');
267267
var that = this;
@@ -328,7 +328,7 @@ goog.debug.ErrorHandler.prototype.setPrefixErrorMessages = function(
328328
goog.debug.ErrorHandler.prototype.disposeInternal = function() {
329329
'use strict';
330330
// Try to unwrap window.setTimeout and window.setInterval.
331-
var win = goog.global['window'];
331+
const win = goog.global['window'] || goog.global['globalThis'];
332332
win.setTimeout = this.unwrap(win.setTimeout);
333333
win.setInterval = this.unwrap(win.setInterval);
334334

0 commit comments

Comments
 (0)