script-for-event.html (2375B)
1 <!DOCTYPE html> 2 <title>Module scripts with for and event attributes</title> 3 <link rel="author" title="Matheus Kerschbaum" href="mailto:matjk7@gmail.com"> 4 <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script"> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <div id="log"></div> 9 <script> 10 var expected = [ 11 true, 12 true, 13 true, 14 true, 15 true, 16 true, 17 true, 18 true, 19 true, 20 true, 21 true, 22 true, 23 true, 24 true, 25 true, 26 true, 27 true, 28 ]; 29 var run = expected.map(function() { return false }); 30 </script> 31 <script for="wİndow" event="onload" type="module"> 32 run[0] = true; 33 </script> 34 <script for="window" event="onload x" type="module"> 35 run[1] = true; 36 </script> 37 <script for="window" event="onload(x" type="module"> 38 run[2] = true; 39 </script> 40 <script for="window" event="onload(x)" type="module"> 41 run[3] = true; 42 </script> 43 <script for="window" event="onclick" type="module"> 44 run[4] = true; 45 </script> 46 <script for="" event="onload" type="module"> 47 run[5] = true; 48 </script> 49 <script for="window" event="" type="module"> 50 run[6] = true; 51 </script> 52 <script for="" event="" type="module"> 53 run[7] = true; 54 </script> 55 <script for=" window" event="onload" type="module"> 56 run[8] = true; 57 </script> 58 <script for="window " event="onload" type="module"> 59 run[9] = true; 60 </script> 61 <script for="window" event=" onload" type="module"> 62 run[10] = true; 63 </script> 64 <script for="window" event="onload " type="module"> 65 run[11] = true; 66 </script> 67 <script for=" window " event=" onload " type="module"> 68 run[12] = true; 69 </script> 70 <script for=" window " event=" onload() " type="module"> 71 run[13] = true; 72 </script> 73 <script for="object" event="handler" type="module"> 74 run[14] = true; 75 </script> 76 <script event="handler" type="module"> 77 run[15] = true; 78 </script> 79 <script for="object" type="module"> 80 run[16] = true; 81 </script> 82 <script type="module"> 83 test(function() { 84 for (var i = 0; i < run.length; ++i) { 85 test(function() { 86 var script = document.querySelectorAll("script[for], script[event]")[i]; 87 assert_equals(run[i], expected[i], 88 "script for=" + format_value(script.getAttribute("for")) + 89 " event=" + format_value(script.getAttribute("event"))); 90 }, "Script " + i); 91 } 92 }); 93 </script>