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

Commit

Permalink
Remove document.securityPolicy since it is no longer supported
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Apr 28, 2014
1 parent 180af95 commit 15ac358
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,23 @@ window.ShadowDOMPolyfill = {};
var nativePrototypeTable = new WeakMap();
var wrappers = Object.create(null);

// Don't test for eval if document has CSP securityPolicy object and we can
// see that eval is not supported. This avoids an error message in console
// even when the exception is caught
var hasEval = !('securityPolicy' in document) ||
document.securityPolicy.allowsEval;

if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
hasEval = false;
}
function detectEval() {
// Don't test for eval if we're running in a Chrome App environment.
// We check for APIs set that only exist in a Chrome App context.
if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
return false;
}

if (hasEval) {
try {
var f = new Function('', 'return true;');
hasEval = f();
var f = new Function('return true;');
return f();
} catch (ex) {
hasEval = false;
return false;
}
}

var hasEval = detectEval();

function assert(b) {
if (!b)
throw new Error('Assertion failed');
Expand Down

0 comments on commit 15ac358

Please sign in to comment.