Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
function runTest() {
const summary = document.querySelector("summary");
summary.addEventListener('click', function(e) {
// Prevent the details from toggling by key events.
e.preventDefault();
});
// Dispatch 'return' key to the summary element.
summary.focus();
synthesizeKey("KEY_Enter");
const details = document.querySelector("details");
ok(!details.open, "Prevent default on summary should not open details.");
SimpleTest.finish();
}
</script>
</head>
<body onload="runTest();">
<details>
<summary>Summary</summary>
<p>This is the details.</p>
</details>
</body>
</html>