Bug 1203766 - Part 7: Test. r=bzbarsky
authorCameron McCormack <cam@mcc.id.au>
Thu, 17 Sep 2015 12:08:21 +1000
changeset 297266 fd7255b1c5f8d090b17bde50dfcebdba0a4da824
parent 297265 856b829f6b0ad0edb85b1ff3ebbb1cb9cb006f20
child 297267 ac81086dc2671bbfe0ab0305b2cc158b762b5af8
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1203766
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203766 - Part 7: Test. r=bzbarsky
layout/style/test/mochitest.ini
layout/style/test/test_bug1203766.html
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -124,16 +124,17 @@ support-files = bug732209-css.sjs
 support-files = file_bug829816.css
 [test_bug887741_at-rules_in_declaration_lists.html]
 [test_bug892929.html]
 [test_bug1055933.html]
 support-files = file_bug1055933_circle-xxl.png
 [test_bug1089417.html]
 support-files = file_bug1089417_iframe.html
 [test_bug1112014.html]
+[test_bug1203766.html]
 [test_cascade.html]
 [test_ch_ex_no_infloops.html]
 [test_compute_data_with_start_struct.html]
 skip-if = toolkit == 'android'
 [test_computed_style.html]
 [test_computed_style_no_pseudo.html]
 [test_computed_style_prefs.html]
 [test_condition_text.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_bug1203766.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Test for bug 1203766</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
+<style>
+.x { color: red; }
+body > .x { color: green; }
+.y { color: green; }
+body > .y { display: none; color: red; }
+div > .z { color: red; }
+.z { color: green; }
+.a { color: red; }
+body > .a { display: none; color: green; }
+.b { display: none; }
+.c { color: red; }
+.b > .c { color: green; }
+.e { color: red; }
+.d > .e { color: green; }
+.f { color: red; }
+.g { color: green; }
+.h > .i { color: red; }
+.j > .i { color: green; }
+</style>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1203766">Mozilla Bug 1203766</a>
+<p id="display"></p>
+<div class=y></div>
+<div class=b></div>
+<pre id="test">
+<script class="testbody">
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+
+  // Element that goes from being out of the document to in the document.
+  var e = document.createElement("div");
+  e.className = "x";
+  var cs = getComputedStyle(e);
+  is(cs.color, "rgb(255, 0, 0)");
+  document.body.appendChild(e);
+  is(cs.color, "rgb(0, 128, 0)");
+
+  // Element that goes from in the document (and display:none) to out of
+  // the document.
+  e = document.querySelector(".y");
+  cs = getComputedStyle(e);
+  is(cs.color, "rgb(255, 0, 0)");
+  e.remove();
+  is(cs.color, "rgb(0, 128, 0)");
+
+  // Element that is removed from an out-of-document tree.
+  e = document.createElement("div");
+  f = document.createElement("span");
+  f.className = "z";
+  e.appendChild(f);
+  cs = getComputedStyle(f);
+  is(cs.color, "rgb(255, 0, 0)");
+  f.remove();
+  is(cs.color, "rgb(0, 128, 0)");
+
+  // Element going from not in document to in document and display:none.
+  e = document.createElement("div");
+  e.className = "a";
+  cs = getComputedStyle(e);
+  is(cs.color, "rgb(255, 0, 0)");
+  document.body.appendChild(e);
+  is(cs.color, "rgb(0, 128, 0)");
+
+  // Element going from not in document to in document and child of
+  // display:none element.
+  e = document.createElement("div");
+  e.className = "c";
+  cs = getComputedStyle(e);
+  is(cs.color, "rgb(255, 0, 0)");
+  document.querySelector(".b").appendChild(e);
+  is(cs.color, "rgb(0, 128, 0)");
+
+  // Element that is added to an out-of-document tree.
+  e = document.createElement("div");
+  e.className = "d";
+  f = document.createElement("span");
+  f.className = "e";
+  cs = getComputedStyle(f);
+  is(cs.color, "rgb(255, 0, 0)");
+  e.appendChild(f);
+  is(cs.color, "rgb(0, 128, 0)");
+
+  // Element that is outside the document when an attribute is modified to
+  // cause a different rule to match.
+  e = document.createElement("div");
+  e.className = "f";
+  cs = getComputedStyle(e);
+  is(cs.color, "rgb(255, 0, 0)");
+  e.className = "g";
+  is(cs.color, "rgb(0, 128, 0)");
+
+  // Element that is outside the document when an ancestor is modified to
+  // cause a different rule to match.
+  e = document.createElement("div");
+  e.className = "h";
+  f = document.createElement("span");
+  f.className = "i";
+  e.appendChild(f);
+  cs = getComputedStyle(f);
+  is(cs.color, "rgb(255, 0, 0)");
+  e.className = "j";
+  is(cs.color, "rgb(0, 128, 0)");
+
+  SimpleTest.finish();
+});
+</script>
+</pre>