Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<head>
<title>Summary</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<details>
<summary>Summary</summary>
Details
</details>
<script type="module">
const details = document.querySelector("details");
details.addEventListener("toggle",
(e) => assert_true(false, 'details should not be toggled'));
const summary = document.querySelector("summary");
summary.addEventListener("click",
(e) => assert_true(false, `summary should not be clicked`));
test(() => {
// keyCode: Enter
summary.dispatchEvent(
new KeyboardEvent("keypress", {
keyCode: 13,
})
);
// key: Enter
summary.dispatchEvent(
new KeyboardEvent("keypress", {
key: "Enter",
})
);
// keyCode: Space
summary.dispatchEvent(
new KeyboardEvent("keypress", {
keyCode: 32,
})
);
// key: Space
summary.dispatchEvent(
new KeyboardEvent("keypress", {
key: " ",
})
);
}, `Dispatching untrusted keypress events to summary should not cause click event`);
test(() => {
// keyCode: Enter
summary.dispatchEvent(
new KeyboardEvent("keydown", {
keyCode: 13,
})
);
summary.dispatchEvent(
new KeyboardEvent("keyup", {
keyCode: 13,
})
);
// key: Enter
summary.dispatchEvent(
new KeyboardEvent("keydown", {
key: "Enter",
})
);
summary.dispatchEvent(
new KeyboardEvent("keyup", {
key: "Enter",
})
);
// keyCode: Space
summary.dispatchEvent(
new KeyboardEvent("keydown", {
keyCode: 32,
})
);
summary.dispatchEvent(
new KeyboardEvent("keyup", {
keyCode: 32,
})
);
// key: Space
summary.dispatchEvent(
new KeyboardEvent("keydown", {
key: " ",
})
);
summary.dispatchEvent(
new KeyboardEvent("keyup", {
key: " ",
})
);
}, `Dispatching untrusted keyup/keydown events to summary should not cause click event`);
</script>
</body>
</html>