PageRenderTime 59ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/third_party/blink/web_tests/external/wpt/css/css-page/page-rule-declarations-001.html

https://github.com/chromium/chromium
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
  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. <style type="text/css">
  10. @media print {
  11. @page {
  12. margin: 3cm;
  13. }
  14. @page :first {
  15. margin-top: 6cm;
  16. }
  17. @page :left {
  18. color: red;
  19. }
  20. @page :right {
  21. color: blue;
  22. }
  23. }
  24. </style>
  25. <script type="text/javascript">
  26. let expectedForSelector = {
  27. "" : "margin: 3cm;",
  28. ":first" : "margin-top: 6cm;",
  29. ":left" : "color: red;",
  30. ":right" : "color: blue;"
  31. };
  32. let styleSheets = document.styleSheets;
  33. for (let i = 0; i < styleSheets.length; i++) {
  34. let rules = styleSheets[i].cssRules;
  35. for (let rule of rules) {
  36. if (rule.type == CSSRule.MEDIA_RULE && rule.conditionText == 'print') {
  37. for (let mediaRule of rule.cssRules) {
  38. if (mediaRule.type == CSSRule.PAGE_RULE) {
  39. let expected = expectedForSelector[mediaRule.selectorText];
  40. test(function(){
  41. assert_equals(mediaRule.style.cssText, expected, "unexpected @page contents");
  42. }, "unexpected contents for selector ['" + mediaRule.selectorText + "']");
  43. delete expectedForSelector[mediaRule.selectorText];
  44. }
  45. }
  46. }
  47. }
  48. }
  49. test(function() {
  50. assert_equals(Object.keys(expectedForSelector).length, 0, "missing @page selectors in @media");
  51. });
  52. </script>