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

Commit 73a758b

Browse files
committed
Merge pull request #428 from arv/detect-eval
Remove document.securityPolicy since it is no longer supported
2 parents 91c249e + 15ac358 commit 73a758b

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/wrappers.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,23 @@ window.ShadowDOMPolyfill = {};
1111
var nativePrototypeTable = new WeakMap();
1212
var wrappers = Object.create(null);
1313

14-
// Don't test for eval if document has CSP securityPolicy object and we can
15-
// see that eval is not supported. This avoids an error message in console
16-
// even when the exception is caught
17-
var hasEval = !('securityPolicy' in document) ||
18-
document.securityPolicy.allowsEval;
19-
20-
if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
21-
hasEval = false;
22-
}
14+
function detectEval() {
15+
// Don't test for eval if we're running in a Chrome App environment.
16+
// We check for APIs set that only exist in a Chrome App context.
17+
if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) {
18+
return false;
19+
}
2320

24-
if (hasEval) {
2521
try {
26-
var f = new Function('', 'return true;');
27-
hasEval = f();
22+
var f = new Function('return true;');
23+
return f();
2824
} catch (ex) {
29-
hasEval = false;
25+
return false;
3026
}
3127
}
3228

29+
var hasEval = detectEval();
30+
3331
function assert(b) {
3432
if (!b)
3533
throw new Error('Assertion failed');

0 commit comments

Comments
 (0)