summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/computed-offset-with-zoom.html
blob: 27d8be4f39b3359f272f64b146caec1a4a90e1dc (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
    <head>
        <style>
            #container {
                width: 500px;
                height: 500px;
                position: relative;
            }
            #container > div {
                position: relative;
                border: 1px solid red;
                font-size: 20px;
                width: 100px;
                height: 100px;
            }
            #test-fixed  {
                left: 100px;
                right: 100px;
                top: 100px;
                bottom: 100px;
            }
            #test-percentage {
                left: 20%;
                right: 20%;
                top: 10%;
                bottom: 10%;
            }
            #test-viewport {
                left: 10vw;
                right: 10vw;
                top: 10vh;
                bottom: 10vh;
            }
        </style>
        <script src="../../resources/js-test.js"></script>
    </head>
    <body>
        <p>
            Reported computed offset should not change with zoom level.
        </p>
        <div id="container">
            <div id="test-fixed"></div>
            <div id="test-percentage"></div>
            <div id="test-viewport"></div>
        </div>
        <script>
            var fixedElement = document.getElementById('test-fixed');
            var percentageElement = document.getElementById('test-percentage');
            var viewportElement = document.getElementById('test-viewport');
            function test(zoomLevel)
            {
                    document.body.style.zoom = zoomLevel;
                    var windowWidth = "'" + (window.innerWidth / 10) + "px'";
                    var windowHeight = "'" + (window.innerHeight / 10) + "px'";
                    
                    shouldBe("window.getComputedStyle(fixedElement).top", "'100px'");
                    shouldBe("window.getComputedStyle(fixedElement).right", "'100px'");
                    shouldBe("window.getComputedStyle(fixedElement).bottom", "'100px'");
                    shouldBe("window.getComputedStyle(fixedElement).left", "'100px'");
                    
                    shouldBe("window.getComputedStyle(percentageElement).top", "'50px'");
                    shouldBe("window.getComputedStyle(percentageElement).right", "'100px'");
                    shouldBe("window.getComputedStyle(percentageElement).bottom", "'50px'");
                    shouldBe("window.getComputedStyle(percentageElement).left", "'100px'");
                    
                    shouldBe("window.getComputedStyle(viewportElement).top", windowHeight);
                    shouldBe("window.getComputedStyle(viewportElement).right", windowWidth);
                    shouldBe("window.getComputedStyle(viewportElement).bottom", windowHeight);
                    shouldBe("window.getComputedStyle(viewportElement).left", windowWidth);
            }
            test(0.5);
            test(1.25);
            test(1.0);
        </script>
    </body>
</html>