summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/css3/device-adapt/viewport-cssom-01.html
blob: 98c99e48d3d1c85016fc80d80ca387780c23d8e4 (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
<!DOCTYPE html>
<html>
<head>
    <title>@viewport CSSOM - set descriptor values</title>
    <script src="../../resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
    <script>
        if (window.testRunner) {
            internals.settings.setViewportEnabled(true);
        }
    </script>
    <style>
        @viewport {
            width: 200px;
        }
    </style>
</head>
<body>
    <div id="log"></div>
    <script>
        test(function(){
            assert_equals(document.styleSheets[0].cssRules.length, 1, "Rule is found");
            assert_equals(document.styleSheets[0].cssRules[0].type, CSSRule.VIEWPORT_RULE, "Rule is of type @viewport");
        }, "@viewport rule exists");

        var rule = document.styleSheets[0].cssRules[0];

        test(function(){
            rule.style.width = "400px";
            assert_equals(rule.style.minWidth, "400px", "min-width is now 400px");
        }, "Setting width shorthand sets min-width");

        test(function(){
            rule.style.height = "900px";
            assert_equals(rule.style.maxHeight, "900px", "max-height is now 900px");
        }, "Setting height shorthand sets max-height");

        test(function(){
            rule.style.cssText = "width: 300px; height: 700px";
            assert_equals(rule.style.minWidth, "300px", "min-width is now 300px");
            assert_equals(rule.style.maxHeight, "700px", "max-height is now 700px");
        }, "Setting cssText of ViewportRule.style parses width/height as shorthands");

        test(function(){
            document.styleSheets[0].insertRule("@viewport { width: 600px; height: 200px }", 0);
            rule = document.styleSheets[0].cssRules[0];
            assert_equals(rule.style.minWidth, "600px", "min-width is now 600px");
            assert_equals(rule.style.maxHeight, "200px", "max-height is now 200px");
        }, "Inserting @viewport rule parses width/height as shorthands");
    </script>
</body>
</html>