diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp
index aa32adf61141..93a296278cc0 100644
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -239,6 +239,9 @@ NS_IMPL_ISUPPORTS(BFCachePreventionObserver, nsIMutationObserver)
void BFCachePreventionObserver::CharacterDataChanged(
nsIContent* aContent, const CharacterDataChangeInfo&) {
+ if (aContent->IsInNativeAnonymousSubtree()) {
+ return;
+ }
MutationHappened();
}
@@ -247,19 +250,31 @@ void BFCachePreventionObserver::AttributeChanged(Element* aElement,
nsAtom* aAttribute,
int32_t aModType,
const nsAttrValue* aOldValue) {
+ if (aElement->IsInNativeAnonymousSubtree()) {
+ return;
+ }
MutationHappened();
}
void BFCachePreventionObserver::ContentAppended(nsIContent* aFirstNewContent) {
+ if (aFirstNewContent->IsInNativeAnonymousSubtree()) {
+ return;
+ }
MutationHappened();
}
void BFCachePreventionObserver::ContentInserted(nsIContent* aChild) {
+ if (aChild->IsInNativeAnonymousSubtree()) {
+ return;
+ }
MutationHappened();
}
void BFCachePreventionObserver::ContentRemoved(nsIContent* aChild,
nsIContent* aPreviousSibling) {
+ if (aChild->IsInNativeAnonymousSubtree()) {
+ return;
+ }
MutationHappened();
}
diff --git a/layout/base/tests/file_zoom_restore_bfcache.html b/layout/base/tests/file_zoom_restore_bfcache.html
index 17816af6bdd4..27d308bed2d3 100644
--- a/layout/base/tests/file_zoom_restore_bfcache.html
+++ b/layout/base/tests/file_zoom_restore_bfcache.html
@@ -1,8 +1,75 @@
-This is a very interesting page
+This is a very interesting page
diff --git a/layout/base/tests/test_zoom_restore_bfcache.html b/layout/base/tests/test_zoom_restore_bfcache.html
index debac3ee2cfb..ffe158f220b4 100644
--- a/layout/base/tests/test_zoom_restore_bfcache.html
+++ b/layout/base/tests/test_zoom_restore_bfcache.html
@@ -7,34 +7,117 @@