diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp
index e04ee7cdba41..640e1e3af85a 100644
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -426,7 +426,8 @@ void nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
inner = GetInner();
}
}
- if (aReflowInput.ShouldReflowAllKids() || GetNextInFlow()) {
+ if (aReflowInput.ShouldReflowAllKids() || GetNextInFlow() ||
+ aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE) {
reflowInner = inner != nullptr;
reflowLegend = legend != nullptr;
} else {
diff --git a/layout/reftests/pagination/fieldset-00M-ref.html b/layout/reftests/pagination/fieldset-00M-ref.html
new file mode 100644
index 000000000000..cc89e417036d
--- /dev/null
+++ b/layout/reftests/pagination/fieldset-00M-ref.html
@@ -0,0 +1,28 @@
+
+
+
CSS Reference: fieldset fragmentation
+
+
+
+
+
+
+
diff --git a/layout/reftests/pagination/fieldset-00M.html b/layout/reftests/pagination/fieldset-00M.html
new file mode 100644
index 000000000000..37db42a1e25e
--- /dev/null
+++ b/layout/reftests/pagination/fieldset-00M.html
@@ -0,0 +1,28 @@
+
+
+ CSS Test: fieldset fragmentation
+
+
+
+
+
+
+
diff --git a/layout/reftests/pagination/reftest.list b/layout/reftests/pagination/reftest.list
index 17cd444b0018..5c744125c64e 100644
--- a/layout/reftests/pagination/reftest.list
+++ b/layout/reftests/pagination/reftest.list
@@ -164,6 +164,7 @@ fuzzy-if(cocoaWidget&&swgl,0-1,0-23) == content-url-pseudo.html content-url-pseu
== fieldset-00J-grid.html fieldset-00J-ref.html
== fieldset-00K.html fieldset-00K-ref.html
== fieldset-00L.html fieldset-00L-ref.html
+== fieldset-00M.html fieldset-00M-ref.html
== block-max-height-001.html block-max-height-001-ref.html
== block-max-height-002.html block-max-height-001-ref.html