2008-02-19 10:15:45 -08:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=416896
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 416896</title>
|
|
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
|
|
<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 **/
|
2009-03-30 08:25:35 -07:00
|
|
|
// Ensure all of our sheets have unique inners and trigger a rule cascade
|
|
|
|
// reconstruct for each of them, so that all the rules the inspector APIs see
|
|
|
|
// will have the right parents. This is basicaly working around bug 253354.
|
|
|
|
for (var sheetIdx = 0; sheetIdx < document.styleSheets.length; ++sheetIdx) {
|
|
|
|
document.styleSheets[sheetIdx].insertRule("dummy {}", 0);
|
|
|
|
}
|
|
|
|
|
2008-02-19 10:15:45 -08:00
|
|
|
var inlineSheet = $("i").sheet;
|
|
|
|
isnot(inlineSheet, null, "Should have sheet here");
|
|
|
|
|
|
|
|
var linkedSheet = $("l").sheet;
|
|
|
|
isnot(linkedSheet, null, "Should have sheet here");
|
|
|
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
|
|
var domUtils = Components.classes["@mozilla.org/inspector/dom-utils;1"]
|
|
|
|
.getService(Components.interfaces.inIDOMUtils);
|
|
|
|
const nsIDOMCSSStyleRule = Components.interfaces["nsIDOMCSSStyleRule"];
|
|
|
|
var inspectedRules = domUtils.getCSSStyleRules(document.links[0]);
|
|
|
|
|
|
|
|
var seenInline = false;
|
|
|
|
var seenLinked = false;
|
|
|
|
|
|
|
|
for (var i = 0; i < inspectedRules.Count(); ++i)
|
|
|
|
{
|
|
|
|
var rule =
|
|
|
|
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>
|
|
|
|
|