mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Introduce ComputedUrl
Add web platform tests for computed URL styles Mark url with no original or resolved unreachable Update the WPT manifest for new url tests
This commit is contained in:
parent
f6aa17add9
commit
14c5a1b8d3
17 changed files with 197 additions and 46 deletions
|
@ -13536,6 +13536,12 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"css/get-computed-style-for-url.html": [
|
||||
[
|
||||
"/_mozilla/css/get-computed-style-for-url.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/import_serialization.html": [
|
||||
[
|
||||
"/_mozilla/css/import_serialization.html",
|
||||
|
@ -23357,6 +23363,10 @@
|
|||
"13a3f8dd23fa28c0b2ad2fe0662d29a27a569e74",
|
||||
"support"
|
||||
],
|
||||
"css/get-computed-style-for-url.html": [
|
||||
"2e90c0abd6c83bb11113f39a557a4c1c1c24364b",
|
||||
"testharness"
|
||||
],
|
||||
"css/green.png": [
|
||||
"15e39f6df8def787cefcfb30e27de5f43da65c9a",
|
||||
"support"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
[get-computed-style-for-url.html]
|
||||
type: testharness
|
||||
|
||||
[getComputedStyle(elem) for url() listStyle uses the resolved URL and elem.style uses the original URL]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/18015
|
||||
|
||||
[getComputedStyle(elem) for url() listStyleImage uses the resolved URL and elem.style uses the original URL]
|
||||
expected: FAIL
|
||||
bug: https://github.com/servo/servo/issues/18015
|
||||
|
49
tests/wpt/mozilla/tests/css/get-computed-style-for-url.html
Normal file
49
tests/wpt/mozilla/tests/css/get-computed-style-for-url.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>Computed styles for URLs use the resolved URL and specified styles use the original URL</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="tests"></div>
|
||||
<script>
|
||||
var origin = window.location.origin;
|
||||
var container = document.getElementById("tests");
|
||||
|
||||
// Some shorthands like background and border-image compute to other properties
|
||||
var computedPropertyName = {
|
||||
background: "backgroundImage",
|
||||
borderImage: "borderImageSource",
|
||||
listStyle: "listStyleImage",
|
||||
};
|
||||
|
||||
function makeComputedUrlStyle(path) {
|
||||
return `url("${origin}/${path}")`;
|
||||
}
|
||||
function makeSpecifiedUrlStyle(path) {
|
||||
return `url("${path}")`;
|
||||
}
|
||||
function testUrlsForProperty(property, urlValue, extraShorthand) {
|
||||
test(function() {
|
||||
var extra = extraShorthand ? ` ${extraShorthand}` : "";
|
||||
|
||||
var elem = document.createElement("div");
|
||||
elem.style[property] = `url("${urlValue}")${extra}`;
|
||||
container.appendChild(elem);
|
||||
|
||||
assert_equals(
|
||||
getComputedStyle(elem)[computedPropertyName[property] || property],
|
||||
makeComputedUrlStyle(`_mozilla/css/${urlValue}`)
|
||||
);
|
||||
assert_equals(
|
||||
elem.style[computedPropertyName[property] || property],
|
||||
makeSpecifiedUrlStyle(urlValue)
|
||||
);
|
||||
}, `getComputedStyle(elem) for url() ${property} uses the resolved URL and elem.style uses the original URL`);
|
||||
}
|
||||
|
||||
testUrlsForProperty("backgroundImage", "test.jpg");
|
||||
testUrlsForProperty("background", "test.jpg", "no-repeat");
|
||||
testUrlsForProperty("borderImage", "test.jpg", "30 round");
|
||||
testUrlsForProperty("listStyleImage", "test.jpg");
|
||||
testUrlsForProperty("listStyle", "test.jpg", "square");
|
||||
</script>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue