tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

page-rule-declarations-001.html (1970B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>CSS Paged Media: parsing @page declarations inside @media</title>
      4 <link rel="author" title="Felipe Erias Morandeira" href="mailto:felipeerias@gmail.com"/>
      5 <link rel="help" href="https://drafts.csswg.org/css-page/#at-page-rule"/>
      6 <meta name="assert" content="Test that @page declarations inside @media are parsed correctly.">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 
     10 <style type="text/css">
     11 
     12    @media print {
     13        @page {
     14            margin: 3cm;
     15        }
     16        @page :first {
     17            margin-top: 6cm;
     18        }
     19        @page :left {
     20            color: red;
     21        }
     22        @page :right {
     23            color: blue;
     24        }
     25    }
     26 
     27 </style>
     28 <script type="text/javascript">
     29 
     30    let expectedForSelector = {
     31        "" : "margin: 3cm;",
     32        ":first" : "margin-top: 6cm;",
     33        ":left" : "color: red;",
     34        ":right" : "color: blue;"
     35    };
     36    let styleSheets = document.styleSheets;
     37    for (let i = 0; i < styleSheets.length; i++) {
     38        let rules = styleSheets[i].cssRules;
     39        for (let rule of rules) {
     40            if (rule.type == CSSRule.MEDIA_RULE && rule.conditionText == 'print') {
     41                for (let mediaRule of rule.cssRules) {
     42                    if (mediaRule.type == CSSRule.PAGE_RULE) {
     43                        let expected = expectedForSelector[mediaRule.selectorText];
     44                        test(function(){
     45                            assert_equals(mediaRule.style.cssText, expected, "unexpected @page contents");
     46                        }, "unexpected contents for selector ['" + mediaRule.selectorText + "']");
     47                        delete expectedForSelector[mediaRule.selectorText];
     48                    }
     49                }
     50            }
     51        }
     52    }
     53    test(function() {
     54        assert_equals(Object.keys(expectedForSelector).length, 0, "missing @page selectors in @media");
     55    });
     56 
     57 </script>