mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision ac16628eb7eb601957382053011363d2bcf8ce44
This commit is contained in:
parent
ea7e753cea
commit
7e7c8873e4
4408 changed files with 664787 additions and 857286 deletions
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>Length unit 'ch' used in pseudo elements without text should be recalculated after loading a web font</title>
|
||||
<link rel="help" href="https://www.w3.org/TR/css-values-4/#font-relative-lengths">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-pseudo-4">
|
||||
<link rel="author" href="xiaochengh@chromium.org">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
.before::before,
|
||||
.after::after,
|
||||
.backdrop::backdrop {
|
||||
font: 25px/1 "custom font", monospace;
|
||||
background: linear-gradient(45deg, red, blue);
|
||||
background-size: 1ch 1ch;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container before"></div>
|
||||
<div class="container after"></div>
|
||||
<dialog class="container backdrop"></dialog>
|
||||
|
||||
<script>
|
||||
function parseBackgroundSizeInPx(element, pseudoElement) {
|
||||
const x = getComputedStyle(element, pseudoElement).backgroundSize.split(' ')[0];
|
||||
if (!x.endsWith('px'))
|
||||
return NaN;
|
||||
return parseFloat(x);
|
||||
}
|
||||
|
||||
const testCases = ['before', 'after', 'backdrop'];
|
||||
const elements = testCases.map(testCase => document.querySelector('.' + testCase));
|
||||
const asyncTests = testCases.map(
|
||||
testCase => async_test(`ch in pseudo-element ::${testCase} should be recalculated after loading a web font`));
|
||||
|
||||
// Before loading custom font, tests should be rendered with monospace
|
||||
// fallback and have a '1ch' measurement much shorter than 25px.
|
||||
for (let i = 0; i < testCases.length; ++i) {
|
||||
asyncTests[i].step(() => {
|
||||
const backgroundSizePx = parseBackgroundSizeInPx(elements[i], '::' + testCases[i]);
|
||||
assert_less_than(backgroundSizePx, 24);
|
||||
});
|
||||
}
|
||||
|
||||
// Insert custom font into style sheet and load it
|
||||
const customFont = new FontFace('custom font', 'url(/fonts/Ahem.ttf)');
|
||||
document.fonts.add(customFont);
|
||||
|
||||
// After loading custom font, tests should be rendered with the custom font,
|
||||
// which is Ahem, and have a '1ch' measurement that equals 25px.
|
||||
customFont.load().then(
|
||||
() => {
|
||||
for (let i = 0; i < testCases.length; ++i) {
|
||||
asyncTests[i].step(() => {
|
||||
const backgroundSizePx = parseBackgroundSizeInPx(elements[i], '::' + testCases[i]);
|
||||
assert_equals(backgroundSizePx, 25);
|
||||
asyncTests[i].done();
|
||||
});
|
||||
}
|
||||
},
|
||||
() => {
|
||||
for (let i = 0; i < testCases.length; ++i) {
|
||||
asyncTests[i].step(() => {
|
||||
assert_unreached('Failed to load font');
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
|
@ -20,4 +20,5 @@ test_invalid_length('clamp(, 1px, 1px)');
|
|||
test_invalid_length('clamp(1px, 1px, )');
|
||||
test_invalid_length('clamp(1px, 1px, 1px, )');
|
||||
test_invalid_length('clamp(1px 1px 1px)');
|
||||
test_invalid_length('clamp(0, 10rem, 100%)');
|
||||
</script>
|
||||
|
|
|
@ -2,91 +2,95 @@
|
|||
<title>round() function</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
</style>
|
||||
<script src="../support/numeric-testcommon.js"></script>
|
||||
|
||||
<meta name=author content="Tab Atkins-Bittner">
|
||||
<link rel=help href="https://drafts.csswg.org/css-values-4/#round-func">
|
||||
|
||||
<div></div>
|
||||
<div id=target></div>
|
||||
<script>
|
||||
const testEl = document.querySelector("div");
|
||||
function testRound(testString, expectedString, {base="0px", msg}={}) {
|
||||
test(()=>{
|
||||
testEl.style.width = base;
|
||||
testEl.style.width = testString;
|
||||
const usedValue = getComputedStyle(testEl).width;
|
||||
assert_not_equals(usedValue, base);
|
||||
testEl.style.width = base;
|
||||
testEl.style.width = expectedString;
|
||||
const expectedValue = getComputedStyle(testEl).width;
|
||||
assert_not_equals(expectedValue, base)
|
||||
assert_equal(usedValue, expectedValue);
|
||||
}, msg || `${testString} should round to ${expectedString}`);
|
||||
}
|
||||
|
||||
// No-op round should be same as nearest
|
||||
testRound("round(23px, 10px)", "20px");
|
||||
testRound("round(18px, 10px)", "20px");
|
||||
testRound("round(15px, 10px)", "20px");
|
||||
testRound("round(13px, 10px)", "10px");
|
||||
testRound("round(-13px, 10px)", "-10px");
|
||||
testRound("round(-18px, 10px)", "-20px");
|
||||
test_math_used("round(23px, 10px)", "20px");
|
||||
test_math_used("round(18px, 10px)", "20px");
|
||||
test_math_used("round(15px, 10px)", "20px");
|
||||
test_math_used("round(13px, 10px)", "10px");
|
||||
test_math_used("round(-13px, 10px)", "-10px");
|
||||
test_math_used("round(-18px, 10px)", "-20px");
|
||||
|
||||
// Test nearest
|
||||
testRound("round(nearest, 23px, 10px)", "20px");
|
||||
testRound("round(nearest, 18px, 10px)", "20px");
|
||||
testRound("round(nearest, 15px, 10px)", "20px");
|
||||
testRound("round(nearest, 13px, 10px)", "10px");
|
||||
testRound("round(nearest, -13px, 10px)", "-10px");
|
||||
testRound("round(nearest, -18px, 10px)", "-20px");
|
||||
test_math_used("round(nearest, 23px, 10px)", "20px");
|
||||
test_math_used("round(nearest, 18px, 10px)", "20px");
|
||||
test_math_used("round(nearest, 15px, 10px)", "20px");
|
||||
test_math_used("round(nearest, 13px, 10px)", "10px");
|
||||
test_math_used("round(nearest, -13px, 10px)", "-10px");
|
||||
test_math_used("round(nearest, -18px, 10px)", "-20px");
|
||||
|
||||
// Test down
|
||||
testRound("round(down, 23px, 10px)", "20px");
|
||||
testRound("round(down, 18px, 10px)", "10px");
|
||||
testRound("round(down, 15px, 10px)", "10px");
|
||||
testRound("round(down, 13px, 10px)", "10px");
|
||||
testRound("round(down, -13px, 10px)", "-20px");
|
||||
testRound("round(down, -18px, 10px)", "-20px");
|
||||
test_math_used("round(down, 23px, 10px)", "20px");
|
||||
test_math_used("round(down, 18px, 10px)", "10px");
|
||||
test_math_used("round(down, 15px, 10px)", "10px");
|
||||
test_math_used("round(down, 13px, 10px)", "10px");
|
||||
test_math_used("round(down, -13px, 10px)", "-20px");
|
||||
test_math_used("round(down, -18px, 10px)", "-20px");
|
||||
|
||||
// Test up
|
||||
testRound("round(up, 23px, 10px)", "30px");
|
||||
testRound("round(up, 18px, 10px)", "20px");
|
||||
testRound("round(up, 15px, 10px)", "20px");
|
||||
testRound("round(up, 13px, 10px)", "20px");
|
||||
testRound("round(up, -13px, 10px)", "-10px");
|
||||
testRound("round(up, -18px, 10px)", "-10px");
|
||||
test_math_used("round(up, 23px, 10px)", "30px");
|
||||
test_math_used("round(up, 18px, 10px)", "20px");
|
||||
test_math_used("round(up, 15px, 10px)", "20px");
|
||||
test_math_used("round(up, 13px, 10px)", "20px");
|
||||
test_math_used("round(up, -13px, 10px)", "-10px");
|
||||
test_math_used("round(up, -18px, 10px)", "-10px");
|
||||
|
||||
// Test to-zero
|
||||
testRound("round(to-zero, 23px, 10px)", "20px");
|
||||
testRound("round(to-zero, 18px, 10px)", "10px");
|
||||
testRound("round(to-zero, 15px, 10px)", "10px");
|
||||
testRound("round(to-zero, 13px, 10px)", "10px");
|
||||
testRound("round(to-zero, -13px, 10px)", "-10px");
|
||||
testRound("round(to-zero, -18px, 10px)", "-10px");
|
||||
test_math_used("round(to-zero, 23px, 10px)", "20px");
|
||||
test_math_used("round(to-zero, 18px, 10px)", "10px");
|
||||
test_math_used("round(to-zero, 15px, 10px)", "10px");
|
||||
test_math_used("round(to-zero, 13px, 10px)", "10px");
|
||||
test_math_used("round(to-zero, -13px, 10px)", "-10px");
|
||||
test_math_used("round(to-zero, -18px, 10px)", "-10px");
|
||||
|
||||
// Test a negative step
|
||||
testRound("round(23px, -10px)", "20px");
|
||||
testRound("round(18px, -10px)", "20px");
|
||||
testRound("round(15px, -10px)", "20px");
|
||||
testRound("round(13px, -10px)", "10px");
|
||||
testRound("round(-13px, -10px)", "-10px");
|
||||
testRound("round(-18px, -10px)", "-20px");
|
||||
test_math_used("round(23px, -10px)", "20px");
|
||||
test_math_used("round(18px, -10px)", "20px");
|
||||
test_math_used("round(15px, -10px)", "20px");
|
||||
test_math_used("round(13px, -10px)", "10px");
|
||||
test_math_used("round(-13px, -10px)", "-10px");
|
||||
test_math_used("round(-18px, -10px)", "-20px");
|
||||
|
||||
// Extreme cases:
|
||||
|
||||
// 0 step is NaN
|
||||
testRound("round(5px, 0px)", "calc(NaN)");
|
||||
test_nan("round(5, 0)");
|
||||
// both infinite is NaN
|
||||
testRound("round(1px/0, 1px/0)", "calc(NaN)");
|
||||
test_nan("round(infinity, infinity)");
|
||||
test_nan("round(infinity, -infinity)");
|
||||
test_nan("round(-infinity, infinity)");
|
||||
test_nan("round(-infinity, -infinity)");
|
||||
|
||||
// infinite value with finite step is the same infinity
|
||||
testRound("round(1px/0, 5px)", "calc(infinity * 1px)");
|
||||
testRound("round(1px/0, -5px)", "calc(infinity * 1px)");
|
||||
testRound("round(-1px/0, 5px)", "calc(-infinity * 1px)");
|
||||
testRound("round(-1px/0, -5px)", "calc(-infinity * 1px)");
|
||||
// finite value with infinite step is same-sign 0
|
||||
testRound("calc(1/round(5px, 1px/0))", "calc(infinity * 1px)");
|
||||
testRound("calc(1/round(5px, -1px/0))", "calc(infinity * 1px)");
|
||||
testRound("calc(1/round(-5px, 1px/0))", "calc(-infinity * 1px)");
|
||||
testRound("calc(1/round(-5px, -1px/0))", "calc(-infinity * 1px)");
|
||||
test_plus_infinity("round(infinity, 5)");
|
||||
test_plus_infinity("round(infinity, -5)");
|
||||
test_minus_infinity("round(-infinity, 5)");
|
||||
test_minus_infinity("round(-infinity, -5)");
|
||||
|
||||
// Finite value with infinite step depends on rounding strategy.
|
||||
// 'nearest' and 'to-zero': pos and +0 go to +0, neg and -0 go to -0
|
||||
test_plus_zero("round(5, infinity)");
|
||||
test_plus_zero("round(5, -infinity)");
|
||||
test_minus_zero("round(-5, infinity)");
|
||||
test_minus_zero("round(-5, -infinity)");
|
||||
test_plus_zero("round(to-zero, 5, infinity)");
|
||||
test_plus_zero("round(to-zero, 5, -infinity)");
|
||||
test_minus_zero("round(to-zero, -5, infinity)");
|
||||
test_minus_zero("round(to-zero, -5, -infinity)");
|
||||
// 'up': pos goes to +inf, 0+ goes to 0+, else 0-
|
||||
test_plus_infinity("round(up, 1, infinity)");
|
||||
test_plus_zero("round(up, 0, infinity)");
|
||||
test_minus_zero("round(up, -1 * 0, infinity");
|
||||
test_minus_zero("round(up, -1, infinity");
|
||||
// 'down': neg goes to -inf, -0 goes to -0, else 0+
|
||||
test_minus_infinity("round(down, -1, infinity)");
|
||||
test_minus_zero("round(down, -1 * 0, infinity)");
|
||||
test_plus_zero("round(down, 0, infinity)");
|
||||
test_plus_zero("round(down, 1, infinity)");
|
||||
</script>
|
|
@ -1,41 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
CSS Values and Units Test:
|
||||
Viewports units are supported in @viewport rules
|
||||
</title>
|
||||
<meta content="
|
||||
Viewports units are supported in @viewport rules
|
||||
" name="assert">
|
||||
|
||||
<link href="mailto:fremycompany.developer@yahoo.fr" rel="author" title="François REMY">
|
||||
|
||||
<link href="http://www.w3.org/TR/css3-values/#viewport-relative-lengths" rel="help">
|
||||
<link href="https://drafts.csswg.org/css-device-adapt-1/#atviewport-rule" rel="help">
|
||||
|
||||
<link href="reference/vh-support-atviewport-ref.htm" rel="match">
|
||||
|
||||
<style type="text/css">
|
||||
html
|
||||
{
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
background-color: blue;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@viewport
|
||||
{
|
||||
width: 50vw;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body></html>
|
Loading…
Add table
Add a link
Reference in a new issue