Newer
Older
minerva / Tests / LibWeb / Text / input / is-collapsed.html
@minerva minerva on 13 Jul 797 bytes Initial commit
<script src="include.js"></script>
<p id="a">Simply selectable</p>

<script>
    test(() => {
        var selection = window.getSelection();
        var range = document.createRange();
        range.setStart(a.firstChild, 0);
        range.setEnd(a.firstChild, 1);
        selection.addRange(range);
        if (selection.isCollapsed) {
            println(`FAIL: "${selection}" is not collapsed`);
            return;
        }
        selection.collapseToStart();
        if (!selection.isCollapsed) {
            println(`FAIL: "${selection}" is collapsed`);
            return;
        }
        selection.removeAllRanges();
        if (!selection.isCollapsed) {
            println(`FAIL: "${selection}" is collapsed`);
            return;
        }
        println("PASS");
    })
</script>