Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Changed hasEval test to avoid console error if browser supports secur…
Browse files Browse the repository at this point in the history
…ityPolicy.

If securityPolicy is not supported, use the previous try/catch procedure.
CSP errors are always sent to console, even when they get caught in a try/catch block.
  • Loading branch information
mangini committed Sep 3, 2013
1 parent db1d00d commit e4ffed1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@

var hasEval = false;
try {
var f = new Function('', 'return true;');
hasEval = f();
if ('securityPolicy' in document) {
hasEval = document.securityPolicy.allowsEval === true;
} else {
var f = new Function('', 'return true;');
hasEval = f();
}
} catch (ex) {
}

Expand Down

0 comments on commit e4ffed1

Please sign in to comment.