summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/css3/device-adapt/viewport-at-rule-parsing.html
blob: 9f4f7783815c16d2e8cb08bcf595b76d5c8c387a (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
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        /* Valid viewport syntax. */
        @viewport {
        }

        /* Valid viewport syntax, extras spaces should be ignored. */
        @viewport          {
        }

        /* Valid viewport syntax, regular attributes. */
        @viewport {
            max-height: 200px;
            min-height: 200px;
        }

        /* Valid viewport syntax, should omit the malformed attribute. */
        @viewport {
            asdasd
        }

        /* Valid viewport syntax, it is allowed inside media queries. */
        @media all {
            @viewport {
            }
        }

        /* Nested viewport rules are not allowed. The inner rule should be ignored. */
        @viewport {
            max-height: 100px;
            min-height: 100px;

            @viewport {
                max-height: 200px;
                min-height: 200px;
            }
        }

        /* Rules inside a viewport should be ignored. */
        @viewport {
            max-height: 50px;
            min-height: 50px;

            @import url('../../resources/testharness.css');
        }
    </style>
    <meta charset="utf-8" />
    <link rel="help" href="http://www.w3.org/TR/css-device-adapt/#syntax" />
    <script src="../../resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
    <script type="text/javascript">
        var rules = document.styleSheets[0].cssRules;

        test(function() {
            assert_equals(rules.item(0).cssText, "@viewport { }");
        }, "Empty at-rule parsing");

        test(function() {
            assert_equals(rules.item(1).cssText, "@viewport { }");
        }, "at-rule with extra spaces");

        test(function() {
            assert_equals(rules.item(2).cssText, "@viewport { max-height: 200px; min-height: 200px; }");
        }, "Rule with attributes");

        test(function() {
            assert_equals(rules.item(3).cssText, "@viewport { }");
        }, "Rule with malformed attributes");

        test(function() {
            assert_equals(rules.item(4).cssText, "@media all { \n  @viewport { }\n}");
        }, "Should be accepted inside media queries");

        test(function() {
            assert_equals(rules.item(5).cssText, "@viewport { max-height: 100px; min-height: 100px; }");
        }, "Nested viewport rule");

        test(function() {
            assert_equals(rules.item(6).cssText, "@viewport { max-height: 50px; min-height: 50px; }");
        }, "Rules inside a viewport rule");
    </script>
</head>
<body>
    <div id="log"></div>
</body>
</html>