blob: 91c7b4d55973dad11a84ebdb83b4da1aeb901075 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style>
.test {
background-color: blue;
}
@media all {
@media all {
@font-face {
src: local('Courier');
font-family: Courier;
}
@page :left { top: 0 }
#t0 { background-color: green; }
@import url("../../cssom/resources/import.css");
@charset "UTF-8";
@namespace "";
}
@media all {
@media none {
#t1 { background-color: green; }
}
}
}
</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')).backgroundColor", 'rgb(0, 128, 0)');
shouldBeEqualToString("getComputedStyle(document.getElementById('t1')).backgroundColor", 'rgb(0, 0, 255)');
</script>