From 1fa7fd2c48a7de1d4a35b4cf584d3fab1d69390f Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Wed, 19 Jun 2019 21:09:28 +0200 Subject: [PATCH] Bug 1560940 - Change tests that use session history listeners to listen in the parent process. r=nika Expose SHistory object from CanonicalBrowsingContext. Differential Revision: https://phabricator.services.mozilla.com/D35654 --HG-- extra : rebase_source : 83b465a1ea387d79889f9cec73f3129adca66016 extra : source : 6d2db7f001668a7a18e7c8dc0693236d6f6964ba extra : histedit_source : cced2d0317eef396dacd626b72cebf9625238897 --- docshell/base/CanonicalBrowsingContext.cpp | 6 ++++-- docshell/base/CanonicalBrowsingContext.h | 7 +++++++ docshell/shistory/SHistoryParent.cpp | 7 +++++++ docshell/shistory/SHistoryParent.h | 7 ++----- dom/chrome-webidl/BrowsingContext.webidl | 2 ++ 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index 8943b7c0d36a..19b120546aa1 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -154,12 +154,14 @@ JSObject* CanonicalBrowsingContext::WrapObject( void CanonicalBrowsingContext::Traverse( nsCycleCollectionTraversalCallback& cb) { CanonicalBrowsingContext* tmp = this; - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowGlobals, mCurrentWindowGlobal); + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowGlobals, mCurrentWindowGlobal, + mSessionHistory); } void CanonicalBrowsingContext::Unlink() { CanonicalBrowsingContext* tmp = this; - NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowGlobals, mCurrentWindowGlobal); + NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowGlobals, mCurrentWindowGlobal, + mSessionHistory); } void CanonicalBrowsingContext::NotifyStartDelayedAutoplayMedia() { diff --git a/docshell/base/CanonicalBrowsingContext.h b/docshell/base/CanonicalBrowsingContext.h index 587c4116d30c..e7638ce6bc7d 100644 --- a/docshell/base/CanonicalBrowsingContext.h +++ b/docshell/base/CanonicalBrowsingContext.h @@ -15,6 +15,7 @@ #include "nsWrapperCache.h" #include "nsTHashtable.h" #include "nsHashKeys.h" +#include "nsISHistory.h" class nsIDocShell; @@ -60,6 +61,10 @@ class CanonicalBrowsingContext final : public BrowsingContext { already_AddRefed GetEmbedderWindowGlobal() const; + nsISHistory* GetSessionHistory() { return mSessionHistory; } + void SetSessionHistory(nsISHistory* aSHistory) { + mSessionHistory = aSHistory; + } JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; @@ -144,6 +149,8 @@ class CanonicalBrowsingContext final : public BrowsingContext { // The current remoteness change which is in a pending state. RefPtr mPendingRemotenessChange; + + nsCOMPtr mSessionHistory; }; } // namespace dom diff --git a/docshell/shistory/SHistoryParent.cpp b/docshell/shistory/SHistoryParent.cpp index 3dfd232de97f..8d6b78a3cd4a 100644 --- a/docshell/shistory/SHistoryParent.cpp +++ b/docshell/shistory/SHistoryParent.cpp @@ -12,6 +12,13 @@ namespace mozilla { namespace dom { +LegacySHistory::LegacySHistory(CanonicalBrowsingContext* aRootBC, + const nsID& aDocShellID) + : nsSHistory(aRootBC, aDocShellID) { + mIsRemote = true; + aRootBC->SetSessionHistory(this); +} + static void FillInLoadResult(PContentParent* aManager, nsresult aRv, const nsSHistory::LoadEntryResult& aLoadResult, LoadSHEntryResult* aResult) { diff --git a/docshell/shistory/SHistoryParent.h b/docshell/shistory/SHistoryParent.h index 0b78e1f4f656..3b098a74884e 100644 --- a/docshell/shistory/SHistoryParent.h +++ b/docshell/shistory/SHistoryParent.h @@ -27,11 +27,8 @@ class LegacySHistory final : public nsSHistory { virtual ~LegacySHistory() {} public: - LegacySHistory(mozilla::dom::BrowsingContext* aRootBC, - const nsID& aDocShellID) - : nsSHistory(aRootBC, aDocShellID) { - mIsRemote = true; - } + LegacySHistory(mozilla::dom::CanonicalBrowsingContext* aRootBC, + const nsID& aDocShellID); }; /** diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl index f509813ffc9b..04367b215981 100644 --- a/dom/chrome-webidl/BrowsingContext.webidl +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -86,6 +86,8 @@ interface CanonicalBrowsingContext : BrowsingContext { [Throws] Promise changeFrameRemoteness( DOMString remoteType, unsigned long long pendingSwitchId); + + readonly attribute nsISHistory? sessionHistory; }; [Exposed=Window, ChromeOnly]