DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Untracked file

Line Code
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=73586
-->
<head>
  <title>Test for Bug 73586</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" />
  <style type="text/css">

  span { background: white; color: black; border: medium solid black; }

  </style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=73586">Mozilla Bug 73586</a>
<div id="display"></div>

<div id="content" style="display: none">
  
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 73586 **/

const GREEN = "rgb(0, 128, 0)";
const LIME = "rgb(0, 255, 0)";
const BLACK = "rgb(0, 0, 0)";
const WHITE = "rgb(255, 255, 255)";

function cs(elt) { return getComputedStyle(elt, ""); }

function check_children(p, check_cb) {
    var len = p.childNodes.length;
    var elts = 0;
    var i, elt, child;
    for (i = 0; i < len; ++i) {
      if (p.childNodes[i].nodeType == Node.ELEMENT_NODE)
        ++elts;
    }

    elt = 0;
    for (i = 0; i < len; ++i) {
        child = p.childNodes[i];
        if (child.nodeType != Node.ELEMENT_NODE)
            continue;
        check_cb(child, elt, elts, i, len);
        ++elt;
    }
}

var display = document.getElementById("display");

function run_series(check_cb) {
    var display = document.getElementById("display");
    // Use a new parent node every time since the optimizations cause
    // bits to be set (permanently) on the parent.
    var p = document.createElement("p");
    display.appendChild(p);
    p.innerHTML = "x<span></span><span></span>";

    check_children(p, check_cb);
    var text = p.removeChild(p.childNodes[0]);
    check_children(p, check_cb);
    var span = p.removeChild(p.childNodes[0]);
    check_children(p, check_cb);
    p.appendChild(span);
    check_children(p, check_cb);
    p.removeChild(span);
    check_children(p, check_cb);
    p.insertBefore(span, p.childNodes[0]);
    check_children(p, check_cb);
    p.removeChild(span);
    check_children(p, check_cb);
    p.insertBefore(span, null);
    check_children(p, check_cb);
    p.appendChild(document.createElement("span"));
    check_children(p, check_cb);
    p.insertBefore(document.createElement("span"), p.childNodes[2]);
    check_children(p, check_cb);
    p.appendChild(text);
    check_children(p, check_cb);

    display.removeChild(p);
}

var style = document.createElement("style");
style.setAttribute("type", "text/css");
var styleText = document.createTextNode("");
style.appendChild(styleText);
document.getElementsByTagName("head")[0].appendChild(style);

styleText.data = "span:first-child { background: lime; }";
run_series(function(child, elt, elts, node, nodes) {
        is(cs(child).backgroundColor, (elt == 0) ? LIME : WHITE,
           "child " + node + " should " + ((elt == 0) ? "" : "NOT ") +
           " match :first-child");
    });

styleText.data = "span:last-child { color: green; }";
run_series(function(child, elt, elts, node, nodes) {
        is(cs(child).color, (elt == elts - 1) ? GREEN : BLACK,
           "child " + node + " should " + ((elt == elts - 1) ? "" : "NOT ") +
           " match :last-child");
    });

styleText.data = "span:only-child { border: medium solid green; }";
run_series(function(child, elt, elts, node, nodes) {
        is(cs(child).borderTopColor, (elts == 1) ? GREEN : BLACK,
           "child " + node + " should " + ((elts == 1) ? "" : "NOT ") +
           " match :only-child");
    });

styleText.data = "span:-moz-first-node { text-decoration: underline; }";
run_series(function(child, elt, elts, node, nodes) {
        is(cs(child).textDecoration, (node == 0) ? "underline" : "none",
           "child " + node + " should " + ((node == 0) ? "" : "NOT ") +
           " match :-moz-first-node");
    });

styleText.data = "span:-moz-last-node { visibility: hidden; }";
run_series(function(child, elt, elts, node, nodes) {
        is(cs(child).visibility, (node == nodes - 1) ? "hidden" : "visible",
           "child " + node + " should " + ((node == nodes - 1) ? "" : "NOT ") +
           " match :-moz-last-node");
    });

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