Index: LayoutTests/http/tests/security/subresourceIntegrity/integrity-attribute.html |
diff --git a/LayoutTests/http/tests/security/subresourceIntegrity/integrity-attribute.html b/LayoutTests/http/tests/security/subresourceIntegrity/integrity-attribute.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4f7851512737dd5bdc26b93a33766b3400a11ebd |
--- /dev/null |
+++ b/LayoutTests/http/tests/security/subresourceIntegrity/integrity-attribute.html |
@@ -0,0 +1,57 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+ <script src="/js-test-resources/js-test.js"></script> |
+ </head> |
+<body> |
+ <script> |
+ description("Some elements should have `integrity` attributes. Others shouldn't."); |
+ |
+ var ASSERT_INTEGRITY = 1; |
+ var ASSERT_NO_INTEGRITY = 0; |
+ |
+ function checkElement(elementName, integrityDisposition) { |
+ var el = document.createElement(elementName); |
+ if (integrityDisposition == ASSERT_INTEGRITY) { |
+ if ("integrity" in el) |
+ testPassed("<" + elementName + "> has an 'integrity' attribute."); |
+ else |
+ testFailed("<" + elementName + "> does not have an 'integrity' attribute."); |
+ } else { |
+ if ("integrity" in el) |
+ testFailed("<" + elementName + "> has an 'integrity' attribute."); |
+ else |
+ testPassed("<" + elementName + "> does not have an 'integrity' attribute."); |
+ } |
+ } |
+ |
+ var shouldHaveIntegrity = [ |
+ 'a', |
+ 'audio', |
+ 'embed', |
+ 'iframe', |
+ 'img', |
+ 'link', |
+ 'object', |
+ 'script', |
+ 'source', |
+ 'track', |
+ 'video', |
+ ]; |
+ |
+ var shouldNotHaveIntegrity = [ |
+ 'body', |
+ 'div', |
+ 'html', |
+ 'meta', |
+ 'span', |
+ ]; |
+ |
+ for (var i = 0; i < shouldHaveIntegrity.length; i++) |
+ checkElement(shouldHaveIntegrity[i], ASSERT_INTEGRITY); |
+ |
+ for (var i = 0; i < shouldNotHaveIntegrity.length; i++) |
+ checkElement(shouldNotHaveIntegrity[i], ASSERT_NO_INTEGRITY); |
+ </script> |
+</body> |
+</html> |