Truly independent web browser
LibWeb: Cover initial SVG stop and flood color values
Andreas Klingf0426c7ca740
diff --git a/Tests/LibWeb/Ref/expected/svg-reset-color-inheritance-ref.html b/Tests/LibWeb/Ref/expected/svg-reset-color-inheritance-ref.htmlnew file mode 100644index 00000000000..d1edaecb485--- /dev/null+++ b/Tests/LibWeb/Ref/expected/svg-reset-color-inheritance-ref.html@@ -0,0 +1,2 @@+<!DOCTYPE html>+<div style="width: 200px; height: 100px; background: green"></div>diff --git a/Tests/LibWeb/Ref/input/svg-reset-color-inheritance.html b/Tests/LibWeb/Ref/input/svg-reset-color-inheritance.htmlnew file mode 100644index 00000000000..f1b3f39a75d--- /dev/null+++ b/Tests/LibWeb/Ref/input/svg-reset-color-inheritance.html@@ -0,0 +1,40 @@+<!DOCTYPE html>+<html class="reftest-wait">+<link rel="match" href="../expected/svg-reset-color-inheritance-ref.html">+<svg width="200" height="100">+ <defs>+ <linearGradient id="gradient" stop-color="currentcolor" color="red">+ <stop offset="0" stop-color="inherit" color="blue"/>+ <stop offset="1" stop-color="inherit" color="blue"/>+ </linearGradient>+ <filter id="filter" flood-color="currentcolor" color="red" x="0%" y="0%" width="100%" height="100%">+ <feFlood id="flood" flood-color="inherit" color="blue"/>+ </filter>+ </defs>+ <rect width="100" height="100" fill="url(#gradient)"/>+ <rect x="100" width="100" height="100" filter="url(#filter)"/>+</svg>+<script>+ window.addEventListener("load", () => {+ const gradient = document.getElementById("gradient");+ const filter = document.getElementById("filter");+ const flood = document.getElementById("flood");+ for (const stop of gradient.children)+ getComputedStyle(stop).stopColor;+ getComputedStyle(flood).floodColor;+ if (window.internals)+ internals.dumpDisplayList();++ gradient.style.color = "purple";+ filter.style.color = "purple";+ for (const stop of gradient.children)+ stop.style.color = "green";+ flood.style.color = "green";++ if (window.internals)+ internals.signalTestIsDone("PASS");+ else+ document.documentElement.classList.remove("reftest-wait");+ });+</script>+</html>diff --git a/Tests/LibWeb/Text/expected/svg-reset-color-inheritance.txt b/Tests/LibWeb/Text/expected/svg-reset-color-inheritance.txtnew file mode 100644index 00000000000..7a741cced50--- /dev/null+++ b/Tests/LibWeb/Text/expected/svg-reset-color-inheritance.txt@@ -0,0 +1,26 @@+initial stop-color: currentcolor+initial flood-color: currentcolor+block stop-color parent: rgb(255, 0, 0)+block stop-color inherited: rgb(0, 0, 255)+block stop-color parent color changed: rgb(0, 0, 255)+block stop-color child color changed: rgb(0, 128, 0)+block stop-color fixed color: rgb(1, 2, 3)+block stop-color restored: rgb(0, 128, 0)+block flood-color parent: rgb(255, 0, 0)+block flood-color inherited: rgb(0, 0, 255)+block flood-color parent color changed: rgb(0, 0, 255)+block flood-color child color changed: rgb(0, 128, 0)+block flood-color fixed color: rgb(1, 2, 3)+block flood-color restored: rgb(0, 128, 0)+none stop-color parent: rgb(255, 0, 0)+none stop-color inherited: rgb(0, 0, 255)+none stop-color parent color changed: rgb(0, 0, 255)+none stop-color child color changed: rgb(0, 128, 0)+none stop-color fixed color: rgb(1, 2, 3)+none stop-color restored: rgb(0, 128, 0)+none flood-color parent: rgb(255, 0, 0)+none flood-color inherited: rgb(0, 0, 255)+none flood-color parent color changed: rgb(0, 0, 255)+none flood-color child color changed: rgb(0, 128, 0)+none flood-color fixed color: rgb(1, 2, 3)+none flood-color restored: rgb(0, 128, 0)diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/parsing/stop-color-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/parsing/stop-color-computed.txtnew file mode 100644index 00000000000..780db572e34--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/parsing/stop-color-computed.txt@@ -0,0 +1,15 @@+Harness status: OK++Found 10 tests++10 Pass+Pass Property stop-color value 'currentcolor'+Pass Property stop-color value 'white'+Pass Property stop-color value 'transparent'+Pass Property stop-color value 'rgb(255, 255, 255)'+Pass Property stop-color value '#ffffff'+Pass Property stop-color value 'rgba(255, 255, 255, 1.0)'+Pass Property stop-color value 'rgba(255, 255, 255, 0.4)'+Pass Property stop-color value 'hsl(0deg, 100%, 100%)'+Pass Property stop-color value 'hsla(0deg, 100%, 100%, 1.0)'+Pass Property stop-color value 'hsla(0deg, 100%, 100%, 0.4)'\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.txtnew file mode 100644index 00000000000..7ca21509b7c--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.txt@@ -0,0 +1,6 @@+Harness status: OK++Found 1 tests++1 Fail+Fail "currentcolor" is inherited as a keyword\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/svg-reset-color-inheritance.html b/Tests/LibWeb/Text/input/svg-reset-color-inheritance.htmlnew file mode 100644index 00000000000..afccb7c1066--- /dev/null+++ b/Tests/LibWeb/Text/input/svg-reset-color-inheritance.html@@ -0,0 +1,41 @@+<!DOCTYPE html>+<script src="include.js"></script>+<svg width="100" height="100">+ <g id="parent" style="color: red"><rect id="child" width="10" height="10" style="color: blue"/></g>+ <defs>+ <linearGradient stop-color="currentcolor" color="red">+ <stop id="initial-stop" stop-color="inherit" color="blue"/>+ </linearGradient>+ <filter flood-color="currentcolor" color="red">+ <feFlood id="initial-flood" flood-color="inherit" color="blue"/>+ </filter>+ </defs>+</svg>+<script>+ test(() => {+ const parent = document.getElementById("parent");+ const child = document.getElementById("child");+ println(`initial stop-color: ${getComputedStyle(document.getElementById("initial-stop")).stopColor}`);+ println(`initial flood-color: ${getComputedStyle(document.getElementById("initial-flood")).floodColor}`);+ for (const display of ["block", "none"]) {+ parent.style.display = display;+ child.getBoundingClientRect();+ for (const property of ["stop-color", "flood-color"]) {+ parent.style.color = "red";+ child.style.color = "blue";+ child.style[property] = "inherit";+ parent.style[property] = "currentcolor";+ println(`${display} ${property} parent: ${getComputedStyle(parent)[property]}`);+ println(`${display} ${property} inherited: ${getComputedStyle(child)[property]}`);+ parent.style.color = "purple";+ println(`${display} ${property} parent color changed: ${getComputedStyle(child)[property]}`);+ child.style.color = "green";+ println(`${display} ${property} child color changed: ${getComputedStyle(child)[property]}`);+ parent.style[property] = "rgb(1, 2, 3)";+ println(`${display} ${property} fixed color: ${getComputedStyle(child)[property]}`);+ parent.style[property] = "currentcolor";+ println(`${display} ${property} restored: ${getComputedStyle(child)[property]}`);+ }+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/pservers/parsing/stop-color-computed.svg b/Tests/LibWeb/Text/input/wpt-import/svg/pservers/parsing/stop-color-computed.svgnew file mode 100644index 00000000000..ad4ad085337--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/svg/pservers/parsing/stop-color-computed.svg@@ -0,0 +1,27 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml">+ <title>SVG Paint Servers: getComputedStyle().stopColor</title>+ <metadata>+ <h:link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/pservers.html#StopColorProperty"/>+ <h:link rel="help" href="https://drafts.csswg.org/css-color/#resolve-color-values"/>+ <h:link rel="help" href="https://drafts.csswg.org/cssom/#serializing-css-values"/>+ </metadata>+ <g id="target" style="color: blue"></g>+ <h:script src="../../../resources/testharness.js"/>+ <h:script src="../../../resources/testharnessreport.js"/>+ <h:script src="../../../css/support/computed-testcommon.js"/>+ <script><![CDATA[++test_computed_value("stop-color", "currentcolor", "rgb(0, 0, 255)");+test_computed_value("stop-color", "white", "rgb(255, 255, 255)");+test_computed_value("stop-color", "transparent", "rgba(0, 0, 0, 0)");+test_computed_value("stop-color", "rgb(255, 255, 255)");+test_computed_value("stop-color", "#ffffff", "rgb(255, 255, 255)");+test_computed_value("stop-color", "rgba(255, 255, 255, 1.0)", "rgb(255, 255, 255)");+test_computed_value("stop-color", "rgba(255, 255, 255, 0.4)");+test_computed_value("stop-color", "hsl(0deg, 100%, 100%)", "rgb(255, 255, 255)");+test_computed_value("stop-color", "hsla(0deg, 100%, 100%, 1.0)", "rgb(255, 255, 255)");+test_computed_value("stop-color", "hsla(0deg, 100%, 100%, 0.4)", "rgba(255, 255, 255, 0.4)");++ ]]></script>+</svg>diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.svg b/Tests/LibWeb/Text/input/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.svgnew file mode 100644index 00000000000..66ec19b77a9--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/svg/pservers/scripted/stop-color-inheritance-currentcolor.svg@@ -0,0 +1,22 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg" xmlns:h="http://www.w3.org/1999/xhtml"+ color="red">+ <title>SVG Paint Servers: 'stop-color' inheritance of 'currentcolor'</title>+ <metadata>+ <h:link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/pservers.html#StopColorProperty"/>+ <h:link rel="help" href="https://drafts.csswg.org/css-color/#resolve-color-values"/>+ </metadata>+ <h:script src="../../../resources/testharness.js"/>+ <h:script src="../../../resources/testharnessreport.js"/>+ <linearGradient stop-color="currentcolor" id="g">+ <stop stop-color="inherit" color="green"/>+ </linearGradient>+ <script><![CDATA[++ test(function() {+ let stop = document.querySelector('stop');+ assert_equals(getComputedStyle(stop).stopColor, 'rgb(0, 128, 0)');+ }, '"currentcolor" is inherited as a keyword');++ ]]></script>+</svg>