mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
Tests: Import some URL-related WPT tests
This commit is contained in:
parent
a1fb34d7f2
commit
09b508d8e8
Notes:
github-actions[bot]
2025-05-03 22:23:47 +00:00
Author: https://github.com/AtkinsSJ
Commit: 09b508d8e8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4569
Reviewed-by: https://github.com/tcl3 ✅
18 changed files with 462 additions and 0 deletions
|
@ -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>
|
|
@ -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>
|
|
@ -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://www.not-wpt.live">
|
||||
<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>
|
|
@ -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>
|
|
@ -0,0 +1,9 @@
|
|||
#external-unquoted {
|
||||
background-image: url();
|
||||
cursor: url(), pointer;
|
||||
}
|
||||
|
||||
#external-quoted {
|
||||
background-image: url("");
|
||||
cursor: url(""), pointer;
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-values-5/#request-url-modifiers">
|
||||
<link rel="author" title="Sam Weinig" href="mailto:weinig@webkit.org">
|
||||
<script src="../../../resources/testharness.js"></script>
|
||||
<script src="../../../resources/testharnessreport.js"></script>
|
||||
<script src="../../../css/support/computed-testcommon.js"></script>
|
||||
<div id="container" style="font-size: 20">
|
||||
<div id="target"></div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
// No modifiers
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png")');
|
||||
|
||||
// <crossorigin-modifier> = crossorigin(anonymous | use-credentials)
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(use-credentials))');
|
||||
|
||||
// <integrity-modifier> = integrity(<string>)
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar"))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity(""))');
|
||||
|
||||
// <referrerpolicy-modifier> = referrerpolicy(no-referrer | no-referrer-when-downgrade | same-origin | origin | strict-origin | origin-when-cross-origin | strict-origin-when-cross-origin | unsafe-url)
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer-when-downgrade))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(same-origin))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(origin))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(strict-origin))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(origin-when-cross-origin))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(strict-origin-when-cross-origin))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(unsafe-url))');
|
||||
|
||||
// Multiple modifiers
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar"))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar"))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) integrity("sha384-foobar"))', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") referrerpolicy(no-referrer) crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) crossorigin(anonymous) integrity("sha384-foobar"))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_computed_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) integrity("sha384-foobar") crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-values-5/#request-url-modifiers">
|
||||
<link rel="author" title="Sam Weinig" href="mailto:weinig@webkit.org">
|
||||
<script src="../../../resources/testharness.js"></script>
|
||||
<script src="../../../resources/testharnessreport.js"></script>
|
||||
<script src="../../../css/support/parsing-testcommon.js"></script>
|
||||
<script>
|
||||
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin())');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(,))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous,))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(,anonymous))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous foobar))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) cross-origin(anonymous))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) cross-origin(use-credentials))');
|
||||
test_invalid_value('background-image', 'url(crossorigin(anonymous) "http://wpt.live:80/css/support/1x1-green.png")');
|
||||
test_invalid_value('background-image', '"http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous)');
|
||||
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity())');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity(,))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar",))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity(,"sha384-foobar"))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar" foobar))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity(sha384-foobar))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") integrity("sha384-foobar"))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") integrity("sha384-barbaz"))');
|
||||
test_invalid_value('background-image', 'url(integrity("sha384-foobar") "http://wpt.live:80/css/support/1x1-green.png")');
|
||||
test_invalid_value('background-image', '"http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar")');
|
||||
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy())');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(,))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer,))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(,no-referrer))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer foobar))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer same-origin))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) referrerpolicy(no-referrer))');
|
||||
test_invalid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) referrerpolicy(same-origin))');
|
||||
test_invalid_value('background-image', 'url(referrerpolicy(no-referrer) "http://wpt.live:80/css/support/1x1-green.png")');
|
||||
test_invalid_value('background-image', '"http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer)');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-values-5/#request-url-modifiers">
|
||||
<link rel="author" title="Sam Weinig" href="mailto:weinig@webkit.org">
|
||||
<script src="../../../resources/testharness.js"></script>
|
||||
<script src="../../../resources/testharnessreport.js"></script>
|
||||
<script src="../../../css/support/parsing-testcommon.js"></script>
|
||||
<div id=target></div>
|
||||
<script>
|
||||
|
||||
// No modifiers
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png")');
|
||||
|
||||
// <crossorigin-modifier> = crossorigin(anonymous | use-credentials)
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(use-credentials))');
|
||||
|
||||
// <integrity-modifier> = integrity(<string>)
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar"))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity(""))');
|
||||
|
||||
// <referrerpolicy-modifier> = referrerpolicy(no-referrer | no-referrer-when-downgrade | same-origin | origin | strict-origin | origin-when-cross-origin | strict-origin-when-cross-origin | unsafe-url)
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer-when-downgrade))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(same-origin))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(origin))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(strict-origin))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(origin-when-cross-origin))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(strict-origin-when-cross-origin))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(unsafe-url))');
|
||||
|
||||
// Multiple modifiers
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar"))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar"))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) integrity("sha384-foobar"))', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" integrity("sha384-foobar") referrerpolicy(no-referrer) crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) crossorigin(anonymous) integrity("sha384-foobar"))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
test_valid_value('background-image', 'url("http://wpt.live:80/css/support/1x1-green.png" referrerpolicy(no-referrer) integrity("sha384-foobar") crossorigin(anonymous))', 'url("http://wpt.live:80/css/support/1x1-green.png" crossorigin(anonymous) integrity("sha384-foobar") referrerpolicy(no-referrer))');
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue