<!doctype html><metacharset="utf-8"><title>CSSOM: resolved value of min-width and min-height:auto should be 0 except in certain defined cases</title><linkrel="help"href="https://drafts.csswg.org/cssom/#resolved-value"><linkrel="help"href="https://drafts.csswg.org/css-sizing-3/#valdef-width-auto"><linkrel="help"href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio"><linkrel="help"href="https://github.com/w3c/csswg-drafts/issues/11716"><linkrel="author"title="Daniel Holbert"href="mailto:dholbert@mozilla.com"><linkrel="author"title="Mozilla"href="https://mozilla.org"><scriptsrc=/resources/testharness.js></script><scriptsrc=/resources/testharnessreport.js></script><!-- OVERVIEW: * Elements to be tested here must include an 'id'. * We use a "preservesAuto" attribute to tag the elements are expected to preserve "auto" in the resolved value of min-width and min-height. --><!-- The test content is in a scrollable div for cosmetic reasons, so that it can be inspected but also doesn't push the testharness output off the bottom of the screen: --><divstyle="overflow: scroll; width: 300px; height: 200px"><divid="block-box"></div><divid="inline-box"></div><!-- Elements with a nondefault aspect-ratio preserve 'auto': --><divid="block-with-valid-aspect-ratio"style="aspect-ratio: 1/1"preservesAuto></div><divid="block-with-degenerate-aspect-ratio"style="aspect-ratio: 0/1"preservesAuto></div><divid="block-with-two-part-valid-aspect-ratio"style="aspect-ratio: auto 1/1"preservesAuto></div><divid="block-with-two-part-degenerate-aspect-ratio"style="aspect-ratio: auto 0/1"preservesAuto></div><!-- Note: aspect-ratio doesn't apply to inline boxes, but we treat it as toggling getComputedStyle to return the true 'min-width:auto' value regardless. --><spanid="inline-with-valid-aspect-ratio"style="aspect-ratio: 1/1"preservesAuto></span><spanid="inline-with-degenerate-aspect-ratio"style="aspect-ratio: 0/1"preservesAuto></span><!-- flex and grid items should preserve 'auto': --><divstyle="display: flex"><divid="flex-item-row"preservesAuto></div></div><divstyle="display: flex; flex-direction: column;"><divid="flex-item-column"preservesAuto></div></div><divstyle="display: grid"><divid="grid-item"preservesAuto></div></div><!-- Per https://drafts.csswg.org/css-sizing/#valdef-width-auto the min-width/min-height:auto value "resolves to zero when no box is generated" (regardless of aspect-ratio & flex/grid-item special cases) --><divid="display-none"style="display: none"></div><divid="display-none-valid-aspect-ratio"style="display: none; aspect-ratio:2/1"></div><divstyle="display:none"><divid="display-none-subtree-valid-aspect-ratio"style="aspect-ratio:2/1"></div></div><divstyle="display: none"><divstyle="display: flex"><divid="display-none-subtree-flex-item"></div></div></div><divstyle="display: none"><divstyle="display: grid"><divid="display-none-subtree-grid-item"></div></div></div></div><script>for(consteofdocument.querySelectorAll("[id]")){test(function(){constcs=getComputedStyle(e);constdoesPreserveAuto=e.hasAttribute("preservesAuto");constexpectedVal=doesPreserveAuto?"auto":"0px";constexpectationMessage=doesPreserveAuto?"should round-trip through getComputedStyle":`should be converted to ${expectedVal} in getComputedStyle`;for(constpropof["min-width","min-height"]){assert_equals(cs[prop],expectedVal,`${e.id}: '${prop}:auto' ${expectationMessage} (as initial value)`);e.style.setProperty(prop,"auto");assert_equals(cs[prop],expectedVal,`${e.id}: '${prop}:auto' ${expectationMessage} (as specified value)`);e.style.removeProperty(prop);}},`Resolved value of min-width & min-height 'auto' keyword behaves as expected on element with id="${e.id}"`);}</script>