<!DOCTYPE html>
<html>
<link href="resources/flexbox.css" rel="stylesheet">
<style>
.flexbox {
    margin: 120px;
    width: 100px;
    height: 100px;
    background-color: #aaa;
    position: relative;
    outline: 2px solid red;
}
.title {
    margin-bottom: 10px;
}
.flexbox > div {
    height: 110px;
    width: 110px;
}
.flexbox :nth-child(1) {
    background-color: blue;
}
.flexbox :nth-child(2) {
    background-color: green;
}
.ltr {
    direction: ltr;
}
.rtl {
    direction: rtl;
}
.horizontal-tb {
    writing-mode: horizontal-tb;
}
.vertical-rl {
    writing-mode: vertical-rl;
}
.vertical-lr {
    writing-mode: vertical-lr;
}
</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-offset-x="' + position[0] + '" data-offset-y="' + position[1] + '"';
}

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

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

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 container = document.createElement('div');
            container.innerHTML = '<div class="flexbox align-items-flex-end ' + flexboxClassName + '">\n' +
                '<div class="flex-none" ' + positionAsString(expectations[writingMode][flexFlow][direction]) + '></div><div class="flex-none"></div>\n' +
            '</div>';

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

</body>
</html>
