summaryrefslogtreecommitdiffstats
path: root/layout/inspector/tests/test_getRelativeRuleLine.html
blob: a1481a49d06627c29b74c8afc603605692770fe0 (plain)
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
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test inDOMUtils::getRelativeRuleLine</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" 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>
  <script type="application/javascript;version=1.8">
  let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
                           .getService(SpecialPowers.Ci.inIDOMUtils);

  let tests = [
    { sheetNo: 0, ruleNo: 0, lineNo: 1, columnNo: 1 },
    { sheetNo: 1, ruleNo: 0, lineNo: 2, columnNo: 15 },
    { sheetNo: 1, ruleNo: 1, lineNo: 8, columnNo: 5 },
    { sheetNo: 2, ruleNo: 0, lineNo: 1, columnNo: 1 },
    { sheetNo: 2, ruleNo: 1, lineNo: 0, columnNo: 1 },
    { sheetNo: 3, ruleNo: 0, lineNo: 5, columnNo: 6 },
  ];

  function doTest() {
    document.styleSheets[2].insertRule("body{}", 1);
    for (let test of tests) {
      let sheet = document.styleSheets[test.sheetNo];
      let rule = sheet.cssRules[test.ruleNo];
      let line = utils.getRelativeRuleLine(rule);
      let column = utils.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 inDOMUtils::getRelativeRuleLine</h1>
<p id="display"></p>
<div id="content" style="display: none">

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