summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/document-metadata/interactions-of-styling-and-scripting/support/utils.js
blob: 02d3a095cd18110afa6502346521174d4f2b8402 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
}