Skip to content

Commit d98f0cc

Browse files
emiliomoz-wptsync-bot
authored andcommitted
Fix scroll-offsets-fractional-zoom.html.
See the comment. Differential Revision: https://phabricator.services.mozilla.com/D238883 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1946100 gecko-commit: f7a82902d25fab7bdb9694f152585ec41779604b gecko-reviewers: rego
1 parent b26ba1d commit d98f0cc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

css/cssom-view/scroll-offsets-fractional-zoom.html

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1">
34
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]">
45
<link rel="help" href="https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface">
56
<meta name="assert" content="This test checks that the scroll offsets behave as expected on fractional zoom situations.">
@@ -22,12 +23,17 @@
2223
</div>
2324
<script>
2425
function runTest(zoom, x, y) {
26+
// Scroll offsets might be snapped to device pixels for performance or
27+
// rendering quality. Since scroll{Top,Left} round, we need to allow up to
28+
// 1px of difference with the expected value.
29+
const EPSILON = 1;
30+
2531
target.scrollTo(x, y);
2632
test(() => {
27-
assert_equals(target.scrollLeft, x, `scrollLeft should be ${x}`);
33+
assert_approx_equals(target.scrollLeft, x, EPSILON, `scrollLeft should be ${x}`);
2834
}, `scrollLeft after scrollTo(${x}, ${y}) with 'zoom: ${zoom}'`);
2935
test(() => {
30-
assert_equals(target.scrollTop, y, `scrollTop should be ${y}`);
36+
assert_approx_equals(target.scrollTop, y, EPSILON, `scrollTop should be ${y}`);
3137
}, `scrollTop after scrollTo(${x}, ${y}) with 'zoom: ${zoom}'`);
3238
}
3339

0 commit comments

Comments
 (0)