style-src-hash-allowed.html (1491B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Security-Policy" content="style-src 5 'sha256-7kQ1KhZCpEzWtsa0RSpbIL7FU3kPNhE3IJMaNeTclMU=' 6 'sha384-OliBBQtittDq3qDaEttMlHG1viNf50PLjSlvXirHZHpeKApMClrTJz+7VB5RTWdN' 7 'sha512-4/SpqCV0WGbb2QZXBViFlnms4M0I+aUGg9/tIhr10twU89nlMSBLOhi3cVli39kyBZbUAlzk9xcVTMy+JDY+VA=='"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 11 <script> 12 var t = async_test("All style elements should load because they have proper hashes"); 13 document.addEventListener("securitypolicyviolation", t.unreached_func("Should not trigger a security policy violation")); 14 </script> 15 16 <style>#content1 { margin-left: 2px; }</style> 17 <style>#content2 { margin-left: 2px; }</style> 18 <style>#content3 { margin-left: 2px; }</style> 19 </head> 20 <body> 21 <div id='log'></div> 22 23 <div id="content1">Lorem ipsum</div> 24 <div id="content2">Lorem ipsum</div> 25 <div id="content3">Lorem ipsum</div> 26 27 <script> 28 function make_assert(contentId) { 29 var contentEl = document.getElementById(contentId); 30 var marginLeftVal = getComputedStyle(contentEl).getPropertyValue('margin-left'); 31 assert_equals(marginLeftVal, "2px") 32 } 33 t.step(function() { 34 make_assert("content1"); 35 make_assert("content2"); 36 make_assert("content3"); 37 t.done(); 38 }); 39 </script> 40 41 </body> 42 </html>