File: test_getRelativeRuleLine.html

package info (click to toggle)
firefox 141.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,550,616 kB
  • sloc: cpp: 7,426,508; javascript: 6,367,238; ansic: 3,707,354; python: 1,368,984; xml: 623,983; asm: 426,916; java: 184,324; sh: 64,488; makefile: 19,203; objc: 13,059; perl: 12,955; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,071; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (106 lines) | stat: -rw-r--r-- 2,714 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test InspectorUtils::getRelativeRuleLine</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
  <style>
    @supports (not (whatever: 72 zq)) {
      #test {
        background-color: #f0c;
      }
    }

    #test {
      color: #f0c;
    }
  </style>
  <style>#test { color: red; }</style>
  <style>
     @invalidatkeyword {
     }

     #test {
       color: blue;
     }
  </style>
  <style>#test { color: red; }</style><!-- This tests stylesheet caching -->
  <style>
    #test {
      color: tomato;

      &:where(*) {
        color: gold;

        &:not(.foo) {
          color: plum;
        }

        color: salmon;
      }

      color: blanchedalmond;
      color: snow;

      & > span {
        color: cornflowerblue;
      }

      color: seagreen;
    }
  </style><!-- This tests nesting -->
  <script>
  const InspectorUtils = SpecialPowers.InspectorUtils;

  let tests = [
    { sheetNo: 0, ruleNo: 0, lineNo: 1, columnNo: 1 },
    { sheetNo: 1, ruleNo: 0, lineNo: 2, columnNo: 5 },
    { sheetNo: 1, ruleNo: 1, lineNo: 8, columnNo: 5 },
    { sheetNo: 2, ruleNo: 0, lineNo: 1, columnNo: 1 },
    { sheetNo: 3, ruleNo: 0, lineNo: 5, columnNo: 6 },
    { sheetNo: 4, ruleNo: 0, lineNo: 1, columnNo: 1 },
    { sheetNo: 5, ruleNo: 0, lineNo: 2, columnNo: 5 },
    { sheetNo: 5, ruleNo: [0, 0], lineNo: 5, columnNo: 7 },
    { sheetNo: 5, ruleNo: [0, 0, 0], lineNo: 8, columnNo: 9 },
    { sheetNo: 5, ruleNo: [0, 0, 1], lineNo: 12, columnNo: 9 },
    { sheetNo: 5, ruleNo: [0, 1], lineNo: 15, columnNo: 7 },
    { sheetNo: 5, ruleNo: [0, 2], lineNo: 18, columnNo: 7 },
    { sheetNo: 5, ruleNo: [0, 3], lineNo: 22, columnNo: 7 },
  ];

  function doTest() {
    for (let test of tests) {
      let sheet = document.styleSheets[test.sheetNo];
      let rule;
      if (Array.isArray(test.ruleNo)) {
        for(const index of test.ruleNo) {
          rule = (rule ? rule : sheet).cssRules[index];
        }
      } else {
        rule = sheet.cssRules[test.ruleNo];
      }
      let line = InspectorUtils.getRelativeRuleLine(rule);
      let column = InspectorUtils.getRuleColumn(rule);
      info("testing sheet " + test.sheetNo + ", rule " + test.ruleNo);
      is(line, test.lineNo, "line number is correct");
      is(column, test.columnNo, "column number is correct");
    }

    SimpleTest.finish();
  }

  SimpleTest.waitForExplicitFinish();
  addLoadEvent(doTest);
  </script>
</head>
<body>
<h1>Test InspectorUtils::getRelativeRuleLine</h1>
<p id="display"></p>
<div id="content" style="display: none">

</div>
<pre id="test">
</pre>
</body>
</html>