From 16e282b296cfc17510c5d41a34df73ca1ba0fd3f Mon Sep 17 00:00:00 2001 From: Mike West Date: Sat, 11 Aug 2012 14:48:47 +0200 Subject: [PATCH] Add a check for Content Security Policy (CSP). The current editor's draft of the Content Security Policy 1.1 spec defines an experimental feature detection API[1]. The feature is implemented in WebKit behind a flag. Currently, only Chrome 22+ has that flag enabled by default, but let's hope that changes going forward. [1]: https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html --- feature-detects/contentsecuritypolicy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 feature-detects/contentsecuritypolicy.js diff --git a/feature-detects/contentsecuritypolicy.js b/feature-detects/contentsecuritypolicy.js new file mode 100644 index 0000000000..ee1ddb857a --- /dev/null +++ b/feature-detects/contentsecuritypolicy.js @@ -0,0 +1,10 @@ +// Test for (experimental) Content Security Policy 1.1 support. +// +// This feature is still quite experimental, but is available now in Chrome 22. +// If the `SecurityPolicy` property is available, you can be sure the browser +// supports CSP. If it's not available, the browser still might support an +// earlier version of the CSP spec. +// +// Editor's Draft: https://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html + +Modernizr.addTest('contentsecuritypolicy', 'SecurityPolicy' in document);