<!DOCTYPE html>
<title>CSS Flexbox: percentages in flex items</title>
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#definite-sizes">
<link rel="help" href="https://crbug.com/341310">
<meta name="assert" content="This test ensures that percentages are resolved in flex items.">
<link href="support/flexbox.css" rel="stylesheet">
<style>
.horizontal {
    height: 50px;
    background-color: purple;
    position: relative;
}
.vertical {
    width: 50px;
    height: 10px;
    background-color: purple;
    position: relative;
    writing-mode: vertical-rl;
}
.flex-one {
    background-color: red;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script>
function changeHeight()
{
  document.getElementById('dynamicHorizontalChild').style.height = "90%";
  document.getElementById('dynamicVerticalChild').style.width = "30%";
  checkLayout('.flexbox');
}
</script>
<body onload="changeHeight()">
<div class="flexbox horizontal">
  <div data-expected-height="50" class="flex-one">
    <div data-expected-height="35" style="height: 70%; background-color: lime"></div>
  </div>
</div>
<div class="flexbox horizontal">
  <div data-expected-height="50" class="flex-one">
    <div id="dynamicHorizontalChild" data-expected-height="45" style="height: 70%; background-color: lime"></div>
  </div>
</div>
<div class="flexbox horizontal">
  <div data-expected-height="50" class="flex-one" style="padding: 10px; border: 2px solid black">
    <div data-expected-height="18" style="height: 70%; background-color: lime"></div>
  </div>
</div>
<div class="flexbox horizontal">
  <img data-expected-height="25" style="max-height: 50%" src="support/10x10-green.png" />
</div>
<div class="flexbox horizontal">
  <div data-expected-height="25" class="flex-one" style="max-height:50%">
    <div data-expected-height="13" style="height: 50%; background-color: lime"></div>
  </div>
</div>
<div class="flexbox vertical">
  <div data-expected-width="50" class="flex-one">
    <div data-expected-width="25" style="width: 50%; background-color: lime"></div>
  </div>
</div>
<div class="flexbox vertical">
  <div data-expected-width="50" class="flex-one">
    <div id="dynamicVerticalChild" data-expected-width="15" style="width: 50%; background-color: lime"></div>
  </div>
</div>
<div class="flexbox vertical">
  <div data-expected-width="50" class="flex-one" style="padding: 10px; border: 2px solid black">
    <div data-expected-width="13" style="width: 50%; background-color: lime"></div>
  </div>
</div>
<div class="flexbox vertical">
  <img data-expected-width="25" style="max-width: 50%" src="support/10x10-green.png" />
</div>
<div class="flexbox vertical">
  <div data-expected-width="25" class="flex-one" style="max-width: 50%">
    <div data-expected-width="13" style="width: 50%; background-color: lime"></div>
  </div>
</div>
</body>
