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

<!DOCTYPE html>
<html>
<style>
.container {
    position: relative;
    background-color: pink;
    outline: 1px solid black;
    display: inline-block;
}
.flexbox {
    display: flex;
    background-color: grey;
    width: 100px;
    height: 100px;
}
.flexbox > * {
    flex: none;
}
.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;
}
.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 asString(position)
{
    return 'data-offset-x="' + position[0] + '" data-offset-y="' + position[1] + '"';
}

var expectations = {
    'horizontal-tb': {
        column: {
            rtl: [[80, 0], [80, 20]],
            ltr: [[0, 0], [0, 20]]
        },
        'column-reverse': {
            rtl: [[80, 80], [80, 60]],
            ltr: [[0, 80], [0, 60]]
        },
        row: {
            rtl: [[80, 0], [60, 0]],
            ltr: [[0, 0], [20, 0]]
        },
        'row-reverse': {
            rtl: [[0, 0], [20, 0]],
            ltr: [[80, 0], [60, 0]]
        }
    },
    'vertical-lr': {
        column: {
            rtl: [[0, 80], [20, 80]],
            ltr: [[0, 0], [20, 0]]
        },
        'column-reverse': {
            rtl: [[80, 80], [60, 80]],
            ltr: [[80, 0], [60, 0]]
        },
        row: {
            rtl: [[0, 80], [0, 60]],
            ltr: [[0, 0], [0, 20]]
        },
        'row-reverse': {
            rtl: [[0, 0], [0, 20]],
            ltr: [[0, 80], [0, 60]]
        }
    },
    'vertical-rl': {
        column: {
            rtl: [[80, 80], [60, 80]],
            ltr: [[80, 0], [60, 0]]
        },
        'column-reverse': {
            rtl: [[0, 80], [20, 80]],
            ltr: [[0, 0], [20, 0]]
        },
        row: {
            rtl: [[80, 80], [80, 60]],
            ltr: [[80, 0], [80, 20]]
        },
        'row-reverse': {
            rtl: [[80, 0], [80, 20]],
            ltr: [[80, 80], [80, 60]]
        }
    }
};

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

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


            var flexItemExpectations = expectations[writingMode][flexFlow][direction];

            var container = document.createElement('div');
            container.className = 'container';
            container.innerHTML = '<div class="flexbox ' + flexboxClassName + '">\n' +
                '<div style="width: 20px; height: 20px;" ' + asString(flexItemExpectations[0]) + '></div>\n' +
                '<div style="width: 20px; height: 20px;" ' + asString(flexItemExpectations[1]) + '></div>\n' +
            '</div>';

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