From 2103a2283b68d0bc147905259f5d7ac94bce6f60 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 16 Feb 2021 12:13:16 +0000 Subject: Issue #1688 - Add flood guard to state change logic. --- docshell/base/nsDocShell.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docshell/base/nsDocShell.h') diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 93a1ba68d..019a7e4ab 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -1049,6 +1049,15 @@ private: // as constants in the nsIDocShell.idl file. uint32_t mTouchEventsOverride; + // Keep track how how many history state changes we're getting, to catch & + // prevent flooding. + int32_t mStateFloodGuardCount; + mozilla::TimeStamp mStateFloodGuardUpdated; + bool mStateFloodGuardReported; + // We have a limit of pushing 50 states to history every 10 seconds. + const int32_t kStateUpdateLimit = 50; + const double kRefreshTimeSecs = 10.0; + // Separate function to do the actual name (i.e. not _top, _self etc.) // searching for FindItemWithName. nsresult DoFindItemWithName(const nsAString& aName, @@ -1064,6 +1073,10 @@ private: void MaybeNotifyKeywordSearchLoading(const nsString& aProvider, const nsString& aKeyword); + // Helper method for AddState which checks for excessive calls to PushState or + // ReplaceState. + bool IsStateChangeFlooding(); + #ifdef DEBUG // We're counting the number of |nsDocShells| to help find leaks static unsigned long gNumberOfDocShells; -- cgit v1.2.3