Bug 1595900 - CanonicalBrowsingContext::GetSessionHistory should be able to deal with in-process case too, r=peterv
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Wed, 13 Nov 2019 15:21:25 +0000
changeset 501762 27f06b7cc987734c9f55742f18351b5e40ea3aed
parent 501761 1936d7a01173063eeeb672a29e519be5249b9a5f
child 501763 bb6776d41b9eae7155e49f0674c00c99ee8dbebf
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1595900
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1595900 - CanonicalBrowsingContext::GetSessionHistory should be able to deal with in-process case too, r=peterv Differential Revision: https://phabricator.services.mozilla.com/D52738
docshell/base/CanonicalBrowsingContext.cpp
docshell/base/CanonicalBrowsingContext.h
--- a/docshell/base/CanonicalBrowsingContext.cpp
+++ b/docshell/base/CanonicalBrowsingContext.cpp
@@ -142,16 +142,32 @@ CanonicalBrowsingContext::GetEmbedderWin
   uint64_t windowId = GetEmbedderInnerWindowId();
   if (windowId == 0) {
     return nullptr;
   }
 
   return WindowGlobalParent::GetByInnerWindowId(windowId);
 }
 
+nsISHistory* CanonicalBrowsingContext::GetSessionHistory() {
+  if (mSessionHistory) {
+    return mSessionHistory;
+  }
+
+  nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(GetDocShell());
+  if (webNav) {
+    RefPtr<ChildSHistory> shistory = webNav->GetSessionHistory();
+    if (shistory) {
+      return shistory->LegacySHistory();
+    }
+  }
+
+  return nullptr;
+}
+
 JSObject* CanonicalBrowsingContext::WrapObject(
     JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
   return CanonicalBrowsingContext_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 void CanonicalBrowsingContext::Traverse(
     nsCycleCollectionTraversalCallback& cb) {
   CanonicalBrowsingContext* tmp = this;
--- a/docshell/base/CanonicalBrowsingContext.h
+++ b/docshell/base/CanonicalBrowsingContext.h
@@ -56,17 +56,17 @@ class CanonicalBrowsingContext final : p
   // The current active WindowGlobal.
   WindowGlobalParent* GetCurrentWindowGlobal() const {
     return mCurrentWindowGlobal;
   }
   void SetCurrentWindowGlobal(WindowGlobalParent* aGlobal);
 
   already_AddRefed<WindowGlobalParent> GetEmbedderWindowGlobal() const;
 
-  nsISHistory* GetSessionHistory() { return mSessionHistory; }
+  nsISHistory* GetSessionHistory();
   void SetSessionHistory(nsISHistory* aSHistory) {
     mSessionHistory = aSHistory;
   }
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
   // This function is used to start the autoplay media which are delayed to
   // start. If needed, it would also notify the content browsing context which