1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/base/tests/test_bug416896.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=416896 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 416896</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 + <link rel="stylesheet" type="text/css" id="l" 1.14 + href="data:text/css,a { color: green }"/> 1.15 + <style type="text/css" id="i"> a { color: blue; } </style> 1.16 + 1.17 +</head> 1.18 +<body> 1.19 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=416896">Mozilla Bug 416896</a> 1.20 +<p id="display"></p> 1.21 +<div id="content" style="display: none"> 1.22 + 1.23 +</div> 1.24 +<pre id="test"> 1.25 +<script class="testbody" type="text/javascript"> 1.26 + 1.27 +/** Test for Bug 416896 **/ 1.28 + var inlineSheet = $("i").sheet; 1.29 + isnot(inlineSheet, null, "Should have sheet here"); 1.30 + 1.31 + var linkedSheet = $("l").sheet; 1.32 + isnot(linkedSheet, null, "Should have sheet here"); 1.33 + 1.34 + var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"] 1.35 + .getService(SpecialPowers.Ci.inIDOMUtils); 1.36 + const nsIDOMCSSStyleRule = SpecialPowers.Ci["nsIDOMCSSStyleRule"]; 1.37 + var inspectedRules = domUtils.getCSSStyleRules(document.links[0]); 1.38 + 1.39 + var seenInline = false; 1.40 + var seenLinked = false; 1.41 + 1.42 + for (var i = 0; i < inspectedRules.Count(); ++i) 1.43 + { 1.44 + var rule = 1.45 + SpecialPowers.unwrap(inspectedRules.GetElementAt(i).QueryInterface(nsIDOMCSSStyleRule)); 1.46 + var sheet = rule.parentStyleSheet; 1.47 + if (sheet == inlineSheet) { 1.48 + is(sheet.href, null, "It's an inline sheet"); 1.49 + is(seenInline, false, "Only one inline rule matches"); 1.50 + seenInline = true; 1.51 + } else { 1.52 + isnot(sheet.href, null, "Shouldn't have null href here"); 1.53 + if (sheet == linkedSheet) { 1.54 + is(seenLinked, false, "Only one linked rule matches"); 1.55 + seenLinked = true; 1.56 + } 1.57 + } 1.58 + } 1.59 + 1.60 + is(seenLinked, true, "Didn't find the linked rule?"); 1.61 + is(seenInline, true, "Didn't find the inline rule?"); 1.62 + 1.63 + 1.64 +</script> 1.65 +</pre> 1.66 +</body> 1.67 +</html> 1.68 +