layout/base/tests/test_bug416896.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=416896
     5 -->
     6 <head>
     7   <title>Test for Bug 416896</title>
     8   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    10   <link rel="stylesheet" type="text/css" id="l"
    11         href="data:text/css,a { color: green }"/>
    12   <style type="text/css" id="i"> a { color: blue; } </style>
    14 </head>
    15 <body>
    16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=416896">Mozilla Bug 416896</a>
    17 <p id="display"></p>
    18 <div id="content" style="display: none">
    20 </div>
    21 <pre id="test">
    22 <script class="testbody" type="text/javascript">
    24 /** Test for Bug 416896 **/
    25  var inlineSheet = $("i").sheet;
    26  isnot(inlineSheet, null, "Should have sheet here");
    28  var linkedSheet = $("l").sheet;
    29  isnot(linkedSheet, null, "Should have sheet here");
    31  var domUtils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
    32                              .getService(SpecialPowers.Ci.inIDOMUtils);
    33  const nsIDOMCSSStyleRule = SpecialPowers.Ci["nsIDOMCSSStyleRule"];
    34  var inspectedRules = domUtils.getCSSStyleRules(document.links[0]);
    36  var seenInline = false;
    37  var seenLinked = false;
    39  for (var i = 0; i < inspectedRules.Count(); ++i)
    40  {
    41    var rule =
    42      SpecialPowers.unwrap(inspectedRules.GetElementAt(i).QueryInterface(nsIDOMCSSStyleRule));
    43    var sheet = rule.parentStyleSheet;
    44    if (sheet == inlineSheet) {
    45      is(sheet.href, null, "It's an inline sheet");
    46      is(seenInline, false, "Only one inline rule matches");
    47      seenInline = true;
    48    } else {
    49      isnot(sheet.href, null, "Shouldn't have null href here");
    50      if (sheet == linkedSheet) {
    51        is(seenLinked, false, "Only one linked rule matches");
    52        seenLinked = true;
    53      }
    54    }
    55  }
    57  is(seenLinked, true, "Didn't find the linked rule?");
    58  is(seenInline, true, "Didn't find the inline rule?");
    61 </script>
    62 </pre>
    63 </body>
    64 </html>

mercurial