test_get_all_style_sheets.html (1184B)
1 <!DOCTYPE HTML> 2 <!-- 3 https://bugzilla.mozilla.org/show_bug.cgi?id=734861 4 --> 5 <meta charset="utf-8"> 6 <title>Test for Bug 734861</title> 7 <script src="/tests/SimpleTest/SimpleTest.js"></script> 8 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 9 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=734861">Mozilla Bug 734861</a> 10 <div id="host"></div> 11 <script> 12 /** Test for Bug 734861 */ 13 const InspectorUtils = SpecialPowers.InspectorUtils; 14 15 add_task(async function() { 16 let sheet = new CSSStyleSheet(); 17 await sheet.replace(`* { color: blue }`); 18 19 let host = document.querySelector("#host"); 20 host.adoptedStyleSheets = [sheet, sheet]; 21 document.adoptedStyleSheets.push(sheet); 22 23 let res = InspectorUtils.getAllStyleSheets(document); 24 25 let foundUA = false; 26 let adoptedCount = 0; 27 for (let s of InspectorUtils.getAllStyleSheets(document)) { 28 if (SpecialPowers.unwrap(s) == sheet) { 29 adoptedCount++; 30 } 31 if (s.href === "resource://gre-resources/ua.css") { 32 foundUA = true; 33 } 34 } 35 36 ok(foundUA, "UA sheet should be returned with all the other sheets."); 37 is(adoptedCount, 1, "Adopted stylesheet should show up once"); 38 }); 39 </script>