Skip to content

Truly independent web browser

Tests/LibWeb: Import WPT tests for fractional grid flex factors

Andreas Klingfb0024594c0d
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/grid-definition/flex-factor-sum-less-than-1-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/grid-definition/flex-factor-sum-less-than-1-001.txt
new file mode 100644
index 00000000000..0c9973dfbc5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/grid-definition/flex-factor-sum-less-than-1-001.txt
@@ -0,0 +1,10 @@
+Harness status: OK
+
+Found 4 tests
+
+2 Pass
+2 Fail
+Fail .grid 1
+Fail .grid 2
+Pass .grid 3
+Pass .grid 4
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/grid-tracks-fractional-fr.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/grid-tracks-fractional-fr.txt
new file mode 100644
index 00000000000..ad85c2f8dc5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-grid/grid-tracks-fractional-fr.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Fail
+Fail Tests fractional fr-units which should multiply to whole numbers.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-grid/grid-definition/flex-factor-sum-less-than-1-001.html b/Tests/LibWeb/Text/input/wpt-import/css/css-grid/grid-definition/flex-factor-sum-less-than-1-001.html
new file mode 100644
index 00000000000..c200b6cd8f7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-grid/grid-definition/flex-factor-sum-less-than-1-001.html
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<html>
+<title>CSS Grid Layout Test: flex factor sum smaller than 1.</title>
+<link rel="author" title="Javier Fernandez" href="mailto:[email protected]">
+<link rel="help" href="https://drafts.csswg.org/css-grid/#algo-find-fr-size">
+<link rel="help" href="https://drafts.csswg.org/css-grid-1/#fr-unit">
+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=520477">
+<link rel="stylesheet" href="../../../css/support/grid.css">
+<meta name="assert" content="Test that resolving auto tracks on grid items works properly even when the flex factor sum is less than 1." />
+
+<style>
+.onlyColumnFractionFlexFactors {
+ grid-template-columns: minmax(0, 0.1fr) minmax(0, 0.2fr) minmax(0, 0.3fr);
+ grid-template-rows: 50px;
+ width: 100px;
+}
+.onlyRowFractionFlexFactors {
+ grid-template-columns: 50px;
+ grid-template-rows: minmax(0, 0.1fr) minmax(0, 0.2fr) minmax(0, 0.3fr);
+ width: 50px;
+ height: 100px;
+}
+.fixedAndfractionFlexFactors {
+ grid-template-columns: 50px minmax(0, 0.2fr) 30px;
+ grid-template-rows: minmax(0, 0.1fr) 50px minmax(0, 0.3fr);
+ width: 100px;
+ height: 100px;
+}
+.zeroValueFlexFactor {
+ grid-template-columns: .0fr .2fr .3fr;
+ grid-template-rows: 50px;
+ width: 100px;
+}
+.firstRowThirdColumn {
+ background-color: yellow;
+ grid-column: 3;
+ grid-row: 1;
+}
+.secondRowThirdColumn {
+ background-color: yellow;
+ grid-column: 3;
+ grid-row: 2;
+}
+.thirdRowFirstColumn {
+ background-color: brown;
+ grid-column: 1;
+ grid-row: 3;
+}
+.thirdRowThirdColumn {
+ background-color: magenta;
+ grid-column: 3;
+ grid-row: 3;
+}
+</style>
+
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../resources/check-layout-th.js"></script>
+
+<body onload="checkLayout('.grid');">
+
+<div style="position: relative;">
+ <div class="grid onlyColumnFractionFlexFactors">
+ <div class="firstRowFirstColumn" data-expected-width="10" data-expected-height="50"></div>
+ <div class="firstRowSecondColumn" data-expected-width="20" data-expected-height="50"></div>
+ <div class="firstRowThirdColumn" data-expected-width="30" data-expected-height="50"></div>
+ </div>
+</div>
+
+<div style="position: relative;">
+ <div class="grid onlyRowFractionFlexFactors">
+ <div class="firstRowFirstColumn" data-expected-width="50" data-expected-height="10"></div>
+ <div class="secondRowFirstColumn" data-expected-width="50" data-expected-height="20"></div>
+ <div class="thirdRowFirstColumn" data-expected-width="50" data-expected-height="30"></div>
+ </div>
+</div>
+
+<div style="position: relative;">
+ <div class="grid zeroValueFlexFactor">
+ <div class="firstRowFirstColumn" data-expected-width="0" data-expected-height="50"></div>
+ <div class="firstRowSecondColumn" data-expected-width="20" data-expected-height="50"></div>
+ <div class="firstRowThirdColumn" data-expected-width="30" data-expected-height="50"></div>
+ </div>
+</div>
+
+<div style="position: relative;">
+ <div class="grid fixedAndfractionFlexFactors">
+ <div class="firstRowFirstColumn" data-expected-width="50" data-expected-height="5"></div>
+ <div class="firstRowSecondColumn" data-expected-width="4" data-expected-height="5"></div>
+ <div class="firstRowThirdColumn" data-expected-width="30" data-expected-height="5"></div>
+ <div class="secondRowFirstColumn" data-expected-width="50" data-expected-height="50"></div>
+ <div class="secondRowSecondColumn" data-expected-width="4" data-expected-height="50"></div>
+ <div class="secondRowThirdColumn" data-expected-width="30" data-expected-height="50"></div>
+ <div class="thirdRowFirstColumn" data-expected-width="50" data-expected-height="15"></div>
+ <div class="thirdRowSecondColumn" data-expected-width="4" data-expected-height="15"></div>
+ <div class="thirdRowThirdColumn" data-expected-width="30" data-expected-height="15"></div>
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-grid/grid-tracks-fractional-fr.html b/Tests/LibWeb/Text/input/wpt-import/css/css-grid/grid-tracks-fractional-fr.html
new file mode 100644
index 00000000000..7a067b7871b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-grid/grid-tracks-fractional-fr.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<title>Tests fractional fr-units which should multiply to whole numbers.</title>
+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1515685">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<div id="target" style="display: grid; grid-template-columns: 1.01fr 0.99fr 1fr; width: 600px;">
+ <div></div>
+ <div></div>
+ <div></div>
+</div>
+<script>
+test(() => {
+ const [a, b, c] = document.getElementById('target').children;
+ assert_equals(a.getBoundingClientRect().width, 202);
+ assert_equals(b.getBoundingClientRect().width, 198);
+ assert_equals(c.getBoundingClientRect().width, 200);
+});
+</script>