Skip to content

Instantly share code, notes, and snippets.

@cvializ
Created May 11, 2016 23:55
Show Gist options
  • Save cvializ/1cf16e9d802bdfd869a793db3a2a72c8 to your computer and use it in GitHub Desktop.
Save cvializ/1cf16e9d802bdfd869a793db3a2a72c8 to your computer and use it in GitHub Desktop.
A function that checks for a Content Security Policy
/* ... */
// Loads an image on the host page to check for a CSP
function loadCspCheck(cb) {
var CSP_CHECK_URL = '//d34db33f.cloudfront.net/assets/tiny.png';
var cspCheckImage = new Image();
cspCheckImage.addEventListener('load', cb.bind(null, false));
cspCheckImage.addEventListener('error', cb.bind(null, true));
cspCheckImage.src = CSP_CHECK_URL;
}
/* ... */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment