chromium/third_party/blink/web_tests/html/details_summary/details-keyboard-show-hide.html

<!DOCTYPE html>
<head>
<script src="../../resources/js-test.js"></script>
</head>

<body>
<p id="description"></p>
<div id="console"></div>
<details id="details"><summary id="summary"></summary><input></details>
<script>
    function openAttribute(id) {
        return document.getElementById(id).open;
    }

    description("This test verifies that pressing the ENTER or SPACEBAR key when the &lt;summary&gt; has focus will toggle the &lt;details&gt; display. On expanding details.open will be true and vice versa.");

    if (window.eventSender) {
        var summary = document.getElementById("summary");
        summary.focus();

        shouldBeFalse('openAttribute("details")');
        debug("Toggle &lt;display&gt; using Enter key:");
        eventSender.keyDown("\r");
        shouldBeTrue('openAttribute("details")');
        eventSender.keyDown("\r");
        shouldBeFalse('openAttribute("details")');

        debug("Toggle &lt;display&gt; using Spacebar key:");
        eventSender.keyDown(" ");
        shouldBeTrue('openAttribute("details")');
        eventSender.keyDown(" ");
        shouldBeFalse('openAttribute("details")');
    } else {
        debug('There are tests using eventSender.');
    }
</script>
</body>
</html>