mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
Auto merge of #17812 - brainlessdeveloper:use-resolved-url-instead-of-original, r=emilio
Introduce ComputedUrl <!-- Please describe your changes on the following line: --> Use the new `ComputedUrl` type for computed types and `SpecifiedUrl` for specified types instead of using the `SpecifiedUrl` implementation for both. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #17625 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because this is an implementation change and tests already exist. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17812) <!-- Reviewable:end -->
This commit is contained in:
commit
8a48578a26
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