chromium/third_party/blink/web_tests/css3/flexbox/flex-flow-border.html

<!DOCTYPE html>
<html>
<style>
.container {
    position: relative;
    background-color: pink;
    outline: 1px solid red;
    display: inline-block;
}
.flexbox {
    display: flex;
    background-color: grey;
    width: 100px;
    height: 100px;
    border-style: solid;
}
.flexbox * {
    border-width: 0px;
    border-style: solid;
}
.title {
    margin-top: 1em;
}
.ltr {
    direction: ltr;
}
.rtl {
    direction: rtl;
}
.horizontal-tb {
    writing-mode: horizontal-tb;
}
.vertical-rl {
    writing-mode: vertical-rl;
}
.vertical-lr {
    writing-mode: vertical-lr;
}
.row {
    flex-flow: row;
}
.row-reverse {
    flex-flow: row-reverse;
}
.column {
    flex-flow: column;
}
.column-reverse {
    flex-flow: column-reverse;
}
.physical {
    border-width: 10px 20px 30px 40px;
}
.physical > div {
    border-width: 13px 2px 17px 8px;
}
.logical {
    border-block-start-width: 10px;
    border-block-end-width: 30px;
    border-inline-start-width: 40px;
    border-inline-end-width: 20px;
}
.logical > div {
    border-block-start-width: 13px;
    border-block-end-width: 17px;
    border-inline-start-width: 8px;
    border-inline-end-width: 2px;
}
.flexbox > :nth-child(1) {
    background-color: blue;
}
.flexbox > :nth-child(2) {
    background-color: green;
}
.flexbox > :nth-child(3) {
    background-color: red;
}
</style>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/check-layout-th.js"></script>
<body onload="checkLayout('.flexbox')">
<div id=log></div>

<script>
function positionAsString(position)
{
    return 'data-total-x="' + position[0] + '" data-total-y="' + position[1] + '"';
}

function offsetSizeAsString(size)
{
    return 'data-expected-width="' + size[0] + '" data-expected-height="' + size[1] + '"';
}

function asString(expectations)
{
    return 'data-expected-client-width="' + expectations[0] + '" data-expected-client-height="' + expectations[1] + '" ' + positionAsString(expectations.slice(2, 4));
}

var physicalFlexBoxOffsetSize = [160, 140];
var physicalFlexBoxClientPosition = [40, 10];

var physicalExpectations = {
    'horizontal-tb': {
        rtl: {
            size: physicalFlexBoxOffsetSize,
            position: physicalFlexBoxClientPosition,
            column: [20, 70, 118, 23],
            row: [90, 20, 48, 23]
        },
        ltr : {
            size: physicalFlexBoxOffsetSize,
            position: physicalFlexBoxClientPosition,
            column: [20, 70, 48, 23],
            row: [90, 20, 48, 23]
        }
    },
    'vertical-lr': {
        rtl: {
            size: physicalFlexBoxOffsetSize,
            position: physicalFlexBoxClientPosition,
            column: [90, 20, 48, 73],
            row: [20, 70, 48, 23]
        },
        ltr : {
            size: physicalFlexBoxOffsetSize,
            position: physicalFlexBoxClientPosition,
            column: [90, 20, 48, 23],
            row: [20, 70, 48, 23]
        }
    },
    'vertical-rl': {
        rtl: {
            size: physicalFlexBoxOffsetSize,
            position: physicalFlexBoxClientPosition,
            column: [90, 20, 48, 73],
            row: [20, 70, 118, 23]
        },
        ltr : {
            size: physicalFlexBoxOffsetSize,
            position: physicalFlexBoxClientPosition,
            column: [90, 20, 48, 23],
            row: [20, 70, 118, 23]
        }
    }
}

var logicalExpectations = {
    'horizontal-tb': {
        rtl: {
            size: [160, 140],
            position: [20, 10],
            column: [20, 70, 92, 23],
            row: [90, 20, 22, 23]
        },
        ltr : {
            size: [160, 140],
            position: [40, 10],
            column: [20, 70, 48, 23],
            row: [90, 20, 48, 23]
        }
    },
    'vertical-lr': {
        rtl: {
            size: [140, 160],
            position: [10, 20],
            column: [70, 20, 23, 92],
            row: [20, 90, 23, 22]
        },
        ltr : {
            size: [140, 160],
            position: [10, 40],
            column: [70, 20, 23, 48],
            row: [20, 90, 23, 48]
        }
    },
    'vertical-rl': {
        rtl: {
            size: [140, 160],
            position: [30, 20],
            column: [70, 20, 47, 92],
            row: [20, 90, 97, 22]
        },
        ltr : {
            size: [140, 160],
            position: [30, 40],
            column: [70, 20, 47, 48],
            row: [20, 90, 97, 48]
        }
    }
}

var writingModes = ['horizontal-tb', 'vertical-lr', 'vertical-rl'];
var flexFlows = ['row', 'column', 'row-reverse', 'column-reverse'];
var directions = ['rtl', 'ltr'];
var marginTypes = ['physical', 'logical'];

writingModes.forEach(function(writingMode) {
    flexFlows.forEach(function(flexFlow) {
        directions.forEach(function(direction) {
            marginTypes.forEach(function(marginType) {
                var flexboxClassName = writingMode + ' ' + direction + ' ' + flexFlow + ' ' + marginType;
                var title = document.createElement('div');
                title.className = 'title';
                title.innerHTML = flexboxClassName;
                document.body.appendChild(title);

                var expectations = (marginType == 'physical') ? physicalExpectations : logicalExpectations;
                expectations = expectations[writingMode][direction];

                var container = document.createElement('div');
                container.className = 'container';
                container.setAttribute('data-expected-width', expectations.size[0]);
                container.setAttribute('data-expected-height', expectations.size[1]);

                container.innerHTML = '\n<div class="flexbox ' + flexboxClassName + '" ' + positionAsString(expectations.position) + ' ' + offsetSizeAsString(expectations.size) + '>\n' +
                    '<div style="flex: 1 auto; height: 20px; width: 20px;" ' + asString(expectations[flexFlow.replace("-reverse", "")]) + '></div>\n' +
                '</div>\n';

                document.body.appendChild(container);   
            })
        })
    })
})
</script>
</body>
</html>