Skip to content

Truly independent web browser

LibWeb: Test color-mix() with currentcolor in getComputedStyle

Andreas Kling964905d4a39f
diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-color-mix-currentcolor.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-color-mix-currentcolor.txt
new file mode 100644
index 00000000000..56077c335dd
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-color-mix-currentcolor.txt
@@ -0,0 +1,20 @@
+color rgb(255, 0, 0)
+background-color color(srgb 0.5 0.5 0.5)
+border-top-color color(srgb 0 0 0 / 0.5)
+outline-color color(srgb 0.5 0.5 0.5)
+color rgb(0, 0, 255)
+background-color color(srgb 0.5 0.5 0.5)
+border-top-color color(srgb 0 0 0 / 0.5)
+outline-color color(srgb 0.5 0.5 0.5)
+color rgb(0, 128, 0)
+background-color color(srgb 0.5 0.5 0.5)
+border-top-color color(srgb 0 0 0 / 0.5)
+outline-color color(srgb 0.5 0.5 0.5)
+color color(srgb 0.5 0.5 0.5)
+background-color rgba(0, 0, 0, 0)
+border-top-color rgb(128, 128, 128)
+outline-color rgb(128, 128, 128)
+color rgb(128, 128, 128)
+background-color color(srgb 0.5 0.5 0.5)
+border-top-color color(srgb 0 0 0 / 0.5)
+outline-color color(srgb 0.5 0.5 0.5)
diff --git a/Tests/LibWeb/Text/input/css/getComputedStyle-color-mix-currentcolor.html b/Tests/LibWeb/Text/input/css/getComputedStyle-color-mix-currentcolor.html
new file mode 100644
index 00000000000..f6e5feae921
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/getComputedStyle-color-mix-currentcolor.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<style>
+ .mix {
+ background-color: color-mix(in srgb, currentcolor 50%, white);
+ border: 1px solid color-mix(in srgb, currentcolor, transparent);
+ outline: 1px solid color-mix(in srgb, color-mix(in srgb, currentcolor, black) 50%, white);
+ }
+ .mix-color {
+ color: color-mix(in srgb, currentcolor, white);
+ }
+</style>
+<div id="red" style="color: rgb(255, 0, 0)"><span class="mix"></span></div>
+<div id="blue" style="color: rgb(0, 0, 255)"><span class="mix"></span></div>
+<div id="own" class="mix" style="color: rgb(0, 128, 0)"></div>
+<div style="color: rgb(255, 0, 0)"><div id="mixColor" class="mix-color"><div class="mix"></div></div></div>
+<script>
+ test(() => {
+ for (const element of [red.firstChild, blue.firstChild, own, mixColor, mixColor.firstChild]) {
+ const style = getComputedStyle(element);
+ println(`color ${style.color}`);
+ println(`background-color ${style.backgroundColor}`);
+ println(`border-top-color ${style.borderTopColor}`);
+ println(`outline-color ${style.outlineColor}`);
+ }
+ });
+</script>