<!DOCTYPE html>
<meta charset="utf-8">
<title>Checkbox keyboard event</title>
<link rel=help href="https://html.spec.whatwg.org/#checkbox-state-(type=checkbox)">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body>
<script>
"use strict";
test(() => {
const input = document.createElement("input");
input.type = "checkbox";
document.body.appendChild(input);
const events = [];
input.addEventListener("change", () => {
events.push("change");
});
input.addEventListener("click", () => {
events.push("click");
});
input.addEventListener("input", () => {
events.push("input");
});
assert_false(input.checked);
if (window.eventSender) {
input.focus();
eventSender.keyDown(" ");
assert_true(input.checked);
assert_array_equals(events, ["click", "input", "change"]);
}
}, "a checkbox input emits click, input, change events in order after keyboard event");
</script>