/third_party/blink/web_tests/external/wpt/css/css-page/page-rule-declarations-001.html
HTML | 57 lines | 52 code | 5 blank | 0 comment | 0 complexity | 7b5f93eb935e56fb5559fec0a4e3c2dd MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0, BSD-3-Clause
- <!doctype html>
- <meta charset="utf-8">
- <title>CSS Paged Media: parsing @page declarations inside @media</title>
- <link rel="author" title="Felipe Erias Morandeira" href="mailto:felipeerias@gmail.com"/>
- <link rel="help" href="https://drafts.csswg.org/css-page/#at-page-rule"/>
- <meta name="assert" content="Test that @page declarations inside @media are parsed correctly.">
- <script src="/resources/testharness.js"></script>
- <script src="/resources/testharnessreport.js"></script>
- <style type="text/css">
- @media print {
- @page {
- margin: 3cm;
- }
- @page :first {
- margin-top: 6cm;
- }
- @page :left {
- color: red;
- }
- @page :right {
- color: blue;
- }
- }
- </style>
- <script type="text/javascript">
- let expectedForSelector = {
- "" : "margin: 3cm;",
- ":first" : "margin-top: 6cm;",
- ":left" : "color: red;",
- ":right" : "color: blue;"
- };
- let styleSheets = document.styleSheets;
- for (let i = 0; i < styleSheets.length; i++) {
- let rules = styleSheets[i].cssRules;
- for (let rule of rules) {
- if (rule.type == CSSRule.MEDIA_RULE && rule.conditionText == 'print') {
- for (let mediaRule of rule.cssRules) {
- if (mediaRule.type == CSSRule.PAGE_RULE) {
- let expected = expectedForSelector[mediaRule.selectorText];
- test(function(){
- assert_equals(mediaRule.style.cssText, expected, "unexpected @page contents");
- }, "unexpected contents for selector ['" + mediaRule.selectorText + "']");
- delete expectedForSelector[mediaRule.selectorText];
- }
- }
- }
- }
- }
- test(function() {
- assert_equals(Object.keys(expectedForSelector).length, 0, "missing @page selectors in @media");
- });
- </script>