summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/window-scroll-scaling.html
blob: 0f138f900cdd566ac2b6f881b298230826da4fe1 (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
<html>
<body>
    <script src="../../resources/js-test.js"></script>
    <script>
        description("This test ensures that document content width (height) as reported by scrollWidth (scrollHeight) is invariant to changes in page scale factor.");

        if (window.internals)
            window.internals.settings.setMockScrollbarsEnabled(true);

        var body = document.body;

        // According to CSSOM (http://dev.w3.org/csswg/cssom-view/#dom-element-scrollwidth)
        // the scrollWidth of the body element (in Quirks mode) is defined as
        //    max(document content width, value of innerWidth).
        // In this test, we want to measure the document content width (height),
        // rather than innerWidth (innerHeight), so we make the body element
        // larger than the innerWidth (innerHeight).

        body.style["width"] = window.innerWidth + 100 + "px";
        body.style["height"] = window.innerHeight + 100 + "px";

        var originalScrollWidth = body.scrollWidth;
        var originalScrollHeight = body.scrollHeight;

        var scale = 1.1;
        if (window.eventSender)
            window.internals.setPageScaleFactor(scale);

        // As we have increased the scale factor, the innerWidth will be less
        // as fewer CSS pixels will be rendered in the same viewport, so
        // body.scrollWidth (scrollHeight) will still be measuring the document
        // content width (height).

        shouldBe("body.scrollWidth", "originalScrollWidth");
        shouldBe("body.scrollHeight", "originalScrollHeight");
    </script>
</body>
</html>