Skip to content

Commit

Permalink
fix: add CSP listener on document, not window (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjones committed Mar 21, 2022
1 parent cd277ff commit 0398599
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/browser/telemetry.js
Expand Up @@ -731,16 +731,16 @@ Instrumenter.prototype.handleCspError = function(message) {
}

Instrumenter.prototype.deinstrumentContentSecurityPolicy = function() {
if (!('addEventListener' in this._window)) { return; }
if (!('addEventListener' in this._document)) { return; }

this.removeListeners('contentsecuritypolicy');
};

Instrumenter.prototype.instrumentContentSecurityPolicy = function() {
if (!('addEventListener' in this._window)) { return; }
if (!('addEventListener' in this._document)) { return; }

var cspHandler = this.handleCspEvent.bind(this);
this.addListener('contentsecuritypolicy', this._window, 'securitypolicyviolation', null, cspHandler, false);
this.addListener('contentsecuritypolicy', this._document, 'securitypolicyviolation', null, cspHandler, false);
};

Instrumenter.prototype.addListener = function(section, obj, type, altType, handler, capture) {
Expand Down

0 comments on commit 0398599

Please sign in to comment.