diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-values/urls | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-values/urls')
7 files changed, 190 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-values/urls/empty.html b/testing/web-platform/tests/css/css-values/urls/empty.html new file mode 100644 index 0000000000..3748567545 --- /dev/null +++ b/testing/web-platform/tests/css/css-values/urls/empty.html @@ -0,0 +1,39 @@ +<!doctype html> +<title>Empty URLs behaviour</title> +<link rel=help href=https://drafts.csswg.org/css-values/#url-empty> +<link rel=help href=https://github.com/w3c/csswg-drafts/issues/2211#issuecomment-365677844> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<style> +#inline-unquoted { + background-image: url(); + cursor: url(), pointer; +} + +#inline-quoted { + background-image: url(""); + cursor: url(""), pointer; +} +</style> +<link rel=stylesheet href=support/empty-urls.css> +<div id="inline-unquoted"></div> +<div id="inline-quoted"></div> +<div id="external-unquoted"></div> +<div id="external-quoted"></div> +<script> +const ids = [ + "inline-unquoted", + "inline-quoted", + "external-unquoted", + "external-quoted" +]; + +for (let id of ids) { + test(function() { + const el = document.getElementById(id); + const style = window.getComputedStyle(el); + assert_equals(style["background-image"], 'url("")'); + assert_equals(style["cursor"], 'url(""), pointer'); + }, "empty URL: " + id); +} +</script> diff --git a/testing/web-platform/tests/css/css-values/urls/fragment-only.html b/testing/web-platform/tests/css/css-values/urls/fragment-only.html new file mode 100644 index 0000000000..a7153adf8f --- /dev/null +++ b/testing/web-platform/tests/css/css-values/urls/fragment-only.html @@ -0,0 +1,40 @@ +<!doctype html> +<title>Fragment-on URLs behaviour</title> +<link rel=help href=https://drafts.csswg.org/css-values/#local-urls> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<style> +#inline-unquoted { + background-image: url(#foo); + cursor: url(#foo), pointer; +} + +#inline-quoted { + background-image: url("#foo"); + cursor: url("#foo"), pointer; +} +</style> +<link rel=stylesheet href=support/fragment-only-urls.css> +<div id="inline-unquoted"></div> +<div id="inline-quoted"></div> +<div id="external-unquoted"></div> +<div id="external-quoted"></div> +<div id="external-variable"></div> +<script> +const ids = [ + "inline-unquoted", + "inline-quoted", + "external-unquoted", + "external-quoted", + "external-variable", +]; + +for (let id of ids) { + test(function() { + const el = document.getElementById(id); + const style = window.getComputedStyle(el); + assert_equals(style["background-image"], 'url("#foo")'); + assert_equals(style["cursor"], 'url("#foo"), pointer'); + }, "empty URL: " + id); +} +</script> diff --git a/testing/web-platform/tests/css/css-values/urls/resolve-relative-to-base.sub.html b/testing/web-platform/tests/css/css-values/urls/resolve-relative-to-base.sub.html new file mode 100644 index 0000000000..bfbe127ab2 --- /dev/null +++ b/testing/web-platform/tests/css/css-values/urls/resolve-relative-to-base.sub.html @@ -0,0 +1,35 @@ +<!doctype html> +<title>URLs in embedded style sheets resolve relative to the document base URI</title> +<link rel=help href=https://drafts.csswg.org/css-values/#relative-urls> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<base href="http://{{hosts[alt][www]}}"> +<style> +:root { + --image-path: url("images/test.png"); +} +#relative-image-url { + background-image: url(images/test.png); +} + +#relative-image-variable-url { + background-image: var(--image-path); +} +</style> +<div id="relative-image-url"></div> +<div id="relative-image-variable-url"></div> +<script> +const ids = [ + "relative-image-url", + "relative-image-variable-url" +]; + +for (let id of ids) { + test(() => { + const el = document.getElementById(id); + const backgroundImageStyle = window.getComputedStyle(el)["background-image"]; + const baseRelativeImageURL = new URL("images/test.png", document.baseURI); + assert_equals(backgroundImageStyle, `url("${baseRelativeImageURL.href}")`); + }, "base-relative URL: " + id); +} +</script> diff --git a/testing/web-platform/tests/css/css-values/urls/resolve-relative-to-stylesheet.html b/testing/web-platform/tests/css/css-values/urls/resolve-relative-to-stylesheet.html new file mode 100644 index 0000000000..1475d97052 --- /dev/null +++ b/testing/web-platform/tests/css/css-values/urls/resolve-relative-to-stylesheet.html @@ -0,0 +1,33 @@ +<!doctype html> +<title>URLs in a stylesheet resolve relative to the stylesheet</title> +<link rel=help href=https://drafts.csswg.org/css-values/#relative-urls> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<link id="stylesheet" rel=stylesheet href=support/relative-urls.css> +<div id="stylesheet-relative-image"></div> +<div id="stylesheet-relative-variable-image"></div> +<div id="stylesheet-relative-document-variable-image"></div> +<style> + :root { + --image-path-document: url("images/test.png"); + } +</style> +<script> +const ids = [ + "stylesheet-relative-image", + "stylesheet-relative-variable-image", + "stylesheet-relative-document-variable-image", +]; + +for (let id of ids) { + test(() => { + const el = document.getElementById(id); + const backgroundImageStyle = window.getComputedStyle(el)["background-image"]; + + const stylesheet = document.getElementById("stylesheet"); + const sheetRelativeImageURL = new URL("images/test.png", stylesheet.href); + + assert_equals(backgroundImageStyle, `url("${sheetRelativeImageURL.href}")`); + }, "stylesheet-relative URL: " + id); +} +</script> diff --git a/testing/web-platform/tests/css/css-values/urls/support/empty-urls.css b/testing/web-platform/tests/css/css-values/urls/support/empty-urls.css new file mode 100644 index 0000000000..0559e3b235 --- /dev/null +++ b/testing/web-platform/tests/css/css-values/urls/support/empty-urls.css @@ -0,0 +1,9 @@ +#external-unquoted { + background-image: url(); + cursor: url(), pointer; +} + +#external-quoted { + background-image: url(""); + cursor: url(""), pointer; +} diff --git a/testing/web-platform/tests/css/css-values/urls/support/fragment-only-urls.css b/testing/web-platform/tests/css/css-values/urls/support/fragment-only-urls.css new file mode 100644 index 0000000000..2c39a087e9 --- /dev/null +++ b/testing/web-platform/tests/css/css-values/urls/support/fragment-only-urls.css @@ -0,0 +1,19 @@ +:root { + --fragment-image-url: url("#foo"); + --fragment-cursor-url: url("#foo"), pointer; +} + +#external-unquoted { + background-image: url(#foo); + cursor: url(#foo), pointer; +} + +#external-quoted { + background-image: url("#foo"); + cursor: url("#foo"), pointer; +} + +#external-variable { + background-image: var(--fragment-image-url); + cursor: var(--fragment-cursor-url); +} diff --git a/testing/web-platform/tests/css/css-values/urls/support/relative-urls.css b/testing/web-platform/tests/css/css-values/urls/support/relative-urls.css new file mode 100644 index 0000000000..1354c655e9 --- /dev/null +++ b/testing/web-platform/tests/css/css-values/urls/support/relative-urls.css @@ -0,0 +1,15 @@ +:root { + --image-path-stylesheet: url("images/test.png"); +} + +#stylesheet-relative-image { + background-image: url(images/test.png); +} + +#stylesheet-relative-variable-image { + background-image: var(--image-path-stylesheet); +} + +#stylesheet-relative-document-variable-image { + background-image: var(--image-path-document); +} |