Bug 1325428 - Disable bfcache for WebVR pages
MozReview-Commit-ID: fymOSOEoDC
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -8574,24 +8574,28 @@ nsDocument::CanSavePresentation(nsIReque
// The aIgnoreRequest we were passed is only for us, so don't pass it on.
bool canCache = subdoc ? subdoc->CanSavePresentation(nullptr) : false;
if (!canCache) {
return false;
}
}
}
-#ifdef MOZ_WEBSPEECH
+
if (win) {
auto* globalWindow = nsGlobalWindow::Cast(win);
+#ifdef MOZ_WEBSPEECH
if (globalWindow->HasActiveSpeechSynthesis()) {
return false;
}
- }
#endif
+ if (globalWindow->HasUsedVR()) {
+ return false;
+ }
+ }
return true;
}
void
nsDocument::Destroy()
{
// The ContentViewer wants to release the document now. So, tell our content
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -13227,16 +13227,24 @@ nsGlobalWindow::EventListenerAdded(nsIAt
void
nsGlobalWindow::NotifyVREventListenerAdded()
{
MOZ_ASSERT(IsInnerWindow());
mHasVREvents = true;
EnableVRUpdates();
}
+bool
+nsGlobalWindow::HasUsedVR() const
+{
+ MOZ_ASSERT(IsInnerWindow());
+
+ return mHasVREvents;
+}
+
void
nsGlobalWindow::EnableTimeChangeNotifications()
{
mozilla::time::AddWindowListener(AsInner());
}
void
nsGlobalWindow::DisableTimeChangeNotifications()
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -443,16 +443,17 @@ public:
virtual void FinishFullscreenChange(bool aIsFullscreen) override final;
bool SetWidgetFullscreen(FullscreenReason aReason, bool aIsFullscreen,
nsIWidget* aWidget, nsIScreen* aScreen);
bool FullScreen() const;
// Inner windows only.
virtual void SetHasGamepadEventListener(bool aHasGamepad = true) override;
void NotifyVREventListenerAdded();
+ bool HasUsedVR() const;
virtual void EventListenerAdded(nsIAtom* aType) override;
// nsIInterfaceRequestor
NS_DECL_NSIINTERFACEREQUESTOR
// WebIDL interface.
already_AddRefed<nsPIDOMWindowOuter> IndexedGetterOuter(uint32_t aIndex);
already_AddRefed<nsPIDOMWindowOuter> IndexedGetter(uint32_t aIndex);