summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/css3/device-adapt/viewport-delete-rule.html
blob: 159f35269ca3470869ece2e03f8079861e160cd4 (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
<!DOCTYPE html>
<html>
<head>
    <title>Insert and delete @viewport rule</title>
    <script src="../../resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
    <style>
        html { width: 100%; height: 100%; }
    </style>
    <script>
        if (window.testRunner) {
            internals.settings.setViewportEnabled(true);
        }

        var t1 = async_test("Check that added @viewport rule is applied.");
        var t2 = async_test("Check that @viewport rule is not applied after removal.");

        onload = function(){

            var origWidth = document.documentElement.offsetWidth;
            var origHeight = document.documentElement.offsetHeight;

            document.styleSheets[0].insertRule("@viewport { width: 400px; height: 400px; }", 0);

            t1.step(function(){
               assert_equals(document.documentElement.offsetWidth, 400, "Width is 400px.");
               assert_equals(document.documentElement.offsetHeight, 400, "Height is 400px.");
            });
            t1.done();

            document.styleSheets[0].deleteRule(0);

            t2.step(function(){
               assert_equals(document.documentElement.offsetWidth, origWidth, "Width is default width.");
               assert_equals(document.documentElement.offsetHeight, origHeight, "Height is default height.");
            });
            t2.done();
        };
    </script>
</head>
<body style="overflow: hidden">
    <div id="log"></div>
</body>
</html>