Skip to content

Firefox content script does not allow clearTimeout and clearInterval to be called in a non-global context #37333

@spaceribs

Description

@spaceribs

🐞 bug report

Affected Package

The issue is caused by package @angular/zone.js

Is this a regression?

No

Description

A clear and concise description of the problem...

When calling clearInterval or clearTimeout in the restricted context of a content script on Firefox with ZoneJS initialized, the call will error out because the function is no longer being called in the context of the window.

🔬 Minimal Reproduction

Difficult to recreate, I'll update my previous testing repo later today.

🔥 Exception or Error


ERROR TypeError: "'clearInterval' called on an object that does not implement interface Window."

image

🌍 Your Environment

Angular Version:


Angular CLI: 9.1.1
Node: 12.16.3
OS: darwin x64

Angular: 9.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.1
@angular-devkit/build-angular     0.901.1
@angular-devkit/build-optimizer   0.901.1
@angular-devkit/build-webpack     0.901.1
@angular-devkit/core              9.1.1
@angular-devkit/schematics        9.1.1
@angular/cdk                      9.2.1
@ngtools/webpack                  9.1.1
@schematics/angular               9.1.1
@schematics/update                0.901.1
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Anything else relevant?

This applies only to Firefox Web Extension content scripts, a temporary patch to work around this issue is below, placed after the zone.js import in polyfills.ts:

const patchedClearTimeout = window.clearTimeout;
window.clearTimeout = function(...args) {
  return patchedClearTimeout.apply(window, args);
};

const patchedClearInterval = window.clearInterval;
window.clearInterval = function(...args) {
  return patchedClearInterval.apply(window, args);
};

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions