diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/css/css-contain/container-queries/font-relative-units-dynamic.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-contain/container-queries/font-relative-units-dynamic.html')
-rw-r--r-- | testing/web-platform/tests/css/css-contain/container-queries/font-relative-units-dynamic.html | 280 |
1 files changed, 280 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-contain/container-queries/font-relative-units-dynamic.html b/testing/web-platform/tests/css/css-contain/container-queries/font-relative-units-dynamic.html new file mode 100644 index 0000000000..63a07c61db --- /dev/null +++ b/testing/web-platform/tests/css/css-contain/container-queries/font-relative-units-dynamic.html @@ -0,0 +1,280 @@ +<!doctype html> +<title>CSS Container Queries Test: font-relative units - dynamic</title> +<link rel="help" href="https://drafts.csswg.org/css-contain-3/#size-container"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="support/cq-testcommon.js"></script> +<script> + +setup(() => assert_implements_container_queries()); + +// Inflate a <template> subtree into #main, run the test function, +// then clean up. +function test_template(template_element, test_fn, description) { + test((t) => { + assert_equals(template_element.tagName, "TEMPLATE"); + t.add_cleanup(() => main.replaceChildren()); + main.append(template_element.content.cloneNode(true)); + test_fn(t); + }, description); +} + +const green = "rgb(0, 128, 0)"; +const red = "rgb(255, 0, 0)"; + +</script> + +<style> + main { + color: red; + } + #container { + container-type: inline-size; + width: 100px; + } + #container > div { + font-size: 16px; + } +</style> + +<main id=main> +</main> + +<template> + <style> + main { font-size: 10px; } + main.larger { font-size: 20px; } + @container (width: 5em) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => main.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + main.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'em units respond to changes'); +</script> + +<template> + <style> + :root { font-size: 10px; } + :root.larger { font-size: 50px; } + @container (width: 2rem) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => document.documentElement.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + document.documentElement.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'rem units respond to changes'); +</script> + +<template> + <style> + main { font-size: 10px; } + main.larger { font-size: 20px; } + @container (width <= 15ex) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => main.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + main.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'ex units respond to changes'); +</script> + +<template> + <style> + :root { font-size: 10px; } + :root.larger { font-size: 20px; } + @container (width <= 12rex) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => document.documentElement.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + document.documentElement.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'rex units respond to changes'); +</script> + +<template> + <style> + main { font-size: 10px; } + main.larger { font-size: 20px; } + @container (width <= 15ch) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => main.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + main.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'ch units respond to changes'); +</script> + +<template> + <style> + :root { font-size: 10px; } + :root.larger { font-size: 20px; } + @container (width <= 15rch) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => document.documentElement.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + document.documentElement.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'rch units respond to changes'); +</script> + +<template> + <style> + main { + font-size: 10px; + line-height: 5; + } + main.larger { font-size: 20px; } + @container (width <= 1lh) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => main.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + main.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'lh units respond to changes'); +</script> + +<template> + <style> + :root { + font-size: 10px; + line-height: 5; + } + :root.larger { + font-size: 20px; + } + @container (width <= 1rlh) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => document.documentElement.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + document.documentElement.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'rlh units respond to changes'); +</script> + +<template> + <style> + main { font-size: 10px; } + main.larger { font-size: 20px; } + @container (width <= 8ic) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => main.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + main.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'ic units respond to changes'); +</script> + + +<template> + <style> + :root { font-size: 10px; } + :root.larger { font-size: 20px; } + @container (width <= 8ric) { + #test { color: green } + } + </style> + <div id="container"> + <div> + <div id="test"></div> + </div> + </div> +</template> +<script> +test_template(document.currentScript.previousElementSibling, (t) => { + t.add_cleanup(() => document.documentElement.classList.remove("larger")); + assert_equals(getComputedStyle(main.querySelector("#test")).color, red); + document.documentElement.classList.add("larger"); + assert_equals(getComputedStyle(main.querySelector("#test")).color, green); +}, 'ric units respond to changes'); +</script> |