summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_bug73586.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /layout/style/test/test_bug73586.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/style/test/test_bug73586.html')
-rw-r--r--layout/style/test/test_bug73586.html192
1 files changed, 192 insertions, 0 deletions
diff --git a/layout/style/test/test_bug73586.html b/layout/style/test/test_bug73586.html
new file mode 100644
index 000000000..a88ae0a30
--- /dev/null
+++ b/layout/style/test/test_bug73586.html
@@ -0,0 +1,192 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=73586
+-->
+<head>
+ <title>Test for Bug 73586</title>
+ <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");
+ });
+
+styleText.data = "span:nth-child(1) { background: lime; }";
+run_series(function(child, elt, elts, node, nodes) {
+ var matches = elt == 0;
+ is(cs(child).backgroundColor, matches ? LIME : WHITE,
+ "child " + node + " should " + (matches ? "" : "NOT ") +
+ " match " + styleText.data);
+ });
+
+styleText.data = "span:nth-last-child(0n+2) { color: green; }";
+run_series(function(child, elt, elts, node, nodes) {
+ var matches = (elt == elts - 2);
+ is(cs(child).color, matches ? GREEN : BLACK,
+ "child " + node + " should " + (matches ? "" : "NOT ") +
+ " match " + styleText.data);
+ });
+
+styleText.data = "span:nth-of-type(2n+3) { color: green; }";
+run_series(function(child, elt, elts, node, nodes) {
+ var nidx = elt + 1;
+ var matches = nidx % 2 == 1 && nidx >= 3;
+ is(cs(child).color, matches ? GREEN : BLACK,
+ "child " + node + " should " + (matches ? "" : "NOT ") +
+ " match " + styleText.data);
+ });
+
+styleText.data = "span:nth-last-of-type(-2n+5) { color: green; }";
+run_series(function(child, elt, elts, node, nodes) {
+ var nlidx = elts - elt;
+ var matches = nlidx % 2 == 1 && nlidx <= 5;
+ is(cs(child).color, matches ? GREEN : BLACK,
+ "child " + node + " should " + (matches ? "" : "NOT ") +
+ " match " + styleText.data);
+ });
+
+styleText.data = "span:first-of-type { color: green; }";
+run_series(function(child, elt, elts, node, nodes) {
+ var matches = (elt == 0);
+ is(cs(child).color, matches ? GREEN : BLACK,
+ "child " + node + " should " + (matches ? "" : "NOT ") +
+ " match " + styleText.data);
+ });
+
+styleText.data = "span:last-of-type { color: green; }";
+run_series(function(child, elt, elts, node, nodes) {
+ var matches = (elt == elts - 1);
+ is(cs(child).color, matches ? GREEN : BLACK,
+ "child " + node + " should " + (matches ? "" : "NOT ") +
+ " match " + styleText.data);
+ });
+
+styleText.data = "span:only-of-type { color: green; }";
+run_series(function(child, elt, elts, node, nodes) {
+ var matches = elts == 1;
+ is(cs(child).color, matches ? GREEN : BLACK,
+ "child " + node + " should " + (matches ? "" : "NOT ") +
+ " match " + styleText.data);
+ });
+
+</script>
+</pre>
+</body>
+</html>
+