Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 3 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/scripting-1/the-script-element/script-for-event.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Scripts with for and event attributes</title>
<link rel="author" title="Matheus Kerschbaum" href="mailto:matjk7@gmail.com">
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var expected = [
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false,
true,
true,
false,
true,
true,
];
var run = expected.map(function() { return false });
</script>
<script for="wİndow" event="onload">
run[0] = true;
</script>
<script for="window" event="onload x">
run[1] = true;
</script>
<script for="window" event="onload(x">
run[2] = true;
</script>
<script for="window" event="onload(x)">
run[3] = true;
</script>
<script for="window" event="onclick">
run[4] = true;
</script>
<script for="" event="onload">
run[5] = true;
</script>
<script for="window" event="">
run[6] = true;
</script>
<script for="" event="">
run[7] = true;
</script>
<script for=" window" event="onload">
run[8] = true;
</script>
<script for="window " event="onload">
run[9] = true;
</script>
<script for="window" event=" onload">
run[10] = true;
</script>
<script for="window" event="onload ">
run[11] = true;
</script>
<script for=" window " event=" onload ">
run[12] = true;
</script>
<script for=" window " event=" onload() ">
run[13] = true;
</script>
<script for="object" event="handler">
run[14] = true;
</script>
<script event="handler">
run[15] = true;
</script>
<script for="object">
run[16] = true;
</script>
<script>
test(function() {
for (var i = 0; i < run.length; ++i) {
test(function() {
var script = document.querySelectorAll("script[for], script[event]")[i];
assert_equals(run[i], expected[i],
"script for=" + format_value(script.getAttribute("for")) +
" event=" + format_value(script.getAttribute("event")));
}, "Script " + i);
}
});
</script>