Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: LayoutTests/http/tests/security/subresourceIntegrity/integrity-attribute.html

Issue 208423011: SRI: Add the 'integrity' attribute, and a SubresourceIntegrity runtime flag. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698