tor-browser

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

page-rule-declarations-003.html (2309B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>CSS Paged Media: parsing @page selectors</title>
      4 <link rel="author" title="Mozilla" href="https://mozilla.org"/>
      5 <link rel="help" href="https://drafts.csswg.org/css-page/#page-selectors"/>
      6 <meta name="assert" content="Test that @page selectors are parsed correctly.">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 
     10 <style>
     11    @page a, B {
     12        size: 1in;
     13    }
     14    @page A,b,C {
     15        size: 2in;
     16    }
     17    @page auto {
     18        size: 3in;
     19    }
     20    @page something, auto {
     21        size: 4in;
     22    }
     23    @page auto, other_thing {
     24        size: 5in;
     25    }
     26    @page _a, Z {
     27        size: 6in;
     28    }
     29    @page -b, y {
     30        size: 7in;
     31    }
     32    @page _abcd {
     33        size: 8in;
     34    }
     35    @page n,-XYZ {
     36        size: 9in;
     37    }
     38 </style>
     39 
     40 <script>
     41    let expectedForSelector = {
     42        "a, B" : "size: 1in;",
     43        "A, b, C" : "size: 2in;",
     44        "auto" : "size: 3in;",
     45        "something, auto" : "size: 4in;",
     46        "auto, other_thing" : "size: 5in;",
     47        "_a, Z" : "size: 6in;",
     48        "-b, y" : "size: 7in;",
     49        "_abcd" : "size: 8in;",
     50        "n, -XYZ" : "size: 9in;"
     51    };
     52    let styleSheets = document.styleSheets;
     53    for (let sheet of styleSheets) {
     54        let rules = sheet.cssRules;
     55        for (let rule of rules) {
     56            if (rule.type == CSSRule.PAGE_RULE) {
     57                let expected = expectedForSelector[rule.selectorText];
     58                test(function(){
     59                    assert_equals(rule.style.cssText, expected, "unexpected @page contents");
     60                }, "contents for selector ['" + rule.selectorText + "']");
     61                delete expectedForSelector[rule.selectorText];
     62            }
     63        }
     64    }
     65    // Validate that we can assign an empty selector
     66    test(function() {
     67        let rule = styleSheets[0].cssRules[0];
     68        assert_equals(rule.type, CSSRule.PAGE_RULE, "expected first rule to be @page");
     69        rule.selectorText = "";
     70        assert_equals(rule.selectorText, "", "unexpected selector when assigning blank string");
     71    }, "expected empty selector when assigning blank string");
     72    test(function() {
     73        assert_equals(Object.keys(expectedForSelector).length, 0, "missing @page selectors");
     74    });
     75 </script>