/third_party/blink/web_tests/external/wpt/css/cssom/insertRule-across-context.html

https://github.com/chromium/chromium · HTML · 32 lines · 28 code · 4 blank · 0 comment · 0 complexity · 74a0fa0bdcc1e8228e3c9f7b2dd45afc MD5 · raw file

  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. <iframe id="iframe"></iframe>
  10. <script>
  11. function createSheet() {
  12. const tempStyleElement = iframe.contentDocument.createElement('style');
  13. iframe.contentDocument.head.append(tempStyleElement);
  14. const tempStyle = tempStyleElement.sheet;
  15. tempStyleElement.remove();
  16. return tempStyle;
  17. }
  18. test(() => {
  19. const sheet = createSheet();
  20. sheet.insertRule(".kaoru {}");
  21. assert_equals(sheet.rules[0].constructor, iframe.contentWindow.CSSStyleRule);
  22. }, "The constructor of inserted rule object must be from iframe");
  23. test(() => {
  24. const sheet = new iframe.contentWindow.CSSStyleSheet();
  25. sheet.insertRule(".kaoru {}");
  26. assert_equals(sheet.rules[0].constructor, iframe.contentWindow.CSSStyleRule);
  27. }, "The constructor of inserted rule object must be from iframe for new CSSStyleSheet()");
  28. </script>