-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for scroll offsets with fractional zoom
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:[email protected]"> | ||
<link rel="help" href="https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface"> | ||
<meta name="assert" content="This test checks that the scroll offsets behave as expected on fractional zoom situations."> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
.scrollable-area { | ||
width: 100px; | ||
height: 100px; | ||
overflow: scroll; | ||
} | ||
.content { | ||
width: 500px; | ||
height: 500px; | ||
background: lightgrey; | ||
} | ||
</style> | ||
<div id="target" class="scrollable-area"> | ||
<div class="content"></div> | ||
</div> | ||
<script> | ||
function runTest(zoom, x, y) { | ||
target.scrollTo(x, y); | ||
test(() => { | ||
assert_equals(target.scrollLeft, x, `scrollLeft should be ${x}`); | ||
}, `scrollLeft after scrollTo(${x}, ${y}) with 'zoom: ${zoom}'`); | ||
test(() => { | ||
assert_equals(target.scrollTop, y, `scrollTop should be ${y}`); | ||
}, `scrollTop after scrollTo(${x}, ${y}) with 'zoom: ${zoom}'`); | ||
} | ||
|
||
function runTests(zoom) { | ||
target.style.zoom = zoom; | ||
|
||
runTest(zoom, 0, 0); | ||
runTest(zoom, 1, 2); | ||
runTest(zoom, 13, 61); | ||
runTest(zoom, 75, 100); | ||
} | ||
|
||
runTests(0.75); | ||
runTests(0.9); | ||
runTests(1); | ||
runTests(1.13); | ||
runTests(1.25); | ||
runTests(1.5); | ||
runTests(1.9); | ||
runTests(2); | ||
runTests(3.33); | ||
</script> |