layout/style/test/test_bug534804.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=534804
     5 -->
     6 <head>
     7   <title>Test for Bug 534804</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10   <style type="text/css" id="styleone">  </style>
    11   <style type="text/css" id="styletwo">  </style>
    12 </head>
    13 <body>
    14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534804">Mozilla Bug 534804</a>
    15 <p id="display"></p>
    16 <pre id="test">
    17 <script type="application/javascript">
    19 /** Test for Bug 534804 **/
    21 var styleone = document.getElementById("styleone");
    22 var styletwo = document.getElementById("styletwo");
    23 var display = document.getElementById("display");
    25 run1();
    26 styletwo.firstChild.data = "#e > span:nth-child(2n+1) { color: green }";
    27 run1();
    28 styletwo.firstChild.data = "#e > span:first-child { color: green }";
    29 run1();
    30 styletwo.firstChild.data = "#e > span:nth-last-child(2n+1) { color: green }";
    31 run1();
    32 styletwo.firstChild.data = "#e > span:last-child { color: green }";
    33 run1();
    35 function run1()
    36 {
    37   function identity(bool)      { return bool; }
    38   function inverse(bool)       { return !bool; }
    39   function always_false(bool)  { return false; }
    40   run2("#e:empty + span", identity, always_false);
    41   run2("#e:empty ~ span", identity, identity);
    42   run2("#e:not(:empty) + span", inverse, always_false);
    43   run2("#e:not(:empty) ~ span", inverse, inverse);
    44 }
    46 function run2(sel, next_sibling_rule, later_sibling_rule)
    47 {
    48   styleone.firstChild.data = sel + " { text-decoration: underline }";
    50   // Rebuild the subtree every time.
    51   var span1 = document.createElement("span");
    52   span1.id = "e";
    53   var span2 = document.createElement("span");
    54   var span3 = document.createElement("span");
    55   display.appendChild(span1);
    56   display.appendChild(span2);
    57   display.appendChild(span3);
    59   function td(e) { return getComputedStyle(e, "").textDecoration; }
    61   function check(desc, isempty) {
    62     is(td(span2), next_sibling_rule(isempty) ? "underline" : "none",
    63        "match of next sibling in state " + desc);
    64     is(td(span3), later_sibling_rule(isempty) ? "underline" : "none",
    65        "match of next sibling in state " + desc);
    66   }
    68   check("initially empty", true);
    69   var kid = document.createElement("span");
    70   span1.appendChild(kid);
    71   check("after append", false);
    72   span1.removeChild(kid);
    73   check("after remove", true);
    74   span1.appendChild(document.createTextNode(""));
    75   span1.appendChild(document.createComment("a comment"));
    76   span1.appendChild(document.createTextNode(""));
    77   check("after append of insignificant children", true);
    78   span1.insertBefore(kid, span1.childNodes[1]);
    79   check("after insert", false);
    81   display.removeChild(span1);
    82   display.removeChild(span2);
    83   display.removeChild(span3);
    84 }
    86 </script>
    87 </pre>
    88 </body>
    89 </html>

mercurial