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

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

Issue 1151773007: Remove integrity attribute from elements not in SRI spec (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update test results Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="/js-test-resources/js-test.js"></script> 4 <script src="/js-test-resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 description("Some elements should have `integrity` attributes. Others sh ouldn't."); 8 description("Some elements should have `integrity` attributes. Others sh ouldn't.");
9 9
10 var ASSERT_INTEGRITY = 1; 10 var ASSERT_INTEGRITY = 1;
11 var ASSERT_NO_INTEGRITY = 0; 11 var ASSERT_NO_INTEGRITY = 0;
12 12
13 function checkElement(elementName, integrityDisposition) { 13 function checkElement(elementName, integrityDisposition) {
14 var el = document.createElement(elementName); 14 var el = document.createElement(elementName);
15 if (integrityDisposition == ASSERT_INTEGRITY) { 15 if (integrityDisposition == ASSERT_INTEGRITY) {
16 if ("integrity" in el) 16 if ("integrity" in el)
17 testPassed("<" + elementName + "> has an 'integrity' attribu te."); 17 testPassed("<" + elementName + "> has an 'integrity' attribu te.");
18 else 18 else
19 testFailed("<" + elementName + "> does not have an 'integrit y' attribute."); 19 testFailed("<" + elementName + "> does not have an 'integrit y' attribute.");
20 } else { 20 } else {
21 if ("integrity" in el) 21 if ("integrity" in el)
22 testFailed("<" + elementName + "> has an 'integrity' attribu te."); 22 testFailed("<" + elementName + "> has an 'integrity' attribu te.");
23 else 23 else
24 testPassed("<" + elementName + "> does not have an 'integrit y' attribute."); 24 testPassed("<" + elementName + "> does not have an 'integrit y' attribute.");
25 } 25 }
26 } 26 }
27 27
28 var shouldHaveIntegrity = [ 28 var shouldHaveIntegrity = [
29 'link',
30 'script',
31 ];
32
33 var shouldNotHaveIntegrity = [
29 'a', 34 'a',
30 'audio', 35 'audio',
31 'embed', 36 'embed',
32 'iframe', 37 'iframe',
33 'img', 38 'img',
34 'link',
35 'object', 39 'object',
36 'script',
37 'source', 40 'source',
38 'track', 41 'track',
39 'video', 42 'video',
40 ];
41
42 var shouldNotHaveIntegrity = [
43 'body', 43 'body',
44 'div', 44 'div',
45 'html', 45 'html',
46 'meta', 46 'meta',
47 'span', 47 'span',
48 ]; 48 ];
49 49
50 for (var i = 0; i < shouldHaveIntegrity.length; i++) 50 for (var i = 0; i < shouldHaveIntegrity.length; i++)
51 checkElement(shouldHaveIntegrity[i], ASSERT_INTEGRITY); 51 checkElement(shouldHaveIntegrity[i], ASSERT_INTEGRITY);
52 52
53 for (var i = 0; i < shouldNotHaveIntegrity.length; i++) 53 for (var i = 0; i < shouldNotHaveIntegrity.length; i++)
54 checkElement(shouldNotHaveIntegrity[i], ASSERT_NO_INTEGRITY); 54 checkElement(shouldNotHaveIntegrity[i], ASSERT_NO_INTEGRITY);
55 </script> 55 </script>
56 </body> 56 </body>
57 </html> 57 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698