Skip to content

Commit

Permalink
Add a test for gradients dependent on the used color-scheme (#45463)
Browse files Browse the repository at this point in the history
Upstream the test added in WebKit/WebKit@5596316.
  • Loading branch information
pxlcoder committed Apr 2, 2024
1 parent 38c6d67 commit acf9d2c
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html>
<head>
<link rel="author" title="Aditya Keerthi" href="https://github.com/pxlcoder">
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#color-scheme-prop">
<link rel="help" href="https://www.w3.org/TR/css-color-4/#css-system-colors">
<link rel="help" href="https://www.w3.org/TR/css-color-5/#light-dark">
<link rel="help" href="https://www.w3.org/TR/css-color-5/#color-mix">
<title>Reference: Test changing used color-scheme updates gradient with color-scheme dependent color stops.</title>
<style>

.box {
color-scheme: dark;

width: 100px;
height: 100px;
}

#system-color {
background-image: linear-gradient(CanvasText, CanvasText);
}

#system-color-in-color-mix {
background-image: linear-gradient(color-mix(in lch, Canvas, pink), color-mix(in lch, Canvas, pink));
}

#light-dark {
background-image: linear-gradient(light-dark(red, green), light-dark(red, green));
}

#light-dark-in-color-mix {
background-image: linear-gradient(color-mix(in lch, light-dark(red, green), pink), color-mix(in lch, light-dark(red, green), pink));
}

</style>
</head>
<body>
<p>Test system color</p>
<div id="system-color" class="box"></div>
<p>Test system color in color-mix()</p>
<div id="system-color-in-color-mix" class="box"></div>
<p>Test light-dark()</p>
<div id="light-dark" class="box"></div>
<p>Test light-dark() in color-mix()</p>
<div id="light-dark-in-color-mix" class="box"></div>
</body>
</html>
61 changes: 61 additions & 0 deletions css/css-images/gradient/color-scheme-dependent-color-stops.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<link rel="author" title="Aditya Keerthi" href="https://github.com/pxlcoder">
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#color-scheme-prop">
<link rel="help" href="https://www.w3.org/TR/css-color-4/#css-system-colors">
<link rel="help" href="https://www.w3.org/TR/css-color-5/#light-dark">
<link rel="help" href="https://www.w3.org/TR/css-color-5/#color-mix">
<title>Test changing used color-scheme updates gradient with color-scheme dependent color stops.</title>
<link rel="match" href="color-scheme-dependent-color-stops-ref.html">
<style>

.dark {
color-scheme: dark;
}

.box {
width: 100px;
height: 100px;
}

#system-color {
background-image: linear-gradient(CanvasText, CanvasText);
}

#system-color-in-color-mix {
background-image: linear-gradient(color-mix(in lch, Canvas, pink), color-mix(in lch, Canvas, pink));
}

#light-dark {
background-image: linear-gradient(light-dark(red, green), light-dark(red, green));
}

#light-dark-in-color-mix {
background-image: linear-gradient(color-mix(in lch, light-dark(red, green), pink), color-mix(in lch, light-dark(red, green), pink));
}

</style>
</head>
<body>
<p>Test system color</p>
<div id="system-color" class="box"></div>
<p>Test system color in color-mix()</p>
<div id="system-color-in-color-mix" class="box"></div>
<p>Test light-dark()</p>
<div id="light-dark" class="box"></div>
<p>Test light-dark() in color-mix()</p>
<div id="light-dark-in-color-mix" class="box"></div>
<script>

requestAnimationFrame(() => {
document.querySelectorAll(".box").forEach((box) => {
box.classList.add("dark");
});

document.documentElement.className = '';
});

</script>
</body>
</html>

0 comments on commit acf9d2c

Please sign in to comment.