Consider feature detection #37
Do you mean the boolean falling out of this expression isn't enough?
"integrity" in document.createElement("script")(I guess it isn't useful if you want to know whether a CSP directive for SRI would work. But then, knowing that in JS isn't helping either)
Yes, that is useful for basic SRI existence detection. However, I was thinking that there are likely to be further features we develop (such as download support, for example) where it might be useful for a developer to know if the user agent supports it (or maybe even just what hashing algorithms the user agent supports). Not sure it's worth the effort, though.
What kind of interface do you suggest to find out which hashing algorithms the user agent supports? This gets trickier with CSP directives.
For downloads, the previous example still works, just for a elements, instead of script ;)
Today, a developer that may want to use SRI has no way to detect if the given user agent supports SRI at all (other than user agent sniffing), much less the SRI features that the user agent provides. While the later is not that important since there's only one set of features today, that is likely to change as of v2, and the former is already problematic (see the use case in #36).
It might be useful to provide a
navigator.integrityFeaturesvalue, or something similar, that provides a list of resources that use SRI.