Bug 1379433: Test. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 09 Jul 2017 04:16:20 +0200
changeset 605795 85ccbec0687e48a8f0524da580408d9c7eedcf9f
parent 605766 76ea77b75f47496732346b0701eaea2f7c81f75a
child 605892 80acac7682a217e2b9508f10c141fb54f3ceb04f
child 606470 70774ac337d822baac96b611dba27bff2c256b28
push id67519
push userbmo:emilio+bugs@crisal.io
push dateSun, 09 Jul 2017 13:32:03 +0000
reviewersheycam
bugs1379433
milestone56.0a1
Bug 1379433: Test. r?heycam MozReview-Commit-ID: EsDTzjLkqVk
layout/style/test/test_stylesheet_additions.html
--- a/layout/style/test/test_stylesheet_additions.html
+++ b/layout/style/test/test_stylesheet_additions.html
@@ -28,28 +28,34 @@ const TESTS = [
   { selector: ".classScope", restyle: true },
   { selector: ".classScope div", restyle: true },
   { selector: "#idScope", restyle: true },
   { selector: "#nonexistentIdScope", restyle: false },
   { selector: "#nonexistentIdScope div + bar", restyle: false },
 ];
 
 for (const test of TESTS) {
-  // TODO(emilio): We don't as of right now, but we could also scan the
-  // stylesheet when removed if needed and test this too.
   target.innerHTML = test.selector + " { color: green; }";
-  target.disabled = true;
+
   document.body.offsetWidth;
   const prevGeneration = utils.restyleGeneration;
+
+  target.disabled = true;
+
+  document.body.offsetWidth;
+  (test.restyle ? isnot : is)(utils.restyleGeneration, prevGeneration,
+     `Stylesheet removal with ${test.selector} should ${test.restyle ? "have" : "not have"} caused a restyle`);
+
   target.disabled = false; // Make the stylesheet effective.
+
   let element = document.querySelector(test.selector);
   if (element) {
     is(test.restyle, true, "How could we not expect a restyle?");
     is(getComputedStyle(element).color, "rgb(0, 128, 0)",
        "Element style should've changed appropriately");
   }
   document.body.offsetWidth;
-  is(test.restyle, utils.restyleGeneration != prevGeneration,
+  (test.restyle ? isnot : is)(utils.restyleGeneration, prevGeneration,
      `Stylesheet addition with ${test.selector} should ${test.restyle ? "have" : "not have"} caused a restyle`);
 }
 
 SimpleTest.finish();
 </script>