source-file-data-scheme.html (1077B)
1 <!DOCTYPE html> 2 <meta http-equiv="Content-Security-Policy" content="script-src 'nonce-abc' data:"> 3 <script nonce="abc" src="/resources/testharness.js"></script> 4 <script nonce="abc" src="/resources/testharnessreport.js"></script> 5 <script nonce="abc"> 6 async_test(t => { 7 var watcher = new EventWatcher(t, document, 'securitypolicyviolation'); 8 watcher.wait_for('securitypolicyviolation').then(t.step_func_done(e => { 9 assert_equals(e.blockedURI, "eval"); 10 assert_equals(e.sourceFile, "data"); 11 assert_equals(e.lineNumber, 3); 12 assert_equals(e.columnNumber, 17); 13 })); 14 15 var scriptText = ` 16 try { 17 eval("assert_unreached('no eval')"); 18 } catch (e) { 19 assert_equals(e.name, 'EvalError'); 20 } 21 `; 22 var s = document.createElement("script"); 23 s.src = "data:text/javascript," + encodeURIComponent(scriptText); 24 document.head.append(s); 25 }, "Violations from data:-URL scripts have a sourceFile of 'data'"); 26 </script>