Skip to content

Truly independent web browser

Tests/LibWeb: Test computed values that typed group fields do not tell

Andreas Kling4b3024465bf5
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/computed-values-of-typed-group-fields.txt b/Tests/LibWeb/Text/expected/css/style-engine/computed-values-of-typed-group-fields.txt
new file mode 100644
index 00000000000..f18596306bc
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/computed-values-of-typed-group-fields.txt
@@ -0,0 +1,128 @@
+odd width: 0px
+odd min-width: min-content
+odd max-width: none
+odd height: 528px
+odd min-height: 0px
+odd max-height: none
+odd top: 13px
+odd right: 775px
+odd bottom: -750px
+odd left: 7px
+odd margin-top: 784px
+odd margin-right: 0px
+odd margin-bottom: 24px
+odd margin-left: 2px
+odd padding-top: 1px
+odd padding-right: 16px
+odd padding-bottom: 0px
+odd padding-left: 0px
+child width: 0px
+child min-width: min-content
+child max-width: none
+child height: 487.09375px
+child min-height: 3px
+child max-height: none
+child top: 10px
+child right: 6.6875px
+child bottom: 26.4375px
+child left: 7px
+child margin-top: 4px
+child margin-right: 0px
+child margin-bottom: 0.46875px
+child margin-left: 2px
+child padding-top: 1px
+child padding-right: 0.3125px
+child padding-bottom: 0px
+child padding-left: 0px
+plain width: 784px
+plain min-width: auto
+plain max-width: none
+plain height: 0px
+plain min-height: auto
+plain max-height: none
+plain top: auto
+plain right: auto
+plain bottom: auto
+plain left: auto
+plain margin-top: 0px
+plain margin-right: 0px
+plain margin-bottom: 0px
+plain margin-left: 0px
+plain padding-top: 0px
+plain padding-right: 0px
+plain padding-bottom: 0px
+plain padding-left: 0px
+plain-child width: 784px
+plain-child min-width: auto
+plain-child max-width: none
+plain-child height: 0px
+plain-child min-height: auto
+plain-child max-height: none
+plain-child top: auto
+plain-child right: auto
+plain-child bottom: auto
+plain-child left: auto
+plain-child margin-top: 0px
+plain-child margin-right: 0px
+plain-child margin-bottom: 0px
+plain-child margin-left: 0px
+plain-child padding-top: 0px
+plain-child padding-right: 0px
+plain-child padding-bottom: 0px
+plain-child padding-left: 0px
+background background-color: rgb(18, 52, 86)
+background background-image: linear-gradient(rgb(255, 0, 0), rgb(0, 0, 255))
+background background-attachment: fixed
+background background-blend-mode: multiply
+background background-clip: content-box
+background background-origin: padding-box
+background background-position-x: 3px
+background background-position-y: 4px
+background background-repeat: no-repeat
+background background-size: 5px 6px
+background mask-image: url("#m")
+background mask-repeat: no-repeat
+background mask-size: 3px 4px
+background opacity: 0.5
+background filter: blur(1px)
+background clip: rect(1px, 2px, 3px, 4px)
+background box-shadow: rgb(255, 0, 0) 1px 2px 3px 0px
+background cx: 1px
+background cy: 0px
+background r: 2px
+restored width: 4px
+restored min-width: min-content
+restored max-width: none
+restored height: 542px
+restored min-height: 3px
+restored max-height: none
+restored top: 1px
+restored right: 771px
+restored bottom: 30px
+restored left: 7px
+restored margin-top: 2px
+restored margin-right: 0px
+restored margin-bottom: 24px
+restored margin-left: 2px
+restored padding-top: 1px
+restored padding-right: 16px
+restored padding-bottom: 0px
+restored padding-left: 0px
+restored width: 4px
+restored min-width: min-content
+restored max-width: none
+restored height: 528px
+restored min-height: 3px
+restored max-height: none
+restored top: 13px
+restored right: 771px
+restored bottom: -750px
+restored left: 7px
+restored margin-top: 784px
+restored margin-right: 0px
+restored margin-bottom: 24px
+restored margin-left: 2px
+restored padding-top: 1px
+restored padding-right: 16px
+restored padding-bottom: 0px
+restored padding-left: 0px
diff --git a/Tests/LibWeb/Text/input/css/style-engine/computed-values-of-typed-group-fields.html b/Tests/LibWeb/Text/input/css/style-engine/computed-values-of-typed-group-fields.html
new file mode 100644
index 00000000000..103fbb329b1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/computed-values-of-typed-group-fields.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<style>
+ #anchor {
+ anchor-name: --a;
+ }
+ .odd {
+ position: absolute;
+ position-anchor: --a;
+ width: fit-content(20px);
+ min-width: min-content;
+ max-width: calc-size(auto, size);
+ height: -webkit-fill-available;
+ min-height: anchor-size(height, 3px);
+ max-height: none;
+ top: anchor(top, 10px);
+ right: auto;
+ bottom: 5%;
+ left: 7px;
+ margin-top: anchor-size(width, 4px);
+ margin-right: auto;
+ margin-bottom: 3%;
+ margin-left: 2px;
+ padding-top: 1px;
+ padding-right: 2%;
+ }
+ .inheriting {
+ position: inherit;
+ position-anchor: inherit;
+ width: inherit;
+ min-width: inherit;
+ max-width: inherit;
+ height: inherit;
+ min-height: inherit;
+ max-height: inherit;
+ top: inherit;
+ right: inherit;
+ bottom: inherit;
+ left: inherit;
+ margin-top: inherit;
+ margin-right: inherit;
+ margin-bottom: inherit;
+ margin-left: inherit;
+ padding-top: inherit;
+ padding-right: inherit;
+ }
+ .background {
+ background: linear-gradient(red, blue) 3px 4px / 5px 6px no-repeat fixed padding-box content-box #123456;
+ background-blend-mode: multiply;
+ mask: url(#m) 1px 2px / 3px 4px no-repeat;
+ opacity: 0.5;
+ filter: blur(1px);
+ clip: rect(1px, 2px, 3px, 4px);
+ box-shadow: 1px 2px 3px red;
+ cx: 1px;
+ r: 2px;
+ }
+</style>
+<div id="anchor"></div>
+<div id="odd" class="odd"><div id="child" class="inheriting"></div></div>
+<div id="plain"><div id="plain-child" class="inheriting"></div></div>
+<div id="background" class="background"></div>
+<div id="restored" class="odd"></div>
+<script src="../../include.js"></script>
+<script>
+ const sizingAndSurround = [
+ "width", "min-width", "max-width", "height", "min-height", "max-height",
+ "top", "right", "bottom", "left",
+ "margin-top", "margin-right", "margin-bottom", "margin-left",
+ "padding-top", "padding-right", "padding-bottom", "padding-left",
+ ];
+ const handles = [
+ "background-color", "background-image", "background-attachment", "background-blend-mode", "background-clip",
+ "background-origin", "background-position-x", "background-position-y", "background-repeat", "background-size",
+ "mask-image", "mask-repeat", "mask-size", "opacity", "filter", "clip", "box-shadow", "cx", "cy", "r",
+ ];
+ function print(id, properties) {
+ const style = getComputedStyle(document.getElementById(id));
+ for (const property of properties)
+ println(`${id} ${property}: ${style.getPropertyValue(property)}`);
+ }
+ test(() => {
+ // The values an element reads back, and those a child inheriting them computes from them, whatever fields of
+ // its groups hold them.
+ print("odd", sizingAndSurround);
+ print("child", sizingAndSurround);
+ print("plain", sizingAndSurround);
+ print("plain-child", sizingAndSurround);
+ print("background", handles);
+ const restored = document.getElementById("restored");
+ restored.style.top = "1px";
+ restored.style.marginTop = "2px";
+ restored.style.minHeight = "3px";
+ restored.style.width = "4px";
+ print("restored", sizingAndSurround);
+ restored.style.removeProperty("top");
+ restored.style.removeProperty("margin-top");
+ print("restored", sizingAndSurround);
+ });
+</script>