StyleSheetList.html (1522B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>CSSOM - StyleSheetList interface</title> 6 <link rel="help" href="https://drafts.csswg.org/cssom/#the-stylesheetlist-interface"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <style> 10 body { width: 50%; } 11 </style> 12 <style> 13 #foo { width: 10%; } 14 #bar { height: 100px; } 15 </style> 16 <script> 17 test(function () { 18 var styleSheets = document.styleSheets; 19 assert_equals(styleSheets.length, 2, "StyleSheetList length attribute"); 20 assert_equals(styleSheets[0].cssRules.length, 1, "StyleSheetList indexed getter length attribute"); 21 assert_equals(styleSheets[1].cssRules.length, 2, "StyleSheetList indexed getter length attribute"); 22 assert_equals(styleSheets[2], undefined, "StyleSheetList indexed getter length attribute"); 23 assert_equals(styleSheets.item(0).cssRules.length, 1, "StyleSheetList item function length attribute"); 24 assert_equals(styleSheets.item(1).cssRules.length, 2, "StyleSheetList item function length attribute"); 25 assert_equals(styleSheets.item(2), null, "StyleSheetList item function length attribute"); 26 27 styleSheets[0].randomProperty = 1; 28 var style = document.createElement("style"); 29 document.head.appendChild(style); 30 assert_equals(styleSheets[0].randomProperty, 1, "[SameObject] StyleSheetList"); 31 }); 32 </script> 33 </head> 34 </html>