summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-box
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-box
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-box')
-rw-r--r--testing/web-platform/tests/css/css-box/META.yml5
-rw-r--r--testing/web-platform/tests/css/css-box/animation/margin-bottom-composition.html78
-rw-r--r--testing/web-platform/tests/css/css-box/animation/margin-interpolation.html118
-rw-r--r--testing/web-platform/tests/css/css-box/animation/margin-left-composition.html78
-rw-r--r--testing/web-platform/tests/css/css-box/animation/margin-right-composition.html78
-rw-r--r--testing/web-platform/tests/css/css-box/animation/margin-top-composition.html78
-rw-r--r--testing/web-platform/tests/css/css-box/animation/padding-bottom-composition.html65
-rw-r--r--testing/web-platform/tests/css/css-box/animation/padding-interpolation.html108
-rw-r--r--testing/web-platform/tests/css/css-box/animation/padding-left-composition.html65
-rw-r--r--testing/web-platform/tests/css/css-box/animation/padding-right-composition.html65
-rw-r--r--testing/web-platform/tests/css/css-box/animation/padding-top-composition.html65
-rw-r--r--testing/web-platform/tests/css/css-box/box-chrome-crash-001.html30
-rw-r--r--testing/web-platform/tests/css/css-box/inheritance.html35
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-block-001.html35
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-block-002.html45
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-001.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-002.html40
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-001.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-002.html40
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item-ref.html28
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item.html32
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-end.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-start.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block.html35
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child.html55
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children.html60
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end.html32
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-child-with-border.html43
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-self-collapsing-nested.html41
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-end.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-start.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end.html43
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-start.html43
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-end.html38
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-start.html38
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block.html38
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end.html38
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-start.html38
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-style-change-triggers-layout-block-start.html42
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-end.html43
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-start.html43
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block.html43
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-start.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-end.html36
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-start.html47
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block.html37
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end.html47
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-start.html47
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-column-auto-flow.html60
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-item-spans-multiple-rows.html42
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end.html55
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start-item-negative-span.html41
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start.html62
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only-ref.html31
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only-ref.html31
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only-ref.html30
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-block-multiline.html41
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-grow.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline.html36
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-orthogonal-item.html39
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-shrink.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end.html41
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start.html41
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block.html41
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only-ref.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only-ref.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only-ref.html31
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline-ref.html32
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-grow.html31
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-inline-multiline.html39
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-orthogonal-item.html39
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-shrink.html31
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end.html40
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start.html40
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline.html40
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins-ref.html29
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins.html32
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-block-end-ref.html29
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-block-end.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-block-start-ref.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-block-start.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-block.html38
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end-ref.html31
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end.html33
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start-ref.html35
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start.html34
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-inline.html38
-rw-r--r--testing/web-platform/tests/css/css-box/margin-trim/grid-trim-ignores-collapsed-tracks.html34
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/clear-computed.html24
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/clear-invalid.html19
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/clear-valid.html26
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/float-computed.html23
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/float-invalid.html20
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/float-valid.html34
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/height-invalid.html30
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/height-valid.html30
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/margin-computed.html46
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/margin-invalid.html25
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/margin-shorthand.html43
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/margin-trim-computed.html34
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/margin-trim.html46
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/margin-valid.html34
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/max-height-invalid.html30
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/max-height-valid.html31
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/max-width-invalid.html30
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/max-width-valid.html31
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/overflow-invalid.html24
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/overflow-valid.html35
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/padding-computed.html51
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/padding-invalid.html29
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/padding-shorthand.html43
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/padding-valid.html31
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/visibility-computed.html20
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/visibility-invalid.html19
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/visibility-valid.html20
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/width-invalid.html31
-rw-r--r--testing/web-platform/tests/css/css-box/parsing/width-valid.html29
133 files changed, 5150 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-box/META.yml b/testing/web-platform/tests/css/css-box/META.yml
new file mode 100644
index 0000000000..dde409360f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/META.yml
@@ -0,0 +1,5 @@
+spec: https://drafts.csswg.org/css-box/
+suggested_reviewers:
+ - dbaron
+ - dholbert
+ - mstensho
diff --git a/testing/web-platform/tests/css/css-box/animation/margin-bottom-composition.html b/testing/web-platform/tests/css/css-box/animation/margin-bottom-composition.html
new file mode 100644
index 0000000000..c95f8de23e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/margin-bottom-composition.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>margin-bottom composition</title>
+<link rel="help" href="https://www.w3.org/TR/CSS2/box.html#margin-properties">
+<meta name="assert" content="margin-bottom supports animation">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'margin-bottom',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'margin-bottom',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'},
+]);
+
+test_composition({
+ property: 'margin-bottom',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'margin-bottom',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+
+test_composition({
+ property: 'margin-bottom',
+ underlying: '100px',
+ addFrom: '100px',
+ addTo: 'auto',
+}, [
+ {at: -0.3, expect: '200px'},
+ {at: 0, expect: '200px'},
+ {at: 0.5, expect: 'auto'},
+ {at: 1, expect: 'auto'},
+ {at: 1.5, expect: 'auto'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/margin-interpolation.html b/testing/web-platform/tests/css/css-box/animation/margin-interpolation.html
new file mode 100644
index 0000000000..088836cbbd
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/margin-interpolation.html
@@ -0,0 +1,118 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>margin interpolation</title>
+<link rel="help" href="https://www.w3.org/TR/CSS2/box.html#margin-properties">
+<meta name="assert" content="margin supports animation">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<style>
+.parent {
+ margin: 10px;
+ border: solid;
+ display: inline-block;
+}
+
+.target {
+ width: 40px;
+ height: 40px;
+ background-color: black;
+ display: inline-block;
+ margin: 30px;
+ opacity: 0.5;
+}
+
+.expected {
+ background-color: green;
+}
+</style>
+
+<body>
+<template id="target-template">
+ <div>
+ <div class="target"></div>
+ </div>
+</template>
+
+<script>
+test_interpolation({
+ property: 'margin',
+ from: neutralKeyframe,
+ to: '20px',
+}, [
+ {at: -0.3, expect: '33px'},
+ {at: 0, expect: '30px'},
+ {at: 0.3, expect: '27px'},
+ {at: 0.6, expect: '24px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '15px'},
+]);
+
+test_interpolation({
+ property: 'margin',
+ from: 'initial',
+ to: '20px',
+}, [
+ {at: -0.3, expect: '-6px'},
+ {at: 0, expect: '0px'},
+ {at: 0.3, expect: '6px'},
+ {at: 0.6, expect: '12px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '30px'},
+]);
+
+test_interpolation({
+ property: 'margin',
+ from: 'inherit',
+ to: '20px',
+}, [
+ {at: -0.3, expect: '7px'},
+ {at: 0, expect: '10px'},
+ {at: 0.3, expect: '13px'},
+ {at: 0.6, expect: '16px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '25px'},
+]);
+
+test_interpolation({
+ property: 'margin',
+ from: 'unset',
+ to: '20px',
+}, [
+ {at: -0.3, expect: '-6px'},
+ {at: 0, expect: '0px'},
+ {at: 0.3, expect: '6px'},
+ {at: 0.6, expect: '12px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '30px'},
+]);
+
+test_interpolation({
+ property: 'margin',
+ from: '0px',
+ to: '10px'
+}, [
+ {at: -0.3, expect: '-3px'},
+ {at: 0, expect: '0px'},
+ {at: 0.3, expect: '3px'},
+ {at: 0.6, expect: '6px'},
+ {at: 1, expect: '10px'},
+ {at: 1.5, expect: '15px'}
+]);
+
+test_interpolation({
+ property: 'margin',
+ from: '20px 40px 60px 80px',
+ to: '30px 50px 70px 90px'
+}, [
+ {at: -0.3, expect: '17px 37px 57px 77px'},
+ {at: 0, expect: '20px 40px 60px 80px'},
+ {at: 0.3, expect: '23px 43px 63px 83px'},
+ {at: 0.6, expect: '26px 46px 66px 86px'},
+ {at: 1, expect: '30px 50px 70px 90px'},
+ {at: 1.5, expect: '35px 55px 75px 95px'}
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/margin-left-composition.html b/testing/web-platform/tests/css/css-box/animation/margin-left-composition.html
new file mode 100644
index 0000000000..8f3c646dfe
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/margin-left-composition.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>margin-left composition</title>
+<link rel="help" href="https://www.w3.org/TR/CSS2/box.html#margin-properties">
+<meta name="assert" content="margin-left supports animation">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'margin-left',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'margin-left',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'},
+]);
+
+test_composition({
+ property: 'margin-left',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'margin-left',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+
+test_composition({
+ property: 'margin-left',
+ underlying: '100px',
+ addFrom: '100px',
+ addTo: 'auto',
+}, [
+ {at: -0.3, expect: '200px'},
+ {at: 0, expect: '200px'},
+ {at: 0.5, expect: 'auto'},
+ {at: 1, expect: 'auto'},
+ {at: 1.5, expect: 'auto'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/margin-right-composition.html b/testing/web-platform/tests/css/css-box/animation/margin-right-composition.html
new file mode 100644
index 0000000000..c903303313
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/margin-right-composition.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>margin-right composition</title>
+<link rel="help" href="https://www.w3.org/TR/CSS2/box.html#margin-properties">
+<meta name="assert" content="margin-right supports animation">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'margin-right',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'margin-right',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'},
+]);
+
+test_composition({
+ property: 'margin-right',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'margin-right',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+
+test_composition({
+ property: 'margin-right',
+ underlying: '100px',
+ addFrom: '100px',
+ addTo: 'auto',
+}, [
+ {at: -0.3, expect: '200px'},
+ {at: 0, expect: '200px'},
+ {at: 0.5, expect: 'auto'},
+ {at: 1, expect: 'auto'},
+ {at: 1.5, expect: 'auto'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/margin-top-composition.html b/testing/web-platform/tests/css/css-box/animation/margin-top-composition.html
new file mode 100644
index 0000000000..5f050bd6c7
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/margin-top-composition.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>margin-top composition</title>
+<link rel="help" href="https://www.w3.org/TR/CSS2/box.html#margin-properties">
+<meta name="assert" content="margin-top supports animation">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'margin-top',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'margin-top',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'},
+]);
+
+test_composition({
+ property: 'margin-top',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'margin-top',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+
+test_composition({
+ property: 'margin-top',
+ underlying: '100px',
+ addFrom: '100px',
+ addTo: 'auto',
+}, [
+ {at: -0.3, expect: '200px'},
+ {at: 0, expect: '200px'},
+ {at: 0.5, expect: 'auto'},
+ {at: 1, expect: 'auto'},
+ {at: 1.5, expect: 'auto'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/padding-bottom-composition.html b/testing/web-platform/tests/css/css-box/animation/padding-bottom-composition.html
new file mode 100644
index 0000000000..855b5d3dc2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/padding-bottom-composition.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>padding-bottom composition</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#padding-shorthand">
+<meta name="assert" content="padding-bottom supports animation as a list of lengths">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'padding-bottom',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'padding-bottom',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'}, // Value clamping should happen after composition.
+]);
+
+test_composition({
+ property: 'padding-bottom',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'padding-bottom',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/padding-interpolation.html b/testing/web-platform/tests/css/css-box/animation/padding-interpolation.html
new file mode 100644
index 0000000000..3bf2841179
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/padding-interpolation.html
@@ -0,0 +1,108 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>padding interpolation</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#padding-shorthand">
+<meta name="assert" content="padding supports animation as a list of lengths">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<style>
+.parent {
+ padding: 30px;
+}
+.target {
+ width: 1px;
+ height: 1px;
+ background-color: black;
+ display: inline-block;
+ padding: 10px;
+}
+.expected {
+ background-color: green;
+ margin-right: 10px;
+}
+</style>
+
+<body></body>
+
+<script>
+test_interpolation({
+ property: 'padding',
+ from: neutralKeyframe,
+ to: '20px',
+}, [
+ {at: -0.3, expect: '7px'},
+ {at: 0, expect: '10px'},
+ {at: 0.3, expect: '13px'},
+ {at: 0.6, expect: '16px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '25px'},
+]);
+
+test_interpolation({
+ property: 'padding',
+ from: 'initial',
+ to: '20px',
+}, [
+ {at: -0.3, expect: '0px'},
+ {at: 0, expect: '0px'},
+ {at: 0.3, expect: '6px'},
+ {at: 0.6, expect: '12px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '30px'},
+]);
+
+test_interpolation({
+ property: 'padding',
+ from: 'inherit',
+ to: '20px',
+}, [
+ {at: -0.3, expect: '33px'},
+ {at: 0, expect: '30px'},
+ {at: 0.3, expect: '27px'},
+ {at: 0.6, expect: '24px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '15px'},
+]);
+
+test_interpolation({
+ property: 'padding',
+ from: 'unset',
+ to: '20px',
+}, [
+ {at: -0.3, expect: '0px'},
+ {at: 0, expect: '0px'},
+ {at: 0.3, expect: '6px'},
+ {at: 0.6, expect: '12px'},
+ {at: 1, expect: '20px'},
+ {at: 1.5, expect: '30px'},
+]);
+
+test_interpolation({
+ property: 'padding',
+ from: '0px',
+ to: '10px'
+}, [
+ {at: -0.3, expect: '0px'}, // CSS padding can't be negative.
+ {at: 0, expect: '0px'},
+ {at: 0.3, expect: '3px'},
+ {at: 0.6, expect: '6px'},
+ {at: 1, expect: '10px'},
+ {at: 1.5, expect: '15px'}
+]);
+
+test_interpolation({
+ property: 'padding',
+ from: '20px 40px 60px 80px',
+ to: '30px 50px 70px 90px'
+}, [
+ {at: -0.3, expect: '17px 37px 57px 77px'},
+ {at: 0, expect: '20px 40px 60px 80px'},
+ {at: 0.3, expect: '23px 43px 63px 83px'},
+ {at: 0.6, expect: '26px 46px 66px 86px'},
+ {at: 1, expect: '30px 50px 70px 90px'},
+ {at: 1.5, expect: '35px 55px 75px 95px'}
+]);
+</script>
diff --git a/testing/web-platform/tests/css/css-box/animation/padding-left-composition.html b/testing/web-platform/tests/css/css-box/animation/padding-left-composition.html
new file mode 100644
index 0000000000..417777ae25
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/padding-left-composition.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>padding-left composition</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#padding-shorthand">
+<meta name="assert" content="padding-left supports animation as a list of lengths">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'padding-left',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'padding-left',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'}, // Value clamping should happen after composition.
+]);
+
+test_composition({
+ property: 'padding-left',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'padding-left',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/padding-right-composition.html b/testing/web-platform/tests/css/css-box/animation/padding-right-composition.html
new file mode 100644
index 0000000000..3c80849bb2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/padding-right-composition.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>padding-right composition</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#padding-shorthand">
+<meta name="assert" content="padding-right supports animation as a list of lengths">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'padding-right',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'padding-right',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'}, // Value clamping should happen after composition.
+]);
+
+test_composition({
+ property: 'padding-right',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'padding-right',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/animation/padding-top-composition.html b/testing/web-platform/tests/css/css-box/animation/padding-top-composition.html
new file mode 100644
index 0000000000..b5083ae79b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/animation/padding-top-composition.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>padding-top composition</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#padding-shorthand">
+<meta name="assert" content="padding-top supports animation as a list of lengths">
+
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_composition({
+ property: 'padding-top',
+ underlying: '50px',
+ addFrom: '100px',
+ addTo: '200px',
+}, [
+ {at: -0.3, expect: '120px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '200px'},
+ {at: 1, expect: '250px'},
+ {at: 1.5, expect: '300px'},
+]);
+
+test_composition({
+ property: 'padding-top',
+ underlying: '100px',
+ addFrom: '10px',
+ addTo: '2px',
+}, [
+ {at: -0.5, expect: '114px'},
+ {at: 0, expect: '110px'},
+ {at: 0.5, expect: '106px'},
+ {at: 1, expect: '102px'},
+ {at: 1.5, expect: '98px'}, // Value clamping should happen after composition.
+]);
+
+test_composition({
+ property: 'padding-top',
+ underlying: '10%',
+ addFrom: '100px',
+ addTo: '20%',
+}, [
+ {at: -0.3, expect: 'calc(130px + 4%)'},
+ {at: 0, expect: 'calc(100px + 10%)'},
+ {at: 0.5, expect: 'calc(50px + 20%)'},
+ {at: 1, expect: '30%'},
+ {at: 1.5, expect: 'calc(-50px + 40%)'},
+]);
+
+test_composition({
+ property: 'padding-top',
+ underlying: '50px',
+ addFrom: '100px',
+ replaceTo: '200px',
+}, [
+ {at: -0.3, expect: '135px'},
+ {at: 0, expect: '150px'},
+ {at: 0.5, expect: '175px'},
+ {at: 1, expect: '200px'},
+ {at: 1.5, expect: '225px'},
+]);
+</script>
+</body>
diff --git a/testing/web-platform/tests/css/css-box/box-chrome-crash-001.html b/testing/web-platform/tests/css/css-box/box-chrome-crash-001.html
new file mode 100644
index 0000000000..351df37f15
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/box-chrome-crash-001.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<title>CSS Box: chrome crash</title>
+<link rel="author" href="mailto:atotic@google.com">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="help" href="https://crbug.com/967361">
+<meta name="assert" content="Chrome does not crash on narrow div with scrollbars.">
+<style>
+body {
+ writing-mode: vertical-lr;
+}
+#target {
+ overflow-y: scroll;
+ max-height: 5px;
+ background: gray;
+}
+</style>
+<!-- -->
+<div>
+ <span>
+ <div id="container">
+ <div id="target">anon</div>
+ </div>
+ </span>
+</div>
+
+<script>
+test(() => {
+}, 'test passes if it does not crash');
+</script>
diff --git a/testing/web-platform/tests/css/css-box/inheritance.html b/testing/web-platform/tests/css/css-box/inheritance.html
new file mode 100644
index 0000000000..bf10aeeb8e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/inheritance.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Inheritance of CSS Box Model properties</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#property-index">
+<link rel="help" href="https://www.w3.org/TR/CSS2/">
+<meta name="assert" content="Properties do not inherit.">
+<meta name="assert" content="length-percentage properties have initial value 0.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/inheritance-testcommon.js"></script>
+</head>
+<body>
+<div id="container">
+ <div id="target"></div>
+</div>
+<script>
+assert_not_inherited('clear', 'none', 'right');
+assert_not_inherited('float', 'none', 'right');
+
+assert_not_inherited('margin-bottom', '0px', '10px');
+assert_not_inherited('margin-left', '0px', '10px');
+assert_not_inherited('margin-right', '0px', '10px');
+assert_not_inherited('margin-top', '0px', '10px');
+assert_not_inherited('margin-trim', 'none', 'block');
+assert_not_inherited('padding-bottom', '0px', '10px');
+assert_not_inherited('padding-left', '0px', '10px');
+assert_not_inherited('padding-right', '0px', '10px');
+assert_not_inherited('padding-top', '0px', '10px');
+
+assert_inherited('visibility', 'visible', 'collapse');
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-001.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-001.html
new file mode 100644
index 0000000000..e31abec367
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-001.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-block-001</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block should trim block start and end margins for block-level first child">
+<style>
+.container {
+ background-color: green;
+ width: min-content;
+ margin-trim: block;
+}
+.outer {
+ background-color: green;
+ width: 100px;
+ height: 50px;
+}
+.child {
+ margin-top: 50px;
+ margin-bottom: 50px;
+ width: 100px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="container">
+ <div class="child"></div>
+ </div>
+ <div class="outer"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-002.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-002.html
new file mode 100644
index 0000000000..399141b17e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-002.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-block-002</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block should trim block start and end margins for ONLY block-level first/last children">
+<style>
+.container {
+ background-color: green;
+ width: min-content;
+ margin-trim: block;
+}
+.first {
+ margin-top: 50px;
+ height: 25px;
+}
+.second {
+ width: 100px;
+ height: 10px;
+ margin-bottom: 15px;
+}
+.third {
+ width: 100px;
+ height: 25px;
+ margin-bottom: 50px;
+}
+.outer {
+ width: 100px;
+ height: 25px;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="container">
+ <div class="first"></div>
+ <div class="second"></div>
+ <div class="third"></div>
+ </div>
+ <div class="outer"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-001.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-001.html
new file mode 100644
index 0000000000..fcee65692c
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-001.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-block-end-001</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-end should trim block end margin for block-level first child">
+<style>
+.container {
+ background-color: green;
+ width: min-content;
+ margin-trim: block-end;
+}
+.outer {
+ background-color: green;
+ width: 100px;
+ height: 50px;
+}
+.child {
+ margin-bottom: 50px;
+ width: 100px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="container">
+ <div class="child"></div>
+ </div>
+ <div class="outer"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-002.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-002.html
new file mode 100644
index 0000000000..42d559fbe9
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-end-002.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-block-end-002</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-end should trim block end margin for ONLY block-level first child">
+<style>
+.container {
+ width: min-content;
+ margin-trim: block-end;
+ background-color: green;
+}
+.outer {
+ width: 100px;
+ height: 40px;
+ background-color: green;
+}
+.first {
+ width: 100px;
+ margin-bottom: 25px;
+ height: 25px;
+}
+.second {
+ margin-bottom: 100px;
+ width: 100px;
+ height: 10px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="container">
+ <div class="first"></div>
+ <div class="second"></div>
+ </div>
+ <div class="outer"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-001.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-001.html
new file mode 100644
index 0000000000..c33c7f0abe
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-001.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-block-start-001</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-start should trim block start margin for block-level first child">
+<style>
+.container {
+ background-color: green;
+ width: min-content;
+ margin-trim: block-start;
+}
+.outer {
+ background-color: green;
+ width: 100px;
+ height: 50px;
+}
+.child {
+ width: 100px;
+ margin-top: 50px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="outer"></div>
+ <div class="container">
+ <div class="child"></div>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-002.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-002.html
new file mode 100644
index 0000000000..339c990d10
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-block-start-002.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-block-start-002</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-start should trim block start margin for ONLY block-level first child">
+<style>
+.container {
+ background-color: green;
+ width: min-content;
+ margin-trim: block-start;
+}
+.outer {
+ background-color: green;
+ width: 100px;
+ height: 10px;
+}
+.first {
+ margin-top: 50px;
+ width: 100px;
+ height: 40px;
+}
+.second {
+ margin-top: 10px;
+ width: 100px;
+ height: 40px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="outer"></div>
+ <div class="container">
+ <div class="first"></div>
+ <div class="second"></div>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item-ref.html
new file mode 100644
index 0000000000..4affb87f11
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item-ref.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-non-adjoining-item</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<meta name="assert" content="non-adjoining first child should still have its margins trimmed and the container should keep its set margin">
+<style>
+.container {
+ background-color: green;
+ width: min-content;
+ margin-bottom: 100px;
+ padding-bottom: 50px;
+ background-clip: padding-box;
+}
+.child {
+ width: 100px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+<div class="container">
+ <div class="child"></div>
+</div>
+<div>This text should be 100px below the green square.</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item.html
new file mode 100644
index 0000000000..215175418b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-non-adjoining-item.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-non-adjoining-item</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="block-container-non-adjoining-item-ref.html">
+<meta name="assert" content="non-adjoining first child should still have its margins trimmed and the container should keep its set margin">
+<style>
+.container {
+ background-color: green;
+ width: min-content;
+ margin-bottom: 100px;
+ padding-bottom: 50px;
+ background-clip: padding-box;
+ margin-trim: block;
+}
+.child {
+ margin-top: 50px;
+ margin-bottom: 200px;
+ width: 100px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+<div class="container">
+ <div class="child"></div>
+</div>
+<div>This text should be 100px below the green square.</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-end.html
new file mode 100644
index 0000000000..0225460b7b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-end.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-replaced-block-end</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block level replaced element should have block-end trimmed">
+<style>
+.container {
+ width: min-content;
+ margin-trim: block-end;
+}
+.outer {
+ background-color: green;
+ width: 100px;
+ height: 40px;
+}
+.child {
+ display: block;
+ margin-bottom: 50px;
+ background-color: green;
+ padding-right: 40px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="container">
+ <img class="child" src="/css/support/60x60-green.png"/>
+ </div>
+ <div class="outer"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-start.html
new file mode 100644
index 0000000000..10080c974f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block-start.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-replaced-block-start</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block level replaced element should have block-start trimmed">
+<style>
+.container {
+ width: min-content;
+ margin-trim: block-start;
+}
+.outer {
+ background-color: green;
+ width: 100px;
+ height: 40px;
+}
+.child {
+ display: block;
+ margin-top: 50px;
+ background-color: green;
+ padding-right: 40px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="outer"></div>
+ <div class="container">
+ <img class="child" src="/css/support/60x60-green.png"/>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block.html b/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block.html
new file mode 100644
index 0000000000..036066f691
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/block-container-replaced-block.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: block-container-replaced-block</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block level replaced element should have both block-start and block-end trimmed when block is specified">
+<style>
+.container {
+ width: min-content;
+ margin-trim: block;
+}
+.outer {
+ background-color: green;
+ width: 100px;
+ height: 40px;
+}
+.child {
+ display: block;
+ margin-top: 50px;
+ margin-bottom: 50px;
+ background-color: green;
+ padding-right: 40px;
+}
+</style>
+</head>
+<body>
+ <p>Test passes if there is a filled green square.</p>
+ <div class="container">
+ <img class="child" src="/css/support/60x60-green.png"/>
+ </div>
+ <div class="outer"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child.html
new file mode 100644
index 0000000000..8a3b03c2e5
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-nested-child.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<meta name="assert" content="Items, including self-collapsing ones, at the block-end of the container should have their margins trimmed">
+<style>
+container {
+ display: block;
+ inline-size: min-content;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ inline-size: 50px;
+ block-size: 10px;
+ margin-block-end: 10px;
+}
+.border {
+ border: 1px solid black;
+}
+.collapsed {
+ block-size: 0px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('item')">
+ <div id="target">
+ <container>
+ <item data-expected-margin-bottom="10"></item>
+ <item data-expected-margin-bottom="0" style="block-size: auto;">
+ <div><item data-expected-margin-bottom="10"></item></div>
+ <div>
+ <item data-expected-margin-bottom="0" style="block-size: auto;">
+ <div><item data-expected-margin-bottom="0"></item></div>
+ </item>
+ <item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item>
+ </div>
+ <item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item>
+ </item>
+ <item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item>
+ </container>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children.html
new file mode 100644
index 0000000000..26d46628ef
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end-with-self-collapsing-children.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<meta name="assert" content="Second item and all self-collapsing children at block-end should have margins trimmed">
+<style>
+container {
+ display: block;
+ inline-size: min-content;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ inline-size: 50px;
+ block-size: 50px;
+ margin-block-end: 10px;
+}
+.collapsed {
+ block-size: 0px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('item')">
+ <div id="target">
+ <container>
+ <item data-expected-margin-bottom="10"></item>
+ <item data-expected-margin-bottom="0"></item>
+ <item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item></div>
+ </item></div>
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item>
+ <item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ <div><item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item></div>
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item></div>
+ <div><item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0">
+ <div><item class="collapsed" data-expected-margin-bottom="0"></item></div>
+ </item></div>
+ </item></div>
+ </item>
+ <item class="collapsed" data-expected-margin-bottom="0"></item>
+ </container>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end.html
new file mode 100644
index 0000000000..6cd0cce263
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-end.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<meta name="assert" content="block-end margin of item should be trimmed">
+<style>
+container {
+ display: block;
+ inline-size: min-content;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ inline-size: 50px;
+ block-size: 50px;
+ margin-block-end: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('item')">
+ <div id="target">
+ <container>
+ <item data-expected-margin-bottom="0"></item>
+ </container>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-child-with-border.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-child-with-border.html
new file mode 100644
index 0000000000..fc9bb93394
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-child-with-border.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<meta name="assert" content="item with border should prevent trimming within itself">
+<style>
+container {
+ display: block;
+ margin-trim: block;
+ border: 1px solid black;
+ margin-block-start: 10px;
+}
+item {
+ display: block;
+ inline-size: 50px;
+ block-size: 50px;
+ background-color: green;
+}
+.collapsed {
+ margin-block: 50px;
+ block-size: 0px
+}
+.with-border-and-margin {
+ border: 1px solid black;
+ margin-block-start: 30px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('item')">
+ <container>
+ <item data-expected-margin-top="0" class="collapsed">
+ <item data-expected-margin-top="0" class="collapsed"></item>
+ </item>
+ <item class="with-border-and-margin" data-expected-margin-top="0">
+ <item class="with-border-and-margin" data-expected-margin-top="30"></item>
+ </item>
+ </container>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-self-collapsing-nested.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-self-collapsing-nested.html
new file mode 100644
index 0000000000..e7963f327f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start-self-collapsing-nested.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<meta name="assert" content="self-collapsing items at block start should have margins trimmed along with first non self-collapsing child block-start margins">
+<style>
+container {
+ display: block;
+ margin-trim: block;
+ border: 1px solid black;
+ margin-block-start: 10px;
+}
+item {
+ display: block;
+ inline-size: 50px;
+ background-color: green;
+}
+.collapsed {
+ margin-block-start: 50px;
+ block-size: 0px
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload=" checkLayout('container, item');">
+ <container data-expected-margin-top="10">
+ <item data-expected-margin-top="0" class="collapsed">
+ <item data-expected-margin-top="0" class="collapsed"></item>
+ </item>
+ <item data-expected-margin-top="0" style="margin-block: 40px">
+ <item data-expected-margin-top="0" data-expected-margin-bottom="0" class="collapsed"></item>
+ <item data-expected-margin-top="0" style="margin-top: 30px;">
+ <item data-expected-margin-top="0" style="margin-block-start: 100px; height: 50px;"></item>
+ </item>
+ </item>
+ </container>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start.html
new file mode 100644
index 0000000000..3a334fc056
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/block-container-block-start.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-block">
+<meta name="assert" content="block-start margin of item should be trimmed">
+<style>
+container {
+ display: block;
+ margin-trim: block;
+ border: 1px solid black;
+ margin-block-start: 10px;
+}
+item {
+ display: block;
+ inline-size: 50px;
+ block-size: 50px;
+ background-color: green;
+}
+.collapsed {
+ margin-block: 50px;
+ block-size: 0px
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('item')">
+ <container>
+ <item style="margin-top: 30px;" data-expected-margin-top="0"></item>
+ </container>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-end.html
new file mode 100644
index 0000000000..ecc266378d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-end.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-end trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-end: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-bottom="10" data-offset-y="8"></item>
+ <item data-expected-margin-bottom="0" data-offset-y="68"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-start.html
new file mode 100644
index 0000000000..6c760bb1f0
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-block-start.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-start trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-start: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-top="0" data-offset-y="8"></item>
+ <item data-expected-margin-top="10" data-offset-y="68"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end.html
new file mode 100644
index 0000000000..9bf43356f2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-end margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ margin-trim: inline-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(1) {
+ margin-inline-end: 10px;
+}
+item:nth-child(2) {
+ margin-inline-end: -10px;
+}
+item:nth-child(3) {
+ margin-inline-end: 30%;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-right="0" data-offset-x="8"></item>
+ <item data-expected-margin-right="0" data-offset-x="8"></item>
+ <item data-expected-margin-right="0" data-offset-x="8"></item>
+</flexbox>
+</div>
+</body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-start.html
new file mode 100644
index 0000000000..681c9b859f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-start.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-start margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(1) {
+ margin-inline-start: 10px;
+}
+item:nth-child(2) {
+ margin-inline-start: -10px;
+}
+item:nth-child(3) {
+ margin-inline-start: 30%;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-left="0" data-offset-x="8"></item>
+ <item data-expected-margin-left="0" data-offset-x="8"></item>
+ <item data-expected-margin-left="0" data-offset-x="8"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-end.html
new file mode 100644
index 0000000000..61f11a9b31
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-end.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-end trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ flex-wrap: wrap;
+ width: 100px;
+ height: 110px;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-end: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-offset-y="8" data-expected-margin-bottom="10"></item>
+ <item data-offset-y="68" data-expected-margin-bottom="0"></item>
+ <item data-offset-y="8" data-expected-margin-bottom="10"></item>
+ <item data-offset-y="68" data-expected-margin-top="0"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-start.html
new file mode 100644
index 0000000000..517619db49
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block-start.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-start trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ flex-wrap: wrap;
+ width: 10px;
+ height: 110px;
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-start: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-offset-y="8" data-expected-margin-top="0"></item>
+ <item data-offset-y="68" data-expected-margin-top="10"></item>
+ <item data-offset-y="8" data-expected-margin-top="0"></item>
+ <item data-offset-y="68" data-expected-margin-top="10"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block.html
new file mode 100644
index 0000000000..e01067fbe2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-block.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="both trimmed block margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ flex-wrap: wrap;
+ width: 100px;
+ height: 120px;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-offset-y="8" data-expected-margin-top="0" data-expected-margin-bottom="10"></item>
+ <item data-offset-y="78" data-expected-margin-top="10" data-expected-margin-bottom="0" ></item>
+ <item data-offset-y="8" data-expected-margin-top="0" data-expected-margin-bottom="10"></item>
+ <item data-offset-y="78" data-expected-margin-top="10" data-expected-margin-bottom="0"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end.html
new file mode 100644
index 0000000000..4d3d5b5326
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-end margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ flex-wrap: wrap;
+ width: min-content;
+ height: 100px;
+ margin-trim: inline-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-end: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-offset-x="8" data-expected-margin-right="10"></item>
+ <item data-offset-x="8" data-expected-margin-right="10"></item>
+ <item data-offset-x="68" data-expected-margin-right="0"></item>
+ <item data-offset-x="68" data-expected-margin-right="0"></item>
+</flexbox>
+</div>
+</body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-start.html
new file mode 100644
index 0000000000..1e4d007658
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-start.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-start margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ flex-wrap: wrap;
+ width: min-content;
+ height: 100px;
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-start: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-offset-x="8" data-expected-margin-left="0"></item>
+ <item data-offset-x="8" data-expected-margin-left="0"></item>
+ <item data-offset-x="68" data-expected-margin-left="10"></item>
+ <item data-offset-x="68" data-expected-margin-left="10"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-style-change-triggers-layout-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-style-change-triggers-layout-block-start.html
new file mode 100644
index 0000000000..175b5c3f2f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-style-change-triggers-layout-block-start.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Make sure margins are no longer trimmed when margin-trim is changed to none on the flexbox">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-start: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body>
+<div id="target">
+<flexbox>
+ <item data-expected-margin-top="10" data-offset-y="18"></item>
+ <item data-expected-margin-top="10" data-offset-y="78"></item>
+</flexbox>
+</div>
+<script>
+// Force the first layout to trim margins, set margin-trim to none,
+// force a second layout, and then check to see if the margins were added back
+document.body.offsetHeight;
+document.querySelector("flexbox").style["margin-trim"] = "none";
+document.body.offsetHeight;
+checkLayout("flexbox > item");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-end.html
new file mode 100644
index 0000000000..f5ca9854fe
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-end.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-end trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+}
+item:nth-child(1) {
+ margin-block-end: 10px;
+}
+item:nth-child(2) {
+ margin-block-end: -10px;
+}
+item:nth-child(3) {
+ margin-block-end: 30%;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-bottom="0"></item>
+ <item data-expected-margin-bottom="0"></item>
+ <item data-expected-margin-bottom="0"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-start.html
new file mode 100644
index 0000000000..9597c9aa10
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block-start.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-start trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+}
+item:nth-child(1) {
+ margin-block-start: 10px;
+}
+item:nth-child(2) {
+ margin-block-start: -10px;
+}
+item:nth-child(3) {
+ margin-block-start: 30%;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-top="0" data-offset-y="8"></item>
+ <item data-expected-margin-top="0" data-offset-y="8"></item>
+ <item data-expected-margin-top="0" data-offset-y="8"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block.html
new file mode 100644
index 0000000000..6c35fa6ac2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-block.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="both trimmed block margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+}
+item:nth-child(1) {
+ margin-block: 10px;
+}
+item:nth-child(2) {
+ margin-block: -10px;
+}
+item:nth-child(3) {
+ margin-block: 30%;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-top="0" data-expected-margin-bottom="0" data-offset-y="8"></item>
+ <item data-expected-margin-top="0" data-expected-margin-bottom="0" data-offset-y="8"></item>
+ <item data-expected-margin-top="0" data-expected-margin-bottom="0" data-offset-y="8"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end.html
new file mode 100644
index 0000000000..2c20625ed3
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-end margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ margin-trim: inline-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-end: 20px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-right="20" data-offset-x="8"></item>
+ <item data-expected-margin-right="20" data-offset-x="78"></item>
+ <item data-expected-margin-right="0" data-offset-x="148"></item>
+</flexbox>
+</div>
+</body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-start.html
new file mode 100644
index 0000000000..24ce7f90e2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-start.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-start margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-start: 20px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-left="0" data-offset-x="8"></item>
+ <item data-expected-margin-left="20" data-offset-x="78"></item>
+ <item data-expected-margin-left="20" data-offset-x="148"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-end.html
new file mode 100644
index 0000000000..f4c90c29f9
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-end.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-end trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ flex-wrap: wrap;
+ width: 100px;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-end: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-offset-y="8" data-expected-margin-bottom="10"></item>
+ <item data-offset-y="8" data-expected-margin-bottom="10"></item>
+ <item data-offset-y="68" data-expected-margin-bottom="0"></item>
+ <item data-offset-y="68" data-expected-margin-bottom="0"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-start.html
new file mode 100644
index 0000000000..c3190e1a93
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block-start.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-start trimmed margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ width: 100px;
+ flex-wrap: wrap;
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(1) {
+ margin-block-start: 10px;
+}
+item:nth-child(2) {
+ margin-block-start: -10px;
+}
+item:nth-child(3) {
+ margin-block-start: 10px;
+}
+item:nth-child(4) {
+ margin-block-start: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-top="0" data-offset-y="8"></item>
+ <item data-expected-margin-top="0" data-offset-y="8"></item>
+ <item data-expected-margin-top="10" data-offset-y="68"></item>
+ <item data-expected-margin-top="10" data-offset-y="68"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block.html
new file mode 100644
index 0000000000..1db5680306
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-block.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="both trimmed block margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ width: 100px;
+ flex-wrap: wrap;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block: 10px;
+}
+
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-top="0" data-expected-margin-bottom="10" data-offset-y="8"></item>
+ <item data-expected-margin-top="0" data-expected-margin-bottom="10" data-offset-y="8"></item>
+ <item data-expected-margin-top="10" data-expected-margin-bottom="0" data-offset-y="78"></item>
+ <item data-expected-margin-top="10" data-expected-margin-bottom="0" data-offset-y="78"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end.html
new file mode 100644
index 0000000000..8a59bc4171
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-end margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ width: 110px;
+ flex-wrap: wrap;
+ margin-trim: inline-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(1) {
+ margin-inline-end: 10px;
+}
+item:nth-child(2) {
+ margin-inline-end: -10px;
+}
+item:nth-child(3) {
+ margin-inline-end: 10px;
+}
+item:nth-child(4) {
+ margin-inline-end: 50%;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-right="10" data-offset-x="8"></item>
+ <item data-expected-margin-right="0" data-offset-x="68"></item>
+ <item data-expected-margin-right="10" data-offset-x="8"></item>
+ <item data-expected-margin-right="0" data-offset-x="68"></item>
+</flexbox>
+</div>
+</body>
+</html> \ No newline at end of file
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-start.html
new file mode 100644
index 0000000000..9b925a7b68
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-start.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="trimmed inline-start margins should be reflected in computed style">
+<style>
+flexbox {
+ display: flex;
+ width: 110px;
+ flex-wrap: wrap;
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(1) {
+ margin-inline-start: 10px;
+}
+item:nth-child(2) {
+ margin-inline-start: -10px;
+}
+item:nth-child(3) {
+ margin-inline-start: 50%;
+}
+item:nth-child(4) {
+ margin-inline-start: 10px;
+}
+</style>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/check-layout-th.js"></script>
+</head>
+<body onload="checkLayout('flexbox > item')">
+<div id="target">
+<flexbox>
+ <item data-expected-margin-left="0" data-offset-x="8"></item>
+ <item data-expected-margin-left="-10" data-offset-x="48"></item>
+ <item data-expected-margin-left="0" data-offset-x="8"></item>
+ <item data-expected-margin-left="10" data-offset-x="68"></item>
+</flexbox>
+</div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-column-auto-flow.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-column-auto-flow.html
new file mode 100644
index 0000000000..f49f036a63
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-column-auto-flow.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="Trimmed block-end margins for grid items should be reflected in computed style">
+</head>
+<style>
+grid {
+ display: grid;
+ width: min-content;
+ grid-auto-flow: column;
+ border: 1px solid black;
+ grid-template-rows: auto auto auto;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ width: 50px;
+ height: 50px;
+ margin-block-end: 10px;
+}
+.span-four {
+ grid-row: span 4;
+}
+item:nth-child(1) {
+ grid-row: 1;
+ background-color: green;
+}
+item:nth-child(2) {
+ grid-row: 2;
+ background-color: blue;
+}
+item:nth-child(3) {
+ grid-row: 3;
+ background-color: purple;
+}
+item:nth-child(4) {
+ background-color:burlywood;
+}
+item:nth-child(5) {
+ background-color: grey;
+ grid-row: 4;
+}
+</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 > item')">
+ <div id="target">
+ <grid>
+ <item data-expected-margin-bottom="10"></item>
+ <item data-expected-margin-bottom="10"></item>
+ <item data-expected-margin-bottom="10"></item>
+ <item data-expected-margin-bottom="0" class="span-four"></item>
+ <item data-expected-margin-bottom="0"></item>
+ </grid>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-item-spans-multiple-rows.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-item-spans-multiple-rows.html
new file mode 100644
index 0000000000..d44085ed8a
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end-item-spans-multiple-rows.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="item that spans into last row should have block-end margin trimmed">
+</head>
+<style>
+grid {
+ display: grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ width: 50px;
+ height: 50px;
+ margin-bottom: 10px;
+}
+.row-two {
+ grid-row: 2;
+ background-color: green;
+}
+.span-two-rows {
+ grid-row: span 2;
+ background-color: blue;
+ height: 90px;
+}
+</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 > item')">
+ <div id="target">
+ <grid>
+ <item data-expected-margin-bottom="0" class="span-two-rows"></item>
+ <item data-expected-margin-bottom="0" class="row-two"></item>
+ </grid>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end.html
new file mode 100644
index 0000000000..a7d5f44f37
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-block-end.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="Trimmed block-end margins for grid items should be reflected in computed style">
+</head>
+<style>
+grid {
+ display: grid;
+ width: min-content;
+ border: 1px solid black;
+ grid-template-columns: repeat(4, auto);
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ width: 50px;
+ height: 50px;
+ margin-bottom: 10px;
+}
+.locked-position {
+ grid-row: 2;
+ grid-column: 2;
+ margin-block-end: 50px;
+ background-color: magenta;
+}
+.span-three-columns {
+ grid-column: span 3;
+ background-color: purple;
+}
+.span-five-columns {
+ grid-column: span 5;
+}
+item:nth-child(1) {
+ background-color: green;
+}
+item:nth-child(4) {
+ background-color: blue;
+}
+</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 > item')">
+ <div id="target">
+ <grid>
+ <item class="span-five-columns" data-expected-margin-bottom="10"></item>
+ <item class="locked-position" data-expected-margin-bottom="50"></item>
+ <item class="span-three-columns" data-expected-margin-bottom="10"></item>
+ <item data-expected-margin-bottom="0"></item>
+ </grid>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start-item-negative-span.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start-item-negative-span.html
new file mode 100644
index 0000000000..80b97e9cd0
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start-item-negative-span.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="trimmed inline-start margins in grid should be reflected in computed style">
+</head>
+<style>
+grid {
+ display: grid;
+ width: min-content;
+ outline: 1px solid black;
+ grid-template-columns: repeat(2, auto);
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ width: 50px;
+ height: 50px;
+ margin-inline-start: 10px;
+ background-color: green;
+}
+.negative-line-number {
+ width: 50px;
+ grid-row: 2;
+ grid-column: -3;
+ background-color: blue;
+}
+</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 > item')">
+ <div id="target">
+ <grid>
+ <item data-expected-margin-left="0" class="negative-line-number"></item>
+ <item data-expected-margin-left="0"></item>
+ </grid>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start.html b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start.html
new file mode 100644
index 0000000000..380090f3a9
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/computed-margin-values/grid-inline-start.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="trimmed inline-start margins in grid should be reflected in computed style">
+</head>
+<style>
+grid {
+ display: grid;
+ width: min-content;
+ outline: 1px solid black;
+ grid-template-columns: repeat(2, auto);
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ width: 50px;
+ height: 50px;
+}
+.locked-position {
+ grid-row: 3;
+ grid-column: 1;
+ margin-inline-start: -30px;
+}
+item:nth-child(1) {
+ background-color: green;
+ margin-inline-start: 30px;
+}
+item:nth-child(2) {
+ background-color: blue;
+ margin-inline-start: 10px;
+}
+item:nth-child(3) {
+ background-color: orchid;
+ margin-inline-start: 10%;
+}
+item:nth-child(4) {
+ background-color: maroon;
+}
+item:nth-child(5) {
+ background-color: salmon;
+ width: auto;
+ grid-column: span 2;
+ margin-inline-start: 10px;
+}
+</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 > item')">
+ <div id="target">
+ <grid>
+ <item data-expected-margin-left="0"></item>
+ <item data-expected-margin-left="10"></item>
+ <item data-expected-margin-left="0"></item>
+ <item class="locked-position" data-expected-margin-left="0"></item>
+ <item data-expected-margin-left="0"></item>
+ </grid>
+ </div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only-ref.html
new file mode 100644
index 0000000000..5145182436
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-block-end-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-end should trim only margin block end of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block-start: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only.html
new file mode 100644
index 0000000000..0a99b3f308
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-end-trimmed-only.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-block-end-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-block-end-trimmed-only-ref.html">
+<meta name="assert" content="block-end should trim only margin block end of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only-ref.html
new file mode 100644
index 0000000000..58a7e5ba31
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-block-start-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-start should trim only margin block start of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block-end: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only.html
new file mode 100644
index 0000000000..5e867ea43d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-start-trimmed-only.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-block-start-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-block-start-trimmed-only-ref.html">
+<meta name="assert" content="block-start should trim only margin block start of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only-ref.html
new file mode 100644
index 0000000000..f4cf4fec86
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only-ref.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-block-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block should trim only block margins of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only.html
new file mode 100644
index 0000000000..e730482825
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-block-trimmed-only.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-block-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-block-trimmed-only-ref.html">
+<meta name="assert" content="block should trim only block margins of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-block-multiline.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-block-multiline.html
new file mode 100644
index 0000000000..6536d7f00d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-block-multiline.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-column-block-multiline</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block-start should be trimmed for items at the start of the flex line and block-end should be trimmed for items at the end of the flex line">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ height: 100px;
+ flex-wrap: wrap;
+ flex-direction: column;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(odd) {
+ margin-block-start: 25px;
+}
+item:nth-child(even) {
+ margin-block-end: 25px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-grow.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-grow.html
new file mode 100644
index 0000000000..62c55b2bff
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-grow.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-column-grow</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="items should grow to take up the space made available by trimming margins">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ height: 100px;
+ flex-direction: column;
+ margin-trim: block;
+}
+item {
+ display: block;
+ width: 100px;
+ height: 50px;
+ margin-block: 25px;
+ flex: 1 0 auto;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline-ref.html
new file mode 100644
index 0000000000..c4b36a91b7
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-column-inline-multiline</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="inline-start should be trimmed for all items on the first flex line and inline-end should be trimmed for all items on the last flex line">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ height: 100px;
+ flex-direction: column;
+ flex-wrap: wrap;
+ gap: 0px 30px;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline.html
new file mode 100644
index 0000000000..25003aab08
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-inline-multiline.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-column-inline-multiline</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-column-inline-multiline-ref.html">
+<meta name="assert" content="inline-start should be trimmed for all items on the first flex line and inline-end should be trimmed for all items on the last flex line">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ height: 100px;
+ flex-direction: column;
+ flex-wrap: wrap;
+ margin-trim: inline;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-start: 10px;
+ margin-inline-end: 20px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-orthogonal-item.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-orthogonal-item.html
new file mode 100644
index 0000000000..9f13e2ce71
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-orthogonal-item.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-column-orthogonal-item</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="orthogonal items have correct margins trimmed according to the flexbox's writing mode">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 100px;
+ height: 50px;
+}
+.orthogonal {
+ writing-mode: vertical-rl;
+}
+item:first-child {
+ margin-inline-start: 10px;
+}
+item:last-child {
+ margin-block-end: 10px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item class="orthogonal"></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-shrink.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-shrink.html
new file mode 100644
index 0000000000..06395ff6d5
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-shrink.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-column-shrink</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="content should fill all available space when flex item is larger than the container and the margins are trimmed">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ height: 100px;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ margin-block: 25px;
+ flex: 0 1 auto;
+ width: 100px;
+ height: 150px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end-ref.html
new file mode 100644
index 0000000000..933ce0cb3b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.margin {
+ margin-block-end: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox>
+ <item class="margin"></item>
+ </flexbox>
+ <flexbox>
+ <item></item>
+ </flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end.html
new file mode 100644
index 0000000000..80f2c62d23
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-end.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<link rel="match" href="flex-column-style-change-triggers-layout-block-end-ref.html">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+.initial-margin-trim {
+ margin-trim: block-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-end: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox class="initial-margin-trim" id="to-no-margin-trim">
+ <item></item>
+ </flexbox>
+ <flexbox id="to-margin-trim">
+ <item></item>
+ </flexbox>
+</body>
+<script>
+document.body.offsetHeight;
+document.getElementById("to-no-margin-trim").style["margin-trim"] = "none";
+document.getElementById("to-margin-trim").style["margin-trim"] = "block-end";
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-ref.html
new file mode 100644
index 0000000000..7b53e757d5
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.margin {
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox>
+ <item class="margin"></item>
+ </flexbox>
+ <flexbox>
+ <item></item>
+ </flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start-ref.html
new file mode 100644
index 0000000000..d58cd0827d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.margin {
+ margin-block-start: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox>
+ <item class="margin"></item>
+ </flexbox>
+ <flexbox>
+ <item></item>
+ </flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start.html
new file mode 100644
index 0000000000..15bdcdaebc
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block-start.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-column-style-change-triggers-layout-block-start-ref.html">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+.initial-margin-trim {
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-start: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox class="initial-margin-trim" id="to-no-margin-trim">
+ <item></item>
+ </flexbox>
+ <flexbox id="to-margin-trim">
+ <item></item>
+ </flexbox>
+</body>
+<script>
+document.body.offsetHeight;
+document.getElementById("to-no-margin-trim").style["margin-trim"] = "none";
+document.getElementById("to-margin-trim").style["margin-trim"] = "block-start";
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block.html
new file mode 100644
index 0000000000..505f62ff28
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-column-style-change-triggers-layout-block.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-column-style-change-triggers-layout-block-ref.html">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ flex-direction: column;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+.initial-margin-trim {
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox class="initial-margin-trim" id="to-no-margin-trim">
+ <item></item>
+ </flexbox>
+ <flexbox id="to-margin-trim">
+ <item></item>
+ </flexbox>
+</body>
+<script>
+document.body.offsetHeight;
+document.getElementById("to-no-margin-trim").style["margin-trim"] = "none";
+document.getElementById("to-margin-trim").style["margin-trim"] = "block";
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only-ref.html
new file mode 100644
index 0000000000..9fb945d00c
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-inline-end-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="inline-end should trim only inline-end margins of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ gap: 20px;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block: 10px;
+}
+item:first-child {
+ margin-inline-start: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only.html
new file mode 100644
index 0000000000..33451daf30
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-end-trimmed-only.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-inline-end-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-inline-end-trimmed-only-ref.html">
+<meta name="assert" content="inline-end should trim only inline-end margins of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ margin-trim: inline-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only-ref.html
new file mode 100644
index 0000000000..f7dc9ec5c5
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only-ref.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-inline-start-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="inline-start should trim only inline-start margin of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ gap: 20px;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block: 10px;
+}
+item:last-child {
+ margin-inline-end: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only.html
new file mode 100644
index 0000000000..05cf112e66
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-start-trimmed-only.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-inline-start-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-inline-start-trimmed-only-ref.html">
+<meta name="assert" content="inline-start trims only inline-start margin of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only-ref.html
new file mode 100644
index 0000000000..e262b903df
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-inline-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="inline should trim only the inline margins of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ gap: 20px;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only.html
new file mode 100644
index 0000000000..637dc485af
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-inline-trimmed-only.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-inline-trimmed-only</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-inline-trimmed-only-ref.html">
+<meta name="assert" content="inline will trim only the inline margins of flex items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ border: 1px black solid;
+ margin-trim: inline;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline-ref.html
new file mode 100644
index 0000000000..8eb29f5806
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline-ref.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-row-block-multiline</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="block-start margins are trimmed for items on first flex line and block-end margins and trimmed for items on last flex line">
+<style>
+flexbox {
+ display: flex;
+ width: 100px;
+ flex-wrap: wrap;
+ gap: 20px 0px;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline.html
new file mode 100644
index 0000000000..c8fc788ca2
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-block-multiline.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-row-block-multiline</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-row-block-multiline-ref.html">
+<meta name="assert" content="block-start margins are trimmed for items on first flex line and block-end margins and trimmed for items on last flex line">
+<style>
+flexbox {
+ display: flex;
+ width: 100px;
+ flex-wrap: wrap;
+ margin-trim: block;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-grow.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-grow.html
new file mode 100644
index 0000000000..64395461cf
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-grow.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-row-grow</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="items should grow to take up the space made available by trimming margins">
+<style>
+flexbox {
+ display: flex;
+ width: 100px;
+ margin-trim: inline;
+}
+item {
+ display: block;
+ width: 50px;
+ height: 100px;
+ margin-inline: 25px;
+ flex: 1 0 auto;
+ background-color: green;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-inline-multiline.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-inline-multiline.html
new file mode 100644
index 0000000000..d563373d50
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-inline-multiline.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-row-inline-multiline</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="inline-start margins are trimmed for items at start of flex line and inline-end margins are trimmed for items at end of flex line">
+<style>
+flexbox {
+ display: flex;
+ width: 100px;
+ flex-wrap: wrap;
+ margin-trim: inline;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(odd) {
+ margin-inline-start: 25px;
+}
+item:nth-child(even) {
+ margin-inline-end: 25px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-orthogonal-item.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-orthogonal-item.html
new file mode 100644
index 0000000000..3facc7450c
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-orthogonal-item.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-row-orthogonal-item</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="orthogonal items have correct margins trimmed according to the flexbox's writing mode">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ margin-trim: inline
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 100px;
+}
+.orthogonal {
+ writing-mode: vertical-rl;
+}
+item:first-child {
+ margin-block-end: 10px;
+}
+item:last-child {
+ margin-inline-end: 10px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item class="orthogonal"></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-shrink.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-shrink.html
new file mode 100644
index 0000000000..172c946cb4
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-shrink.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-row-shrink</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="content should fill all available space when flex item is larger than the container and the margins are trimmed">
+<style>
+flexbox {
+ display: flex;
+ width: 100px;
+ margin-trim: inline;
+}
+item {
+ display: block;
+ background-color: green;
+ margin-inline: 25px;
+ flex: 0 1 auto;
+ width: 150px;
+ height: 100px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<flexbox>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end-ref.html
new file mode 100644
index 0000000000..cee1fbb55f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.margin {
+ margin-inline-end: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox>
+ <item class="margin"></item>
+ </flexbox>
+ <flexbox>
+ <item></item>
+ </flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end.html
new file mode 100644
index 0000000000..c17e043548
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-end.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<link rel="match" href="flex-row-style-change-triggers-layout-inline-end-ref.html">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+.initial-margin-trim {
+ margin-trim: inline-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-end: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox id="to-no-margin-trim" class="initial-margin-trim">
+ <item></item>
+ </flexbox>
+ <flexbox id="to-margin-trim">
+ <item></item>
+ </flexbox>
+</body>
+<script>
+document.body.offsetHeight;
+document.getElementById("to-no-margin-trim").style["margin-trim"] = "none";
+document.getElementById("to-margin-trim").style["margin-trim"] = "inline-end";
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-ref.html
new file mode 100644
index 0000000000..455a88f78e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.margin {
+ margin-inline: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox>
+ <item class="margin"></item>
+ </flexbox>
+ <flexbox>
+ <item></item>
+ </flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start-ref.html
new file mode 100644
index 0000000000..966bdf1be8
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.margin {
+ margin-inline-start: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox>
+ <item class="margin"></item>
+ </flexbox>
+ <flexbox>
+ <item></item>
+ </flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start.html
new file mode 100644
index 0000000000..87118ff698
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline-start.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-row-style-change-triggers-layout-inline-start-ref.html">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+.initial-margin-trim {
+ margin-trim: inline-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-start: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox class="initial-margin-trim" id="to-no-margin-trim">
+ <item></item>
+ </flexbox>
+ <flexbox id="to-margin-trim">
+ <item></item>
+ </flexbox>
+</body>
+<script>
+document.body.offsetHeight;
+document.getElementById("to-no-margin-trim").style["margin-trim"] = "none";
+document.getElementById("to-margin-trim").style["margin-trim"] = "inline-start";
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline.html
new file mode 100644
index 0000000000..2e02643e58
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-row-style-change-triggers-layout-inline.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-row-style-change-triggers-layout-inline-ref.html">
+<meta name="assert" content="Flex items react to change in their flexbox's margin-trim value">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ flex-wrap: wrap;
+ border: 1px solid black;
+}
+.initial-margin-trim {
+ margin-trim: inline;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+}
+</style>
+</head>
+<body>
+ <flexbox class="initial-margin-trim" id="to-no-margin-trim">
+ <item></item>
+ </flexbox>
+ <flexbox id="to-margin-trim">
+ <item></item>
+ </flexbox>
+</body>
+<script>
+document.body.offsetHeight;
+document.getElementById("to-no-margin-trim").style["margin-trim"] = "none";
+document.getElementById("to-margin-trim").style["margin-trim"] = "inline";
+</script>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins-ref.html
new file mode 100644
index 0000000000..aebc1045d1
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-trim-all-margins</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<meta name="assert" content="specifying all margin edges should trim all of them correctly for the appropriate items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ gap: 20px;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins.html b/testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins.html
new file mode 100644
index 0000000000..1c2eda8aa0
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/flex-trim-all-margins.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: flex-trim-all-margins</title>
+<link rel="author" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex">
+<link rel="match" href="flex-trim-all-margins-ref.html">
+<meta name="assert" content="specifying all margin edges should trim all of them correctly for the appropriate items">
+<style>
+flexbox {
+ display: flex;
+ width: min-content;
+ margin-trim: block-start block-end inline-start inline-end;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline: 10px;
+ margin-block: 10px;
+}
+</style>
+</head>
+<body>
+<flexbox>
+<item></item>
+<item></item>
+<item></item>
+</flexbox>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-block-end-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-end-ref.html
new file mode 100644
index 0000000000..0ada645147
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-end-ref.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-block-end</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="block-end should trim block-end margins of items on last row">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item style="grid-row: span 2; height: auto;"></item>
+<item style="margin-block-end: 10px;"></item>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-block-end.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-end.html
new file mode 100644
index 0000000000..ffbc374756
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-end.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-block-end</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<link rel="match" href="grid-block-end-ref.html">
+<meta name="assert" content="block-end should trim block-end margins of items on last row">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+ margin-trim: block-end;
+}
+
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-end: 10px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item style="grid-row: span 2; height: auto;"></item>
+<item></item>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-block-start-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-start-ref.html
new file mode 100644
index 0000000000..486b64c74a
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-start-ref.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-block-start</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="block-start should trim block-start margins of items on first row">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.block-start-margin {
+ margin-block-start: 10px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item></item>
+<item></item>
+<item class="block-start-margin"></item>
+<item class="block-start-margin"></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-block-start.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-start.html
new file mode 100644
index 0000000000..21d5447253
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-block-start.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-block-start</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<link rel="match" href="grid-block-start-ref.html">
+<meta name="assert" content="block-start should trim block-start margins of items on first row">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+ margin-trim: block-start;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-block-start: 10px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-block.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-block.html
new file mode 100644
index 0000000000..6a4c3bbc94
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-block.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-block</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="block should trim block-start margin of items on first row and block-end margins of items on last row">
+<style>
+grid {
+ display: inline-grid;
+ grid-template-columns: auto auto;
+ margin-trim: block;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.block-start-margin {
+ margin-block-start: 10px;
+}
+.block-end-margin {
+ margin-block-end: 20px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<grid>
+<item class="block-start-margin"></item>
+<item class="block-start-margin"></item>
+<item class="block-end-margin"></item>
+<item class="block-end-margin"></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end-ref.html
new file mode 100644
index 0000000000..e51a97faf8
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end-ref.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-inline-end</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="inline-end should trim inline-end margins of items on last column">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+ margin-trim: inline-end;
+}
+
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item style="grid-column: span 2; width: auto;"></item>
+<item style="margin-inline-end: 10px;"></item>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end.html
new file mode 100644
index 0000000000..3754a9b50a
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-end.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-inline-end</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<link rel="match" href="grid-inline-end-ref.html">
+<meta name="assert" content="inline-end should trim inline-end margins of items on last column">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+ margin-trim: inline-end;
+}
+
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-end: 10px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item style="grid-column: span 2; width: auto;"></item>
+<item></item>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start-ref.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start-ref.html
new file mode 100644
index 0000000000..c35b1f5fe6
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start-ref.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-inline-start</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<meta name="assert" content="inline-start should trim inline-start margins of items on first column">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+ margin-trim: inline-start;
+}
+
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+.inline-start-margin {
+ margin-inline-start: 10px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item></item>
+<item class="inline-start-margin"></item>
+<item></item>
+<item class="inline-start-margin"></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start.html
new file mode 100644
index 0000000000..e0f4c6d454
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline-start.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-inline-start</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<link rel="match" href="grid-inline-start-ref.html">
+<meta name="assert" content="inline-start should trim inline-start margins of items on first column">
+<style>
+grid {
+ display: inline-grid;
+ border: 1px solid black;
+ grid-template-columns: auto auto;
+ margin-trim: inline-start;
+}
+
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+ margin-inline-start: 10px;
+}
+</style>
+</head>
+<body>
+<grid>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-inline.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline.html
new file mode 100644
index 0000000000..1ac228296a
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-inline.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-inline</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="inline should trim inline-start margin of items on first column and inline-end margins of items on last column">
+<style>
+grid {
+ display: inline-grid;
+ grid-template-columns: auto auto;
+ margin-trim: inline;
+}
+item {
+ display: block;
+ background-color: green;
+ width: 50px;
+ height: 50px;
+}
+item:nth-child(odd) {
+ margin-inline-start: 10px;
+}
+item:nth-child(even) {
+ margin-inline-end: 20px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<grid>
+<item></item>
+<item></item>
+<item></item>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/margin-trim/grid-trim-ignores-collapsed-tracks.html b/testing/web-platform/tests/css/css-box/margin-trim/grid-trim-ignores-collapsed-tracks.html
new file mode 100644
index 0000000000..15768ea7aa
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/margin-trim/grid-trim-ignores-collapsed-tracks.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>margin-trim: grid-trim-ignores-collapsed-tracks</title>
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-grid">
+<link rel="match" href="/css/reference/ref-filled-green-100px-square-only.html">
+<meta name="assert" content="should ignore collapsed margins when determining if an edge should be trimmed">
+<style>
+grid {
+ display: inline-grid;
+ grid-template-rows: repeat(auto-fit, 250px);
+ grid-template-columns: repeat(auto-fit, 250px);
+ margin-trim: block-start inline-start;
+}
+item {
+ display: block;
+ background-color: green;
+ grid-column: 2;
+ grid-row: 2;
+ margin-inline-start: 30px;
+ margin-block-start: 50px;
+ width: 100px;
+ height: 100px;
+}
+</style>
+</head>
+<body>
+<p>Test passes if there is a filled green square.</p>
+<grid>
+<item></item>
+</grid>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/clear-computed.html b/testing/web-platform/tests/css/css-box/parsing/clear-computed.html
new file mode 100644
index 0000000000..9571cb7e40
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/clear-computed.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: getComputedStyle().clear</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-clear">
+<link rel="help" href="https://drafts.csswg.org/css-logical/#float-clear">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/computed-testcommon.js"></script>
+</head>
+<body>
+<div id="target"></div>
+<script>
+test_computed_value("clear", "none");
+test_computed_value("clear", "left");
+test_computed_value("clear", "right");
+test_computed_value("clear", "both");
+
+test_computed_value("clear", "inline-start");
+test_computed_value("clear", "inline-end");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/clear-invalid.html b/testing/web-platform/tests/css/css-box/parsing/clear-invalid.html
new file mode 100644
index 0000000000..38d1821bc8
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/clear-invalid.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing clear with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-clear">
+<meta name="assert" content="clear supports only the grammar 'none | left | right | both'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("clear", "auto");
+test_invalid_value("clear", "left right");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/clear-valid.html b/testing/web-platform/tests/css/css-box/parsing/clear-valid.html
new file mode 100644
index 0000000000..fc1947f71d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/clear-valid.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing clear with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-clear">
+<link rel="help" href="https://drafts.csswg.org/css-logical/#float-clear">
+<meta name="assert" content="clear supports the full grammar 'none | left | right | both'.">
+<meta name="assert" content="clear also supports inline-start and inline-end.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("clear", "none");
+test_valid_value("clear", "left");
+test_valid_value("clear", "right");
+test_valid_value("clear", "both");
+
+test_valid_value("clear", "inline-start");
+test_valid_value("clear", "inline-end");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/float-computed.html b/testing/web-platform/tests/css/css-box/parsing/float-computed.html
new file mode 100644
index 0000000000..9d680e16c6
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/float-computed.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: getComputedStyle().float</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-float">
+<link rel="help" href="https://drafts.csswg.org/css-logical/#float-clear">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/computed-testcommon.js"></script>
+</head>
+<body>
+<div id="target"></div>
+<script>
+test_computed_value("float", "none");
+test_computed_value("float", "left");
+test_computed_value("float", "right");
+
+test_computed_value("float", "inline-start");
+test_computed_value("float", "inline-end");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/float-invalid.html b/testing/web-platform/tests/css/css-box/parsing/float-invalid.html
new file mode 100644
index 0000000000..c11f4e2e66
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/float-invalid.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing float with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-float">
+<meta name="assert" content="float supports only the grammar 'left | right | top | bottom | start | end | none | <page-floats>'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("float", "auto");
+test_invalid_value("float", "right bottom");
+test_invalid_value("float", "top, left");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/float-valid.html b/testing/web-platform/tests/css/css-box/parsing/float-valid.html
new file mode 100644
index 0000000000..32cf7edefd
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/float-valid.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing float with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-float">
+<link rel="help" href="https://drafts.csswg.org/css-logical/#float-clear">
+<meta name="assert" content="float supports the full grammar 'left | right | top | bottom | start | end | none | <page-floats>'.">
+<meta name="assert" content="float supports 'inline-start | inline-end'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("float", "left");
+test_valid_value("float", "right");
+test_valid_value("float", "none");
+
+test_valid_value("float", "inline-start");
+test_valid_value("float", "inline-end");
+
+// The following are not yet supported by browsers:
+// test_valid_value("float", "top");
+// test_valid_value("float", "bottom");
+// test_valid_value("float", "start"); // not permitted in https://drafts.csswg.org/css-page-floats/#float-property
+// test_valid_value("float", "end"); // not permitted in https://drafts.csswg.org/css-page-floats/#float-property
+
+// Page floats are now defined in
+// https://drafts.csswg.org/css-page-floats/#float-property
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/height-invalid.html b/testing/web-platform/tests/css/css-box/parsing/height-invalid.html
new file mode 100644
index 0000000000..dcd4d1afbe
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/height-invalid.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing height with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-height">
+<meta name="assert" content="height supports only the grammar '[<length> | <percentage>] | available | min-content | max-content | fit-content | complex | auto'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("height", "none");
+
+test_invalid_value("height", "min-content available");
+test_invalid_value("height", "max-content 10px");
+test_invalid_value("height", "20% available");
+
+test_invalid_value("height", "-10px");
+test_invalid_value("height", "-20%");
+test_invalid_value("height", "60");
+test_invalid_value("height", "10px 20%");
+
+test_invalid_value("height", "10px border-box");
+test_invalid_value("height", "content-box 20%");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/height-valid.html b/testing/web-platform/tests/css/css-box/parsing/height-valid.html
new file mode 100644
index 0000000000..7cc09a594e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/height-valid.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing height with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-height">
+<meta name="assert" content="height supports the full grammar '[<length> | <percentage>] | available | min-content | max-content | fit-content | complex | auto'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("height", "auto");
+
+test_valid_value("height", "10px");
+test_valid_value("height", "20%");
+test_valid_value("height", "calc(2em + 3ex)");
+
+test_valid_value("height", "min-content");
+test_valid_value("height", "max-content");
+test_valid_value("height", "fit-content");
+
+// The following are not yet supported by browsers:
+// test_valid_value("height", "available");
+// test_valid_value("height", "complex");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/margin-computed.html b/testing/web-platform/tests/css/css-box/parsing/margin-computed.html
new file mode 100644
index 0000000000..6c3b321c72
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/margin-computed.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: getComputedStyle().margin</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-margin">
+<meta name="assert" content="margin computed value has absolute lengths.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/computed-testcommon.js"></script>
+<style>
+ #parent {
+ width: 200px;
+ }
+ #target {
+ width: 0px;
+ font-size: 40px;
+ }
+</style>
+</head>
+<body>
+<div id="parent">
+ <div id="target"></div>
+</div>
+<script>
+const target = document.getElementById("target");
+
+test_computed_value("margin", "10px");
+test_computed_value("margin", "10px 20px 30px 40px");
+test_computed_value("margin", "calc(0.5em + 10px)", "30px");
+test_computed_value("margin", "30%", "60px");
+
+// Since what should the margin be in presence of other margins is a bit
+// unclear (https://github.com/w3c/csswg-drafts/issues/2328), reset the margin
+// before testing.
+target.style.margin = "0";
+test_computed_value("margin-top", "10px");
+target.style.margin = "0";
+test_computed_value("margin-right", "20px");
+target.style.margin = "0";
+test_computed_value("margin-bottom", "30px");
+target.style.margin = "0";
+test_computed_value("margin-left", "40px");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/margin-invalid.html b/testing/web-platform/tests/css/css-box/parsing/margin-invalid.html
new file mode 100644
index 0000000000..7700917093
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/margin-invalid.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing margin with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-margin">
+<meta name="assert" content="margin supports only the grammar '[ <length> | <percentage> | auto]{1,4}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("margin", "available");
+test_invalid_value("margin", "10px border-box");
+test_invalid_value("margin", "1% 2% 3% 4% 5%");
+
+test_invalid_value("margin-top", "calc(2em + 3ex) auto");
+test_invalid_value("margin-right", "auto calc(2em + 3ex) 20%");
+test_invalid_value("margin-bottom", "10px 20% calc(2em + 3ex) auto");
+test_invalid_value("margin-bottom-left", "none");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/margin-shorthand.html b/testing/web-platform/tests/css/css-box/parsing/margin-shorthand.html
new file mode 100644
index 0000000000..293927983e
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/margin-shorthand.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: margin sets longhands</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-margin">
+<meta name="assert" content="margin supports the full grammar '<length-percentage>{1,4}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/shorthand-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_shorthand_value('margin', '1px 2px 3px 4px', {
+ 'margin-top': '1px',
+ 'margin-right': '2px',
+ 'margin-bottom': '3px',
+ 'margin-left': '4px'
+});
+
+test_shorthand_value('margin', '1px 2px 3px', {
+ 'margin-top': '1px',
+ 'margin-right': '2px',
+ 'margin-bottom': '3px',
+ 'margin-left': '2px'
+});
+
+test_shorthand_value('margin', '1px 2px', {
+ 'margin-top': '1px',
+ 'margin-right': '2px',
+ 'margin-bottom': '1px',
+ 'margin-left': '2px'
+});
+
+test_shorthand_value('margin', '1px', {
+ 'margin-top': '1px',
+ 'margin-right': '1px',
+ 'margin-bottom': '1px',
+ 'margin-left': '1px'
+});
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/margin-trim-computed.html b/testing/web-platform/tests/css/css-box/parsing/margin-trim-computed.html
new file mode 100644
index 0000000000..ad2d17f2ef
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/margin-trim-computed.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS margin-trim computed style</title>
+<link rel="help" href="https://www.w3.org/TR/css-box-4/#margin-trim">
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<meta name="assert" content="Test the computed values for margin-trim">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/computed-testcommon.js"></script>
+</head>
+<body>
+<div id="target"></div>
+<script>
+test_computed_value("margin-trim", "none");
+test_computed_value("margin-trim", "block");
+test_computed_value("margin-trim", "inline");
+test_computed_value("margin-trim", "block-start block-end", "block");
+test_computed_value("margin-trim", "inline-start inline-end", "inline");
+test_computed_value("margin-trim", "block-start");
+test_computed_value("margin-trim", "block-end");
+test_computed_value("margin-trim", "inline-start");
+test_computed_value("margin-trim", "inline-end");
+test_computed_value("margin-trim", "block-start inline-start");
+test_computed_value("margin-trim", "inline-start block-start", "block-start inline-start");
+test_computed_value("margin-trim", "inline-end block-start", "block-start inline-end");
+test_computed_value("margin-trim", "inline-end block-end", "block-end inline-end");
+test_computed_value("margin-trim", "block-start block-end inline-start", "block-start inline-start block-end");
+test_computed_value("margin-trim", "inline-start block-start inline-end block-end", "block-start inline-start block-end inline-end");
+test_computed_value("margin-trim", "inline-start inline-end block-start", "block-start inline-start inline-end");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/margin-trim.html b/testing/web-platform/tests/css/css-box/parsing/margin-trim.html
new file mode 100644
index 0000000000..0d92f80b9b
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/margin-trim.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS margin-trim: property parsing</title>
+<link rel="help" href="https://www.w3.org/TR/css-box-4/#margin-trim">
+<link rel="author" title="Sammy Gill" href="mailto:sammy.gill@apple.com">
+<meta name="assert" content="Test parsing for the margin-trim property">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+// Individual values should get set
+test_valid_value("margin-trim", "none");
+test_valid_value("margin-trim", "block");
+test_valid_value("margin-trim", "inline");
+test_valid_value("margin-trim", "block-start");
+test_valid_value("margin-trim", "block-end");
+test_valid_value("margin-trim", "inline-start");
+test_valid_value("margin-trim", "inline-end");
+
+// Serialize values into either block or inline
+test_valid_value("margin-trim", "block-start block-end", "block");
+test_valid_value("margin-trim", "inline-start inline-end", "inline");
+test_valid_value("margin-trim", "block-end block-start", "block");
+test_valid_value("margin-trim", "inline-end inline-start", "inline");
+test_valid_value("margin-trim", "inline-start block-start");
+
+test_valid_value("margin-trim", "inline-end block-start block-end");
+test_valid_value("margin-trim", "block-start inline-start block-end inline-end");
+test_valid_value("margin-trim", "inline-end block-end inline-start block-start");
+
+test_invalid_value("margin-trim", "block inline");
+test_invalid_value("margin-trim", "block block");
+test_invalid_value("margin-trim", "inline inline");
+test_invalid_value("margin-trim", "block inline-start inline-end");
+test_invalid_value("margin-trim", "block block-start block-end");
+test_invalid_value("margin-trim", "block-start block-end block");
+test_invalid_value("margin-trim", "block 10px");
+test_invalid_value("margin-trim", "auto");
+test_invalid_value("margin-trim", "left");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/margin-valid.html b/testing/web-platform/tests/css/css-box/parsing/margin-valid.html
new file mode 100644
index 0000000000..154aa2de7c
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/margin-valid.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing margin with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-margin">
+<meta name="assert" content="margin supports the full grammar '[ <length> | <percentage> | auto]{1,4}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("margin", "10px");
+test_valid_value("margin", "20%");
+test_valid_value("margin", "calc(2em + 3ex)");
+test_valid_value("margin", "auto");
+test_valid_value("margin", "-10px");
+test_valid_value("margin", "-20%");
+
+test_valid_value("margin", "calc(2em + 3ex) auto");
+test_valid_value("margin", "auto calc(2em + 3ex) 20%");
+test_valid_value("margin", "10px 20% calc(2em + 3ex) auto");
+
+test_valid_value("margin-top", "10px");
+test_valid_value("margin-right", "20%");
+test_valid_value("margin-bottom", "calc(2em + 3ex)");
+test_valid_value("margin-left", "auto");
+test_valid_value("margin-top", "-10px");
+test_valid_value("margin-right", "-20%");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/max-height-invalid.html b/testing/web-platform/tests/css/css-box/parsing/max-height-invalid.html
new file mode 100644
index 0000000000..aeb6e64808
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/max-height-invalid.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing max-height with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-max-height">
+<meta name="assert" content="max-height supports only the grammar '[ [<length> | <percentage>] && [border-box | content-box]? ] | available | min-content | max-content | fit-content | none'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("max-height", "complex");
+test_invalid_value("max-height", "auto");
+test_invalid_value("max-height", "none available");
+test_invalid_value("max-height", "max-content 10px");
+test_invalid_value("max-height", "20% available");
+
+test_invalid_value("max-height", "-10px");
+test_invalid_value("max-height", "-20%");
+test_invalid_value("max-height", "60");
+test_invalid_value("max-height", "10px 20%");
+test_invalid_value("max-height", "content-box border-box");
+test_invalid_value("max-height", "10px border-box 20%");
+test_invalid_value("max-height", "content-box 20% border-box");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/max-height-valid.html b/testing/web-platform/tests/css/css-box/parsing/max-height-valid.html
new file mode 100644
index 0000000000..04880c4903
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/max-height-valid.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing max-height with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-max-height">
+<meta name="assert" content="max-height supports the full grammar '[ [<length> | <percentage>] && [border-box | content-box]? ] | available | min-content | max-content | fit-content | none'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("max-height", "none");
+
+test_valid_value("max-height", "10px");
+test_valid_value("max-height", "20%");
+test_valid_value("max-height", "calc(2em + 3ex)");
+
+test_valid_value("max-height", "min-content");
+test_valid_value("max-height", "max-content");
+test_valid_value("max-height", "fit-content");
+
+// The following are not yet supported by browsers:
+// test_valid_value("max-height", "available");
+// test_valid_value("max-height", "10px border-box");
+// test_valid_value("max-height", "content-box 20%", "20% content-box");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/max-width-invalid.html b/testing/web-platform/tests/css/css-box/parsing/max-width-invalid.html
new file mode 100644
index 0000000000..03db7e2657
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/max-width-invalid.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing max-width with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-max-width">
+<meta name="assert" content="max-width supports only the grammar '[ [<length> | <percentage>] && [border-box | content-box]? ] | available | min-content | max-content | fit-content | none'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("max-width", "complex");
+test_invalid_value("max-width", "auto");
+test_invalid_value("max-width", "none available");
+test_invalid_value("max-width", "max-content 10px");
+test_invalid_value("max-width", "20% available");
+
+test_invalid_value("max-width", "-10px");
+test_invalid_value("max-width", "-20%");
+test_invalid_value("max-width", "60");
+test_invalid_value("max-width", "10px 20%");
+test_invalid_value("max-width", "content-box border-box");
+test_invalid_value("max-width", "10px border-box 20%");
+test_invalid_value("max-width", "content-box 20% border-box");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/max-width-valid.html b/testing/web-platform/tests/css/css-box/parsing/max-width-valid.html
new file mode 100644
index 0000000000..1e08a820d9
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/max-width-valid.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing max-width with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-max-width">
+<meta name="assert" content="max-width supports the full grammar '[ [<length> | <percentage>] && [border-box | content-box]? ] | available | min-content | max-content | fit-content | none'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("max-width", "none");
+
+test_valid_value("max-width", "10px");
+test_valid_value("max-width", "20%");
+test_valid_value("max-width", "calc(2em + 3ex)");
+
+test_valid_value("max-width", "min-content");
+test_valid_value("max-width", "max-content");
+test_valid_value("max-width", "fit-content");
+
+// The following are not yet supported by browsers:
+// test_valid_value("max-width", "available");
+// test_valid_value("max-width", "10px border-box");
+// test_valid_value("max-width", "content-box 20%", "20% content-box");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/overflow-invalid.html b/testing/web-platform/tests/css/css-box/parsing/overflow-invalid.html
new file mode 100644
index 0000000000..4747764fb6
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/overflow-invalid.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing overflow with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-overflow">
+<meta name="assert" content="overflow supports only the grammar '[ visible | hidden | scroll | auto | no-display | no-content ]{1,2}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("overflow", "none");
+test_invalid_value("overflow", "visible hidden scroll");
+test_invalid_value("overflow", "no-display, no-content");
+
+test_invalid_value("overflow-x", "none");
+test_invalid_value("overflow-y", "visible hidden");
+test_invalid_value("overflow-y", "no-display, no-content");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/overflow-valid.html b/testing/web-platform/tests/css/css-box/parsing/overflow-valid.html
new file mode 100644
index 0000000000..1bfeec2364
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/overflow-valid.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing overflow with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-overflow">
+<meta name="assert" content="overflow supports the full grammar '[ visible | hidden | scroll | auto | no-display | no-content ]{1,2}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("overflow", "visible");
+test_valid_value("overflow", "hidden");
+test_valid_value("overflow", "scroll");
+test_valid_value("overflow", "auto");
+
+test_valid_value("overflow-x", "visible");
+test_valid_value("overflow-x", "hidden");
+test_valid_value("overflow-x", "scroll");
+test_valid_value("overflow-y", "auto");
+
+// The following are not yet supported by browsers:
+// test_valid_value("overflow", "no-display");
+// test_valid_value("overflow", "no-content");
+// test_valid_value("overflow", "visible hidden");
+// test_valid_value("overflow", "auto scroll");
+// test_valid_value("overflow", "no-display no-content");
+// test_valid_value("overflow-y", "no-display");
+// test_valid_value("overflow-y", "no-content");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/padding-computed.html b/testing/web-platform/tests/css/css-box/parsing/padding-computed.html
new file mode 100644
index 0000000000..f1186c4530
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/padding-computed.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: getComputedStyle().padding</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-padding">
+<link rel="help" href="https://drafts.csswg.org/cssom/#resolved-values">
+<meta name="assert" content="padding resolved value is an absolute length.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/computed-testcommon.js"></script>
+<style>
+ #container {
+ will-change: transform; /* containing block for #target */
+ width: 200px;
+ }
+ #parent {
+ width: 0px;
+ }
+ #target {
+ position: absolute;
+ font-size: 40px;
+ }
+</style>
+</head>
+<body>
+<div id="container">
+ <div id="parent">
+ <div id="target"></div>
+ </div>
+</div>
+<script>
+test_computed_value("padding", "10px");
+test_computed_value("padding", "10px 20px 30px 40px");
+
+test_computed_value("padding-top", "10px");
+test_computed_value("padding-right", "20px");
+test_computed_value("padding-bottom", "30px");
+test_computed_value("padding-left", "40px");
+
+test_computed_value("padding", "20%", "40px");
+test_computed_value("padding", "10px 20% 30% 40px", "10px 40px 60px");
+test_computed_value("padding-right", "20%", "40px");
+
+test_computed_value('padding-top', 'calc(10% - 40px)', '0px');
+test_computed_value('padding-right', 'calc(10% + 40px)', '60px');
+test_computed_value('padding-bottom', 'calc(10px - 0.5em)', '0px');
+test_computed_value('padding-left', 'calc(10px + 0.5em)', '30px');
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/padding-invalid.html b/testing/web-platform/tests/css/css-box/parsing/padding-invalid.html
new file mode 100644
index 0000000000..3e3a560c2f
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/padding-invalid.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing padding with invalid values</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-padding">
+<meta name="assert" content="padding supports only the grammar '<length-percentage>{1,4}'.">
+<meta name="assert" content="Negative values are invalid.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("padding", "auto");
+test_invalid_value("padding", "available");
+test_invalid_value("padding", "10px border-box");
+test_invalid_value("padding", "calc(2em + 3ex) auto");
+test_invalid_value("padding", "10px 20px 30px 40px 50px");
+
+test_invalid_value("padding-top", "auto");
+test_invalid_value("padding-bottom", "10px 20px calc(2em + 3ex) auto");
+test_invalid_value("padding-bottom-left", "10px 20px");
+
+test_invalid_value("padding-top", "-10px");
+test_invalid_value("padding-right", "-20%");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/padding-shorthand.html b/testing/web-platform/tests/css/css-box/parsing/padding-shorthand.html
new file mode 100644
index 0000000000..dc0139dc47
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/padding-shorthand.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: padding sets longhands</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-padding">
+<meta name="assert" content="padding supports the full grammar '<length-percentage>{1,4}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/shorthand-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_shorthand_value('padding', '1px 2px 3px 4px', {
+ 'padding-top': '1px',
+ 'padding-right': '2px',
+ 'padding-bottom': '3px',
+ 'padding-left': '4px'
+});
+
+test_shorthand_value('padding', '1px 2px 3px', {
+ 'padding-top': '1px',
+ 'padding-right': '2px',
+ 'padding-bottom': '3px',
+ 'padding-left': '2px'
+});
+
+test_shorthand_value('padding', '1px 2px', {
+ 'padding-top': '1px',
+ 'padding-right': '2px',
+ 'padding-bottom': '1px',
+ 'padding-left': '2px'
+});
+
+test_shorthand_value('padding', '1px', {
+ 'padding-top': '1px',
+ 'padding-right': '1px',
+ 'padding-bottom': '1px',
+ 'padding-left': '1px'
+});
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/padding-valid.html b/testing/web-platform/tests/css/css-box/parsing/padding-valid.html
new file mode 100644
index 0000000000..36d158b4d0
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/padding-valid.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing padding with valid values</title>
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-padding">
+<meta name="assert" content="padding supports the full grammar '<length-percentage>{1,4}'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("padding", "10px");
+test_valid_value("padding", "10px 20px 30px 40px");
+test_valid_value("padding", "calc(2em + 3ex)");
+
+test_valid_value("padding-top", "10px");
+test_valid_value("padding-right", "20px");
+test_valid_value("padding-bottom", "30px");
+test_valid_value("padding-left", "40px");
+
+test_valid_value("padding", "20%");
+test_valid_value("padding", "10px 20% 30% 40px");
+test_valid_value("padding-right", "20%");
+
+// https://drafts.csswg.org/css-values-4/#sort-a-calculations-children
+test_valid_value("padding-right", "calc(2em + 3%)", "calc(3% + 2em)");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/visibility-computed.html b/testing/web-platform/tests/css/css-box/parsing/visibility-computed.html
new file mode 100644
index 0000000000..f6d4c3f8e5
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/visibility-computed.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: getComputedStyle().visibility</title>
+<link rel="help" href="https://www.w3.org/TR/CSS2/visufx.html#visibility">
+<meta name="assert" content="visibility computed value is as specified.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/computed-testcommon.js"></script>
+</head>
+<body>
+<div id="target"></div>
+<script>
+test_computed_value("visibility", "visible");
+test_computed_value("visibility", "hidden");
+test_computed_value("visibility", "collapse");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/visibility-invalid.html b/testing/web-platform/tests/css/css-box/parsing/visibility-invalid.html
new file mode 100644
index 0000000000..73e611b2b8
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/visibility-invalid.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing visibility with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-visibility">
+<meta name="assert" content="visibility supports only the grammar 'visible | hidden | collapse'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("visibility", "auto");
+test_invalid_value("visibility", "hidden collapse");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/visibility-valid.html b/testing/web-platform/tests/css/css-box/parsing/visibility-valid.html
new file mode 100644
index 0000000000..2ab2f49660
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/visibility-valid.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing visibility with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-visibility">
+<meta name="assert" content="visibility supports the full grammar 'visible | hidden | collapse'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("visibility", "visible");
+test_valid_value("visibility", "hidden");
+test_valid_value("visibility", "collapse");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/width-invalid.html b/testing/web-platform/tests/css/css-box/parsing/width-invalid.html
new file mode 100644
index 0000000000..5a0145fe1d
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/width-invalid.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing width with invalid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-width">
+<meta name="assert" content="width supports only the grammar '[<length> | <percentage>] | available | min-content | max-content | fit-content | auto'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_invalid_value("width", "complex");
+test_invalid_value("width", "none");
+
+test_invalid_value("width", "min-content available");
+test_invalid_value("width", "max-content 10px");
+test_invalid_value("width", "20% available");
+
+test_invalid_value("width", "-10px");
+test_invalid_value("width", "-20%");
+test_invalid_value("width", "60");
+test_invalid_value("width", "10px 20%");
+
+test_invalid_value("width", "10px border-box");
+test_invalid_value("width", "content-box 20%");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/css/css-box/parsing/width-valid.html b/testing/web-platform/tests/css/css-box/parsing/width-valid.html
new file mode 100644
index 0000000000..93059bd2d3
--- /dev/null
+++ b/testing/web-platform/tests/css/css-box/parsing/width-valid.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>CSS basic box model: parsing width with valid values</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-box-3/#propdef-width">
+<meta name="assert" content="width supports the full grammar '[<length> | <percentage>] | available | min-content | max-content | fit-content | auto'.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/css/support/parsing-testcommon.js"></script>
+</head>
+<body>
+<script>
+test_valid_value("width", "auto");
+
+test_valid_value("width", "10px");
+test_valid_value("width", "20%");
+test_valid_value("width", "calc(2em + 3ex)");
+
+test_valid_value("width", "min-content");
+test_valid_value("width", "max-content");
+test_valid_value("width", "fit-content");
+
+// The following is not yet supported by browsers:
+// test_valid_value("width", "available");
+</script>
+</body>
+</html>