insertRule-across-context.html (1303B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>CSS Test: CSSOM StyleSheet insertRule across context</title> 4 <link rel="author" title="Kagami Sascha Rosylight" href="mailto:saschanaz@outlook.com"> 5 <link rel="author" title="Mozilla" href="https://mozilla.org"> 6 <link rel="help" href="https://drafts.csswg.org/cssom/"> 7 <script src="/resources/testharness.js" type="text/javascript"></script> 8 <script src="/resources/testharnessreport.js" type="text/javascript"></script> 9 10 <iframe id="iframe"></iframe> 11 <script> 12 function createSheet() { 13 const tempStyleElement = iframe.contentDocument.createElement('style'); 14 iframe.contentDocument.head.append(tempStyleElement); 15 16 const tempStyle = tempStyleElement.sheet; 17 tempStyleElement.remove(); 18 return tempStyle; 19 } 20 21 test(() => { 22 const sheet = createSheet(); 23 sheet.insertRule(".kaoru {}"); 24 assert_equals(sheet.rules[0].constructor, iframe.contentWindow.CSSStyleRule); 25 }, "The constructor of inserted rule object must be from iframe"); 26 27 test(() => { 28 const sheet = new iframe.contentWindow.CSSStyleSheet(); 29 sheet.insertRule(".kaoru {}"); 30 assert_equals(sheet.rules[0].constructor, iframe.contentWindow.CSSStyleRule); 31 }, "The constructor of inserted rule object must be from iframe for new CSSStyleSheet()"); 32 </script>