diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/support/utils.js')
-rw-r--r-- | testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/support/utils.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/support/utils.js b/testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/support/utils.js new file mode 100644 index 0000000000..02d3a095cd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/support/utils.js @@ -0,0 +1,20 @@ +function styleExistsInSheet(styleText, sheet) { + for (let rule of sheet.cssRules) { + if (styleText == rule.cssText) + return true; + if (rule instanceof CSSImportRule) { + if (rule.styleSheet && styleExistsInSheet(styleText, rule.styleSheet)) + return true; + } + } + return false; +} + +function styleExists(styleText) { + for (let sheet of document.styleSheets) { + if (styleExistsInSheet(styleText, sheet)) + return true; + } + return false; +} + |