Truly independent web browser
LibWeb: Import SVG paint URL computation tests
Andreas Kling36628f41c9f0
diff --git a/Tests/LibWeb/Text/expected/svg-paint-computed-urls.txt b/Tests/LibWeb/Text/expected/svg-paint-computed-urls.txtnew file mode 100644index 00000000000..6b05743edc6--- /dev/null+++ b/Tests/LibWeb/Text/expected/svg-paint-computed-urls.txt@@ -0,0 +1,50 @@+external fill: false+external stroke: false+fill "paint.svg#gradient": false+fill inherited "paint.svg#gradient": false+fill fallback "paint.svg#gradient": false+fill specified "paint.svg#gradient": true+fill "../paint.svg#gradient": false+fill inherited "../paint.svg#gradient": false+fill fallback "../paint.svg#gradient": false+fill specified "../paint.svg#gradient": true+fill "é.svg#gradient": false+fill inherited "é.svg#gradient": false+fill fallback "é.svg#gradient": false+fill specified "é.svg#gradient": true+fill "#gradient": true+fill inherited "#gradient": true+fill fallback "#gradient": true+fill specified "#gradient": true+fill "": true+fill inherited "": true+fill fallback "": true+fill specified "": true+fill "https://example.test/paint.svg#gradient": true+fill inherited "https://example.test/paint.svg#gradient": true+fill fallback "https://example.test/paint.svg#gradient": true+fill specified "https://example.test/paint.svg#gradient": true+stroke "paint.svg#gradient": false+stroke inherited "paint.svg#gradient": false+stroke fallback "paint.svg#gradient": false+stroke specified "paint.svg#gradient": true+stroke "../paint.svg#gradient": false+stroke inherited "../paint.svg#gradient": false+stroke fallback "../paint.svg#gradient": false+stroke specified "../paint.svg#gradient": true+stroke "é.svg#gradient": false+stroke inherited "é.svg#gradient": false+stroke fallback "é.svg#gradient": false+stroke specified "é.svg#gradient": true+stroke "#gradient": true+stroke inherited "#gradient": true+stroke fallback "#gradient": true+stroke specified "#gradient": true+stroke "": true+stroke inherited "": true+stroke fallback "": true+stroke specified "": true+stroke "https://example.test/paint.svg#gradient": true+stroke inherited "https://example.test/paint.svg#gradient": true+stroke fallback "https://example.test/paint.svg#gradient": true+stroke specified "https://example.test/paint.svg#gradient": truediff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/fill-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/fill-computed.txtnew file mode 100644index 00000000000..f3fe7f6da82--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/fill-computed.txt@@ -0,0 +1,12 @@+Harness status: OK++Found 6 tests++5 Pass+1 Fail+Pass Property fill value 'none'+Pass Property fill value 'rgb(12, 34, 56)'+Pass Property fill value 'url("https://example.com/")'+Pass Property fill value 'url("https://example.com/") none'+Pass Property fill value 'url("https://example.com/") rgb(12, 34, 56)'+Fail url values are made absolute\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/stroke-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/stroke-computed.txtnew file mode 100644index 00000000000..6994bf7d4f8--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/stroke-computed.txt@@ -0,0 +1,12 @@+Harness status: OK++Found 6 tests++5 Pass+1 Fail+Pass Property stroke value 'none'+Pass Property stroke value 'rgb(12, 34, 56)'+Pass Property stroke value 'url("https://example.com/")'+Pass Property stroke value 'url("https://example.com/") none'+Pass Property stroke value 'url("https://example.com/") rgb(12, 34, 56)'+Fail url values are made absolute\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/support/svg-paint-computed-urls.css b/Tests/LibWeb/Text/input/support/svg-paint-computed-urls.cssnew file mode 100644index 00000000000..04b2adc56e7--- /dev/null+++ b/Tests/LibWeb/Text/input/support/svg-paint-computed-urls.css@@ -0,0 +1,4 @@+.external-paint {+ fill: url("paint.svg#gradient");+ stroke: url("paint.svg#gradient") rgb(12, 34, 56);+}diff --git a/Tests/LibWeb/Text/input/svg-paint-computed-urls.html b/Tests/LibWeb/Text/input/svg-paint-computed-urls.htmlnew file mode 100644index 00000000000..859cc3eedbd--- /dev/null+++ b/Tests/LibWeb/Text/input/svg-paint-computed-urls.html@@ -0,0 +1,30 @@+<!DOCTYPE html>+<script src="include.js"></script>+<link rel="stylesheet" href="support/svg-paint-computed-urls.css">+<svg>+ <g id="parent"><g id="child"></g></g>+ <g id="external" class="external-paint"></g>+</svg>+<script>+ test(() => {+ const parent = document.getElementById("parent");+ const child = document.getElementById("child");+ const external = document.getElementById("external");+ const externalURL = new URL("support/paint.svg#gradient", document.baseURI).href;+ println(`external fill: ${getComputedStyle(external).fill === `url("${externalURL}")`}`);+ println(`external stroke: ${getComputedStyle(external).stroke === `url("${externalURL}") rgb(12, 34, 56)`}`);+ for (const property of ["fill", "stroke"]) {+ for (const url of ["paint.svg#gradient", "../paint.svg#gradient", "é.svg#gradient", "#gradient", "", "https://example.test/paint.svg#gradient"]) {+ const specified = `url("${url}")`;+ const computedURL = url === "" || url.startsWith("#") ? url : new URL(url, document.baseURI).href;+ const expected = `url("${computedURL}")`;+ parent.style[property] = specified;+ println(`${property} ${JSON.stringify(url)}: ${getComputedStyle(parent)[property] === expected}`);+ println(`${property} inherited ${JSON.stringify(url)}: ${getComputedStyle(child)[property] === expected}`);+ parent.style[property] = `${specified} rgb(12, 34, 56)`;+ println(`${property} fallback ${JSON.stringify(url)}: ${getComputedStyle(parent)[property] === `${expected} rgb(12, 34, 56)`}`);+ println(`${property} specified ${JSON.stringify(url)}: ${parent.style[property] === `${specified} rgb(12, 34, 56)`}`);+ }+ }+ });+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/fill-computed.svg b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/fill-computed.svgnew file mode 100644index 00000000000..a84473be4be--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/fill-computed.svg@@ -0,0 +1,34 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg"+ xmlns:h="http://www.w3.org/1999/xhtml"+ width="800px" height="800px">+ <title>SVG Painting: getComputedStyle().fill</title>+ <metadata>+ <h:link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/painting.html#FillProperty"/>+ <h:meta name="assert" content="fill computed value is as specified, with url values absolute."/>+ </metadata>+ <g id="target"></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("fill", "none");+test_computed_value("fill", "rgb(12, 34, 56)");++test_computed_value("fill", 'url("https://example.com/")');+test_computed_value("fill", 'url("https://example.com/") none');+test_computed_value("fill", 'url("https://example.com/") rgb(12, 34, 56)');++// context-fill and context-stroke are not yet supported by browsers.++test(() => {+ const target = document.getElementById('target');+ target.style['fill'] = 'url("a.b#c")';+ const result = getComputedStyle(target)['fill'];+ const resolved = new URL("a.b#c", document.URL).href;+ assert_equals(result, 'url("' + resolved + '")');+}, 'url values are made absolute');++ ]]></script>+</svg>diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/stroke-computed.svg b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/stroke-computed.svgnew file mode 100644index 00000000000..9ba6ac1c758--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/stroke-computed.svg@@ -0,0 +1,34 @@+<?xml version="1.0" encoding="UTF-8"?>+<svg xmlns="http://www.w3.org/2000/svg"+ xmlns:h="http://www.w3.org/1999/xhtml"+ width="800px" height="800px">+ <title>SVG Painting: getComputedStyle().stroke</title>+ <metadata>+ <h:link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/painting.html#StrokeProperty"/>+ <h:meta name="assert" content="stroke computed value is as specified, with url values absolute."/>+ </metadata>+ <g id="target"></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("stroke", "none");+test_computed_value("stroke", "rgb(12, 34, 56)");++test_computed_value("stroke", 'url("https://example.com/")');+test_computed_value("stroke", 'url("https://example.com/") none');+test_computed_value("stroke", 'url("https://example.com/") rgb(12, 34, 56)');++// context-fill and context-stroke are not yet supported by browsers.++test(() => {+ const target = document.getElementById('target');+ target.style['stroke'] = 'url("a.b#c")';+ const result = getComputedStyle(target)['stroke'];+ const resolved = new URL("a.b#c", document.URL).href;+ assert_equals(result, 'url("' + resolved + '")');+}, 'url values are made absolute');++ ]]></script>+</svg>