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 authored Mar 21, 2022
1 parent 73c8fbd commit dd89060
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sdks/rollbar.js/src/browser/telemetry.js
Original file line number Diff line number Diff line change
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 dd89060

Please sign in to comment.