summaryrefslogtreecommitdiffstats
path: root/layout/base/tests/test_bug416896.html
blob: d7742327568dafca7523ced0b9ec6b20fa9d5e38 (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
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=416896
-->
<head>
  <title>Test for Bug 416896</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <link rel="stylesheet" type="text/css" id="l"
        href="data:text/css,a { color: green }"/>
  <style type="text/css" id="i"> a { color: blue; } </style>
   
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=416896">Mozilla Bug 416896</a>
<p id="display"></p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 416896 **/
 var inlineSheet = $("i").sheet;
 isnot(inlineSheet, null, "Should have sheet here");

 var linkedSheet = $("l").sheet;
 isnot(linkedSheet, null, "Should have sheet here");

 var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
                             .getService(SpecialPowers.Ci.inIDOMUtils);
 const nsIDOMCSSStyleRule = SpecialPowers.Ci["nsIDOMCSSStyleRule"];
 var inspectedRules = domUtils.getCSSStyleRules(document.links[0]);

 var seenInline = false;
 var seenLinked = false;
 
 for (var i = 0; i < inspectedRules.Count(); ++i)
 {
   var rule =
     SpecialPowers.unwrap(inspectedRules.GetElementAt(i).QueryInterface(nsIDOMCSSStyleRule));
   var sheet = rule.parentStyleSheet;
   if (sheet == inlineSheet) {
     is(sheet.href, null, "It's an inline sheet");
     is(seenInline, false, "Only one inline rule matches");
     seenInline = true;
   } else {
     isnot(sheet.href, null, "Shouldn't have null href here");
     if (sheet == linkedSheet) {
       is(seenLinked, false, "Only one linked rule matches");
       seenLinked = true;
     }
   }
 }

 is(seenLinked, true, "Didn't find the linked rule?");
 is(seenInline, true, "Didn't find the inline rule?");


</script>
</pre>
</body>
</html>