Invalidate a bit more aggressively when a pseudo-element matches, in order to also invalidate the cached pseudo-styles on the parent.

This should probably be fine. If it becomes a perf issue somehow we can
implement the RESTYLE_PSEUDOS hint or what not.

Differential Revision: https://phabricator.services.mozilla.com/D108338

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1697998
gecko-commit: acd959de0b618f741b2d6ec7ccb86e53686c9914
gecko-reviewers: mats
diff --git a/css/css-lists/marker-dynamic-content-change-ref.html b/css/css-lists/marker-dynamic-content-change-ref.html
new file mode 100644
index 0000000..6b5daa1
--- /dev/null
+++ b/css/css-lists/marker-dynamic-content-change-ref.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>CSS Test Reference</title>
+<style>
+::marker {
+  content: "PASS";
+}
+</style>
+<ol>
+  <li>Item
+</ol>
diff --git a/css/css-lists/marker-dynamic-content-change.html b/css/css-lists/marker-dynamic-content-change.html
new file mode 100644
index 0000000..31abb16
--- /dev/null
+++ b/css/css-lists/marker-dynamic-content-change.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<html class=reftest-wait>
+<title>Dynamic content change on ::marker</title>
+<link rel="help" href="https://drafts.csswg.org/css-lists-3/#marker-pseudo">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1697998">
+<link rel="author" title="Mozilla" href="https://mozilla.org">
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
+<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
+<link rel="match" href="marker-dynamic-content-change-ref.html">
+<style>
+::marker {
+  content: "FAIL";
+}
+.tweak ::marker {
+  content: "PASS";
+}
+</style>
+<script>
+  document.addEventListener("TestRendered", function() {
+    document.documentElement.classList = "tweak";
+  });
+</script>
+<ol>
+  <li>Item
+</ol>