script-html-correctly-labeled.tentative.sub.html (1295B)
1 <!DOCTYPE html> 2 <!-- Test verifies that html fed to a <script> tag won't report a syntax 3 error after CORB blocks the response (an empty response body injected 4 by CORB won't have any JavaScript syntax errors). 5 --> 6 <meta charset="utf-8"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <div id=log></div> 10 <script> 11 setup({allow_uncaught_exception : true}); 12 async_test(function(t) { 13 var script = document.createElement("script") 14 15 // Without CORB, the html document would cause a syntax error when parsed as 16 // JavaScript, but with CORB there should be no errors (because CORB will 17 // replace the response body with an empty body). With ORB, the script loading 18 // itself will error out. 19 script.onload = t.step_func_done(); 20 script.onerror = t.step_func_done(); 21 addEventListener("error",function(e) { 22 t.step(function() { 23 assert_unreached("Empty body of a CORB-blocked response shouldn't trigger syntax errors."); 24 t.done(); 25 }) 26 }); 27 28 // www1 is cross-origin, so the HTTP response is CORB-eligible. 29 script.src = 'http://{{domains[www1]}}:{{ports[http][0]}}/fetch/corb/resources/html-correctly-labeled.html'; 30 document.body.appendChild(script) 31 }, "CORB-blocked script has no syntax errors"); 32 </script>