
<head>
<style>
body {
    margin: 0px;
}
div {
    width:200px;
    height:80px;
}
summary {
    background-color: red;
}
</style>

<script>

var error = false;

var writeLog = function (msg)
{
    var results = document.getElementById('results');
    results.innerHTML += msg + '<br>';
};

var clickElement = function (element) {

    var detail = document.getElementById("details" + element);
    var old = detail.open;

    eventSender.mouseDown();
    eventSender.mouseUp();

    if (old !== detail.open) {
        writeLog("details" + element + "'s open attribute is expected to be'" + !old + "' and is.");
    } else {
        writeLog("details" + element + "'s open attribute is expected to be'" + !old + "' but instead is '" + old + "'.");
        error = true;
    }
};

var testElement = function (element) {
    switch (element) {
    case 0:
        eventSender.mouseMoveTo(2, 2);
        break;
    case 1:
        eventSender.mouseMoveTo(2, 158);
        break;
    case 2:
        eventSender.mouseMoveTo(2, 162);
        break;
    case 3:
        eventSender.mouseMoveTo(198, 242);
        break;
    }

    clickElement(element);
    clickElement(element);
};

var runTests = function () {

    if (!window.testRunner || !window.eventSender)
        return;

    testRunner.dumpAsText();

    testElement(0);
    testElement(1);
    testElement(2);
    testElement(3);

    writeLog(error ? "FAIL" : "PASS");
}

</script>

</head>

<body onload="runTests()">

<div style="-webkit-writing-mode:horizontal-tb;">
    <details id="details0"><input></details>
</div>

<div style="-webkit-writing-mode:horizontal-bt;">
    <details id="details1"><input></details>
</div>

<div style="-webkit-writing-mode:vertical-lr;">
    <details id="details2"><input></details>
</div>

<div style="-webkit-writing-mode:vertical-rl;">
    <details id="details3"><input></details>
</div>

<div id="results">
</div>

</body>

