summaryrefslogtreecommitdiffstats
path: root/layout/reftests/async-scrolling/disable-apz-for-sle-pages.html
blob: 8db572f7a7ee4a681ae10010bd4841e493ec9961 (plain)
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
<!DOCTYPE html>
<html class="reftest-wait reftest-snapshot-all reftest-no-flush" reftest-async-scroll
      reftest-async-scroll-y="200">
 <head>
  <title>Check that the apz.disable_for_sle_pages pref behaves as expected</title>
  <script>
    // Upon load, this page invokes scrollTo() for a transparent element
    // repeatedly. It triggers scroll events, which run the scroll listener
    // below. The scroll listener updates the background-position-x of the div
    // to make the div a scroll-linked-effect. The scroll-linked effect detector
    // should then report that the document contains such an effect, which will
    // disable APZ on the page. That in turn will cause the
    // reftest-async-scroll-y to get ignored, and that's what the reftest checks
    // for.

    function start() {
        let scrollPosition = 1;

        scroller.addEventListener('scroll', function() {
            // NOTE: Changing background-position-x doesn't change rendering for
            // this element.
            document.getElementById('scroll-linked-effect').style.backgroundPositionX =
                scroller.scrollTop + "px";
            if (scrollPosition == 1) {
              setTimeout(done, 0);
            }
            scrollPosition++;
            scroller.scrollTo(0, scrollPosition);
        });

        scroller.scrollTo(0, scrollPosition);
    }
    addEventListener('load', start, false);

    function done() {
        document.documentElement.classList.remove('reftest-wait');
    }
  </script>
 </head>
 <body style="height: 5000px; background-image:url(repeatable-diagonal-gradient.png);">
  <div id="scroller" style="overflow: auto; width: 100px; height: 100px; scrollbar-width: none;">
    <div style="height: 5000px;"></div>
  </div>
  <div id="scroll-linked-effect" style="position: absolute; top: 100px; left: 100px; width: 100px; height: 100px; background-color: green"></div>
 </body>
</html>