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