Bug 1889896 - Improve media-progress-computed.tentative.html to not have test names that depend on the viewport size. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D206771
This commit is contained in:
Emilio Cobos Álvarez 2024-04-05 23:15:58 +00:00
parent e0900dc042
commit 1da183580e
2 changed files with 24 additions and 52 deletions

View File

@ -1,5 +1,5 @@
[media-progress-computed.tentative.html]
[media-progress(height from 0px to 1px) should be used-value-equivalent to 1136]
[media-progress() identity check]
expected: FAIL
[media-progress(height from media-progress(height from 0px to 1px) * 1px to media-progress(height from 0px to 1px) * 1px) should be used-value-equivalent to 0]
@ -8,53 +8,17 @@
[media-progress(height from media-progress(height from 0px to 1px) * 0.5px to media-progress(height from 0px to 1px) * 1px) should be used-value-equivalent to 1]
expected: FAIL
[calc(media-progress(width from 0px to 50px) * 10px + 100px) should be used-value-equivalent to 260px]
[media-progress() with length product]
expected: FAIL
[calc(media-progress(height from 10px to sign(50px - 500em) * 10px)) should be used-value-equivalent to -56.3]
[media-progress with complex to calculation]
expected: FAIL
[calc(media-progress(width from 0px to 1px) * 1px) should be used-value-equivalent to 800px]
[media-progress() as length]
expected: FAIL
[calc(media-progress(height from 0px to 1px) * 1s) should be used-value-equivalent to 1136s]
[media-progress() as time]
expected: FAIL
[calc(media-progress(width from 0px to 1px) * 1deg) should be used-value-equivalent to 800deg]
expected: FAIL
[media-progress(height from 0px to 1px) should be used-value-equivalent to 891]
expected: FAIL
[calc(media-progress(width from 0px to 50px) * 10px + 100px) should be used-value-equivalent to 356px]
expected: FAIL
[calc(media-progress(height from 10px to sign(50px - 500em) * 10px)) should be used-value-equivalent to -44.05]
expected: FAIL
[calc(media-progress(width from 0px to 1px) * 1px) should be used-value-equivalent to 1280px]
expected: FAIL
[calc(media-progress(height from 0px to 1px) * 1s) should be used-value-equivalent to 891s]
expected: FAIL
[calc(media-progress(width from 0px to 1px) * 1deg) should be used-value-equivalent to 1280deg]
expected: FAIL
[media-progress(height from 0px to 1px) should be used-value-equivalent to 955]
expected: FAIL
[calc(media-progress(height from 10px to sign(50px - 500em) * 10px)) should be used-value-equivalent to -47.25]
expected: FAIL
[calc(media-progress(height from 0px to 1px) * 1s) should be used-value-equivalent to 955s]
expected: FAIL
[calc(media-progress(height from 0px to 1px) * 1s) should be used-value-equivalent to 866s]
expected: FAIL
[calc(media-progress(height from 10px to sign(50px - 500em) * 10px)) should be used-value-equivalent to -42.8]
expected: FAIL
[media-progress(height from 0px to 1px) should be used-value-equivalent to 866]
[media-progress() as angle]
expected: FAIL

View File

@ -1,4 +1,5 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="help" href="https://drafts.csswg.org/css-values-5/#media-progress-func">
<link rel="author" title="sakhapov@chromium.org">
<script src="/resources/testharness.js"></script>
@ -9,26 +10,33 @@
#target {
font-size: 10px;
}
:root {
width: 100vw;
height: 100vh;
}
</style>
<script>
let width = window.innerWidth;
let height = window.innerHeight;
// innerWidth and innerHeight have lossy precision, see
// https://github.com/w3c/csswg-drafts/issues/5260.
let { width, height } = document.documentElement.getBoundingClientRect();
// Identity tests
test_math_used('media-progress(height from 0px to 1px)', height, {type:'number'});
// NOTE(emilio): We provide custom messages so that the test name doesn't
// depend on the viewport size (since in testharness.js files the viewport size is
// not guaranteed to be fixed, unlike in reftests).
test_math_used('media-progress(height from 0px to 1px)', height, { type:'number', 'msg': 'media-progress() identity check' });
// Nestings
test_math_used('media-progress(height from media-progress(height from 0px to 1px) * 1px to media-progress(height from 0px to 1px) * 1px)', '0', {type:'number'});
test_math_used('media-progress(height from media-progress(height from 0px to 1px) * 0.5px to media-progress(height from 0px to 1px) * 1px)', '1', {type:'number'});
// General calculations
test_math_used('calc(media-progress(width from 0px to 50px) * 10px + 100px)', (width / 50 * 10 + 100) + 'px');
test_math_used('calc(media-progress(height from 10px to sign(50px - 500em) * 10px))', (height - 10) / (-10 - 10), {type:'number'});
// General calculations.
test_math_used('calc(media-progress(width from 0px to 50px) * 10px + 100px)', (width / 50 * 10 + 100) + 'px', { msg: 'media-progress() with length product' });
test_math_used('calc(media-progress(height from 10px to sign(50px - 500em) * 10px))', (height - 10) / (-10 - 10), { type:'number', msg: 'media-progress with complex to calculation' });
// Type checking
test_math_used('calc(media-progress(width from 0px to 1px) * 1px)', width + 'px');
test_math_used('calc(media-progress(height from 0px to 1px) * 1s)', height + 's', {type:'time'});
test_math_used('calc(media-progress(width from 0px to 1px) * 1deg)', width + 'deg', {type:'angle', approx:0.001});
test_math_used('calc(media-progress(width from 0px to 1px) * 1px)', width + 'px', { msg: 'media-progress() as length' });
test_math_used('calc(media-progress(height from 0px to 1px) * 1s)', height + 's', { type:'time', msg: 'media-progress() as time' });
test_math_used('calc(media-progress(width from 0px to 1px) * 1deg)', width + 'deg', { type:'angle', approx:0.001, msg: 'media-progress() as angle' });
</script>