page-001.html (1450B)
1 <!DOCTYPE html> 2 <link rel="author" title="Morten Stenshorne" href="mailto:mstensho@chromium.org"> 3 <link rel="help" href="https://drafts.csswg.org/cssom/#the-csspagerule-interface"> 4 <title>Basic CSSPageRule CSSOM test</title> 5 <style id="sheet"> 6 @page {} 7 @page :left {} 8 @page named { margin: 10px 20px; } 9 </style> 10 <script src="/resources/testharness.js"></script> 11 <script src="/resources/testharnessreport.js"></script> 12 <script> 13 var sheet = document.getElementById("sheet").sheet; 14 test(()=> { 15 assert_not_equals(sheet, null); 16 assert_equals(sheet.rules.length, 3); 17 }, "There should be 3 @page rules."); 18 19 test(()=> { 20 assert_equals(sheet.rules[0].constructor.name, "CSSPageRule"); 21 assert_equals(sheet.rules[0].selectorText, ""); 22 assert_equals(sheet.rules[0].style.length, 0); 23 }, "Rule #0"); 24 25 test(()=> { 26 assert_equals(sheet.rules[1].constructor.name, "CSSPageRule"); 27 assert_equals(sheet.rules[1].selectorText, ":left"); 28 assert_equals(sheet.rules[1].style.length, 0); 29 }, "Rule #1"); 30 31 test(()=> { 32 assert_equals(sheet.rules[2].constructor.name, "CSSPageRule"); 33 assert_equals(sheet.rules[2].selectorText, "named"); 34 var style = sheet.rules[2].style; 35 assert_equals(style.length, 4); 36 assert_equals(style.marginTop, "10px"); 37 assert_equals(style.marginRight, "20px"); 38 assert_equals(style.marginBottom, "10px"); 39 assert_equals(style.marginLeft, "20px"); 40 }, "Rule #2"); 41 </script>