summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/nested-at-rules.html
blob: 12164b1e456986a4b090ced66b2d7f00f5170eea (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
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
<style>
.test {
    content: "UNTOUCHED";
}

@media all {
    @media all {
        @font-face {
            src: local('Courier');
            font-family: Courier;
        }

        @page :left { top: 0 }

        #t0 { content: "APPLIED" }

        @import url("../../cssom/resources/import.css");
        @charset "UTF-8";
        @namespace "";
    }
    @media all {
        @media none {
            #t1 { content: "APPLIED" }
        }
    }
}
</style>
<body>
<span id=t0 class=test></span>
<span id=t1 class=test></span>
<script>
description("Test nested at-rules.");

evalAndLog("rules = document.styleSheets[1].cssRules");
shouldEvaluateTo("rules.length", 2);

shouldBe("rules[0].type", "CSSRule.STYLE_RULE");
shouldBe("rules[1].type", "CSSRule.MEDIA_RULE");
shouldEvaluateTo("rules[1].cssRules.length", 2);
shouldBe("rules[1].cssRules[0].type", "CSSRule.MEDIA_RULE");
shouldEvaluateTo("rules[1].cssRules[0].cssRules.length", 3);
shouldBe("rules[1].cssRules[0].cssRules[0].type", "CSSRule.FONT_FACE_RULE");
shouldBe("rules[1].cssRules[0].cssRules[1].type", "CSSRule.PAGE_RULE");
shouldBe("rules[1].cssRules[0].cssRules[2].type", "CSSRule.STYLE_RULE");
shouldBe("rules[1].cssRules[0].cssRules[0].parentStyleSheet", "document.styleSheets[1]");
shouldBe("rules[1].cssRules[0].cssRules[1].parentStyleSheet", "document.styleSheets[1]");
shouldBe("rules[1].cssRules[0].cssRules[2].parentStyleSheet", "document.styleSheets[1]");

shouldBe("rules[1].cssRules[1].type", "CSSRule.MEDIA_RULE");
shouldEvaluateTo("rules[1].cssRules[1].cssRules.length", 1);
shouldBe("rules[1].cssRules[1].cssRules[0].type", "CSSRule.MEDIA_RULE");
evalAndLog("rules[1].cssRules[1].insertRule('@media all { @page :left { top: 0; } }', 1)");
shouldEvaluateTo("rules[1].cssRules[1].cssRules.length", 2);
shouldBe("rules[1].cssRules[1].cssRules[1].type", "CSSRule.MEDIA_RULE");
shouldBe("rules[1].cssRules[1].cssRules[1].cssRules[0].type", "CSSRule.PAGE_RULE");

shouldBeEqualToString("getComputedStyle(document.getElementById('t0')).content", "APPLIED");
shouldBeEqualToString("getComputedStyle(document.getElementById('t1')).content", "UNTOUCHED");
</script>