Skip to content

Truly independent web browser

LibWeb: Test background layer lists against the element's own images

Andreas Kling61e74aeb7c82
diff --git a/Tests/LibWeb/Text/expected/css/style-engine/background-layer-lists-follow-own-images.txt b/Tests/LibWeb/Text/expected/css/style-engine/background-layer-lists-follow-own-images.txt
new file mode 100644
index 00000000000..0f3b58dd20a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/style-engine/background-layer-lists-follow-own-images.txt
@@ -0,0 +1,7 @@
+one-then-two 0 (one): attachment scroll, repeat repeat, size auto, origin padding-box, clip border-box, position 0% 0%
+one-then-two 1 (two): attachment scroll, repeat repeat, size auto, origin padding-box, clip border-box, position 0% 0%
+two-then-one 0 (two): attachment scroll, repeat repeat, size auto, origin padding-box, clip border-box, position 0% 0%
+two-then-one 1 (one): attachment scroll, repeat repeat, size auto, origin padding-box, clip border-box, position 0% 0%
+one: attachment scroll, repeat repeat, size auto, origin padding-box, clip border-box, position 0% 0%
+two: attachment scroll, repeat repeat, size auto, origin padding-box, clip border-box, position 0% 0%
+one again: attachment scroll, repeat repeat, size auto, origin padding-box, clip border-box, position 0% 0%
diff --git a/Tests/LibWeb/Text/input/css/style-engine/background-layer-lists-follow-own-images.html b/Tests/LibWeb/Text/input/css/style-engine/background-layer-lists-follow-own-images.html
new file mode 100644
index 00000000000..6fc77d2e4d4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/style-engine/background-layer-lists-follow-own-images.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<script src="../../include.js"></script>
+<style>
+ .one { background-image: linear-gradient(red, blue); }
+ .two { background-image: linear-gradient(red, blue), linear-gradient(green, yellow); }
+</style>
+<div id="one-then-two"><div class="one"></div><div class="two"></div></div>
+<div id="two-then-one"><div class="two"></div><div class="one"></div></div>
+<div id="changing" class="one"></div>
+<script>
+ function report(label, element) {
+ const style = getComputedStyle(element);
+ println(`${label}: attachment ${style.backgroundAttachment}, repeat ${style.backgroundRepeat}, size ${style.backgroundSize}, origin ${style.backgroundOrigin}, clip ${style.backgroundClip}, position ${style.backgroundPosition}`);
+ }
+
+ test(() => {
+ // Alike siblings whose rules give each another number of background layers, in either order.
+ for (const id of ["one-then-two", "two-then-one"]) {
+ for (const [index, child] of [...document.getElementById(id).children].entries())
+ report(`${id} ${index} (${child.className})`, child);
+ }
+
+ // An element whose number of layers changes after its first style.
+ const changing = document.getElementById("changing");
+ report("one", changing);
+ changing.className = "two";
+ report("two", changing);
+ changing.className = "one";
+ report("one again", changing);
+ });
+</script>