File: scroll-offsets-fractional-zoom.html

package info (click to toggle)
thunderbird 1%3A144.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,725,312 kB
  • sloc: cpp: 7,869,225; javascript: 5,974,276; ansic: 3,946,747; python: 1,421,062; xml: 654,642; asm: 474,045; java: 183,117; sh: 110,973; makefile: 20,398; perl: 14,362; objc: 13,086; yacc: 4,583; pascal: 3,448; lex: 1,720; ruby: 999; exp: 762; sql: 731; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (58 lines) | stat: -rw-r--r-- 1,756 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
<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) {
    // Scroll offsets might be snapped to device pixels for performance or
    // rendering quality. Since scroll{Top,Left} round, we need to allow up to
    // 1px of difference with the expected value.
    const EPSILON = 1;

    target.scrollTo(x, y);
    test(() => {
      assert_approx_equals(target.scrollLeft, x, EPSILON, `scrollLeft should be ${x}`);
    }, `scrollLeft after scrollTo(${x}, ${y}) with 'zoom: ${zoom}'`);
    test(() => {
      assert_approx_equals(target.scrollTop, y, EPSILON, `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>