Bug 1376352: Test. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 03 Jul 2017 11:09:44 +0200
changeset 603279 a057b5dbe0f79532666df2b6d645acff6a5bfff0
parent 603251 0d2ee6465107e4507029ad909804c56049680c26
child 603315 c59ce341a96fd1c6703ff5ae723c31beb7aa0e50
push id66714
push userbmo:emilio+bugs@crisal.io
push dateMon, 03 Jul 2017 11:07:48 +0000
reviewersheycam
bugs1376352
milestone56.0a1
Bug 1376352: Test. r?heycam MozReview-Commit-ID: K0QCJgwhEMN
layout/reftests/generated-content/dynamic-content-ref.html
layout/reftests/generated-content/dynamic-content.html
layout/reftests/generated-content/reftest.list
layout/style/test/mochitest.ini
layout/style/test/test_reframe_pseudo_element.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/generated-content/dynamic-content-ref.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<style>
+div::before {
+  content: "Woof";
+}
+</style>
+<div></div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/generated-content/dynamic-content.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<style>
+div::before {
+  content: none;
+}
+.foo::before {
+  content: "Woof";
+}
+</style>
+<div></div>
+<script>
+  document.body.offsetTop;
+  document.querySelector('div').classList.add('foo');
+</script>
--- a/layout/reftests/generated-content/reftest.list
+++ b/layout/reftests/generated-content/reftest.list
@@ -13,8 +13,9 @@ fuzzy-if(OSX==1010,1,10) == dynamic-tabl
 fuzzy-if(OSX==1010,1,10) == floated-01.html floated-01-ref.html
 fuzzy-if(OSX==1010,1,10) == images-01.html images-01-ref.html
 fuzzy-if(OSX==1010,1,10) == positioned-01.html positioned-01-ref.html
 fuzzy-if(OSX==1010,1,10) == quotes-001.xml quotes-001-ref.xml
 fuzzy-if(OSX==1010,1,10) == table-ignoring-whitespace-01.html table-ignoring-whitespace-01-ref.html
 fuzzy-if(OSX==1010,1,10) == table-parts-01.html table-parts-01-ref.html
 == before-style-sharing.html before-style-sharing-ref.html
 == transitive-style-invalidation.html transitive-style-invalidation-ref.html
+== dynamic-content.html dynamic-content-ref.html
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -253,16 +253,17 @@ skip-if = android_version == '18' #debug
 [test_position_sticky.html]
 [test_priority_preservation.html]
 [test_property_database.html]
 [test_property_syntax_errors.html]
 [test_pseudoelement_state.html]
 [test_pseudoelement_parsing.html]
 [test_redundant_font_download.html]
 support-files = redundant_font_download.sjs
+[test_reframe_pseudo_element.html]
 [test_rem_unit.html]
 [test_restyle_table_wrapper.html]
 [test_restyles_in_smil_animation.html]
 skip-if = toolkit == 'android' # bug 1328522
 [test_root_node_display.html]
 [test_rule_insertion.html]
 [test_rule_serialization.html]
 [test_rules_out_of_sheets.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_reframe_pseudo_element.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>
+  Test for bug 1376352: We don't reframe all the time a replaced element that
+  matches generated content rules.
+</title>
+<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<style>
+input::before {
+  content: "Foo";
+}
+</style>
+<input type="text">
+<script>
+SimpleTest.waitForExplicitFinish();
+const utils = SpecialPowers.getDOMWindowUtils(window);
+document.documentElement.offsetTop;
+const input = document.querySelector('input');
+
+const previousConstructCount = utils.framesConstructed;
+const previousRestyleGeneration = utils.restyleGeneration;
+
+input.style.color = "blue";
+
+document.documentElement.offsetTop;
+isnot(previousRestyleGeneration, utils.restyleGeneration,
+      "We should have restyled");
+is(previousConstructCount, utils.framesConstructed,
+   "We shouldn't have reframed");
+
+SimpleTest.finish();
+</script>