<!DOCTYPE html>
<title>CSS Grid: track sizing algo with size restrictions and intrinsic sizes.</title>
<link rel="author" title="Sergio Villar" href="mailto:svillar@igalia.com"/>
<link rel="help" href="https://drafts.csswg.org/css-grid-1/#layout-algorithm"/>
<meta name="assert" content="This test ensures that fr tracks are properly sized whenever grid has intrinsic sizes."/>
<link rel="issue" href="https://crbug.com/423743"/>
<link href="/css/support/width-keyword-classes.css" rel="stylesheet"/>
<link href="/css/support/height-keyword-classes.css" rel="stylesheet"/>
<link href="/css/support/grid.css" rel="stylesheet"/>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />

<style>
.container {
    width: 100px;
    height: 100px;
}

.grid {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

div { font: 10px/1 Ahem; }
</style>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script type="text/javascript">
  setup({ explicit_done: true });
</script>

<body onload="document.fonts.ready.then(() => { checkLayout('.grid'); })">

<div class="container">
  <div class="grid" data-expected-width="100" data-expected-height="10">
    <div>XXX XXX</div>
  </div>
</div>

<div class="container">
  <div class="grid min-content" data-expected-width="30" data-expected-height="20">
    <div>XXX XXX</div>
  </div>
</div>

<div class="container">
  <div class="grid min-content" data-expected-width="0" data-expected-height="20" style="grid-template-columns:minmax(0, 1fr);">
    <div>XXX XXX</div>
  </div>
</div>

<div class="container">
  <div class="grid max-content" data-expected-width="70" data-expected-height="10">
    <div>XXX XXX</div>
  </div>
</div>

<div class="container">
  <div class="grid fit-content" data-expected-width="70" data-expected-height="10">
    <div>XXX XXX</div>
  </div>
</div>

<div class="min-content">
    <div class="grid" data-expected-width="40" data-expected-height="50">
        <div>XXX XXXX XX X XX XXX</div>
    </div>
</div>

<div class="grid container" data-expected-width="100" data-expected-height="100">
    <div style="display: grid; grid-template-columns: 3fr; grid-template-rows: 2fr;" data-expected-width="100" data-expected-height="100">
        <div>XXX XXXX XX X XX XXX</div>
    </div>
</div>

<div class="grid" style="grid; grid: 1fr 2fr / 2fr 1fr; width: 300px; height: 300px;" data-expected-width="300" data-expected-height="300">
    <div class="firstRowFirstColumn" style="display: grid; grid: 1fr 3fr / 3fr 1fr;" data-expected-width="200" data-expected-height="100">
        <div style="border: 2px solid magenta;" data-expected-width="150" data-expected-height="25">XXXX</div>
        <div class="secondRowSecondColumn" style="border: 2px solid cyan;" data-expected-width="50" data-expected-height="75">XXXX XX XX</div>
    </div>
    <div class="secondRowSecondColumn" style="display: grid; grid: 3fr 4fr / 4fr 3fr;" data-expected-width="100" data-expected-height="200">
        <div style="border: 2px solid lime;" data-expected-width="56" data-expected-height="86">XXX XX X</div>
        <div class="secondRowSecondColumn" style="border: 2px solid navy;" data-expected-width="44" data-expected-height="114">XXXX XXX XXXX XXX XXXX</div>
    </div>
</div>

</body>
