Created
May 11, 2016 23:55
-
-
Save cvializ/1cf16e9d802bdfd869a793db3a2a72c8 to your computer and use it in GitHub Desktop.
A function that checks for a Content Security Policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
// 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