chromium/third_party/blink/web_tests/fast/writing-mode/text-combine-line-break.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
#container {
    -webkit-writing-mode:vertical-rl;
}
#container > div {
    border:solid thin black;
    font-size:20px;
    height:2em;
    line-height:1;
}
.tcy {
    -webkit-text-combine:horizontal;
}
</style>
<div id="container">
    <div title="break after">&#x56FD;<span data-expected="1,0" class="tcy">123</span>&#x56FD;</div>
    <div title="break before">&#x56FD;&#x56FD;<span data-expected="0,1" class="tcy">123</span>&#x56FD;</div>
    <div title="after open">&#x56FD;&#x300C;<span data-expected="1,1" class="tcy">123</span></div>
    <div title="before close">&#x56FD;<span data-expected="0,1" class="tcy">123</span>&#x300D;</div>
    <div title="break after with break inside">&#x56FD;<span data-expected="1,0" class="tcy">&#x56FD;&#x56FD;</span>&#x56FD;</div>
    <div title="break before with break inside">&#x56FD;&#x56FD;<span data-expected="0,1" class="tcy">&#x56FD;&#x56FD;</span>&#x56FD;</div>
    <div title="after open with break inside">&#x56FD;&#x300C;<span data-expected="1,1" class="tcy">&#x56FD;&#x56FD;</span></div>
    <div title="before close with break inside">&#x56FD;<span data-expected="0,1" class="tcy">&#x56FD;&#x56FD;</span>&#x300D;</div>
</div>
<script>
(function () {
    var blocks = document.querySelectorAll("div[title]");
    for (var i = 0; i < blocks.length; i++)
        testColumnAndRow(blocks[i]);

    function testColumnAndRow(block) {
        test(function () {
            var targets = block.querySelectorAll("span[data-expected]");
            for (var i = 0; i < targets.length; i++) {
                var element = targets[i];
                var expected = eval("[" + element.dataset.expected + "]");
                var actual = getColumnAndRow(element);
                assert_array_equals(actual, expected);
            }
        }, block.title);
    }

    function getColumnAndRow(element) {
        var rect = element.getBoundingClientRect();
        var block = element.parentElement.getBoundingClientRect()
        var column = rect.top - block.top;
        var row = block.right - rect.right;
        // "+ 1 - 1" is to convert -0 to 0.
        return [Math.round(column / 20) + 1 - 1, Math.round(row / 20) + 1 - 1];
    }
})();

if (window.testRunner)
    container.style.display = "none";
</script>