Bug 1317293: Only allow nsFrameLoader::SwapWithOtherRemoteLoader when remote types match. r=billm
authorBob Owen <bobowencode@gmail.com>
Wed, 25 Jan 2017 07:18:00 +0000
changeset 330996 34c57b2a36e3fd5410b5ff9b5bea836599798b08
parent 330995 1604679f84e0a169f8cccece471905811f3d40f5
child 330997 c989c7b352279925edf138373e4ca3f1540dbd5f
child 331000 2e13f21663bba2af75c9184966cf24bf56d90dad
push id31256
push usercbook@mozilla.com
push dateWed, 25 Jan 2017 12:47:57 +0000
treeherdermozilla-central@c989c7b35227 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1317293
milestone54.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 1317293: Only allow nsFrameLoader::SwapWithOtherRemoteLoader when remote types match. r=billm
dom/base/nsFrameLoader.cpp
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1343,16 +1343,25 @@ nsFrameLoader::SwapWithOtherRemoteLoader
   if (!ourShell || !otherShell) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   if (!mRemoteBrowser || !aOther->mRemoteBrowser) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
+  // Remote types must match to swap loaders.
+  const nsAString& currentRemoteType =
+    mRemoteBrowser->Manager()->AsContentParent()->GetRemoteType();
+  const nsAString& newRemoteType =
+    aOther->mRemoteBrowser->Manager()->AsContentParent()->GetRemoteType();
+  if (!currentRemoteType.Equals(newRemoteType)) {
+    return NS_ERROR_NOT_IMPLEMENTED;
+  }
+
   if (mRemoteBrowser->IsIsolatedMozBrowserElement() !=
       aOther->mRemoteBrowser->IsIsolatedMozBrowserElement()) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   // When we swap docShells, maybe we have to deal with a new page created just
   // for this operation. In this case, the browser code should already have set
   // the correct userContextId attribute value in the owning XULElement, but our
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1089,16 +1089,22 @@ ContentParent::GetAllEvenIfDead(nsTArray
 {
   aArray.Clear();
 
   for (auto* cp : AllProcesses(eAll)) {
     aArray.AppendElement(cp);
   }
 }
 
+const nsAString&
+ContentParent::GetRemoteType() const
+{
+  return mRemoteType;
+}
+
 void
 ContentParent::Init()
 {
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (obs) {
     size_t length = ArrayLength(sObserverTopics);
     for (size_t i = 0; i < length; ++i) {
       obs->AddObserver(this, sObserverTopics[i], false);
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -157,16 +157,18 @@ public:
                 Element* aFrameElement,
                 ContentParent* aOpenerContentParent,
                 bool aFreshProcess = false);
 
   static void GetAll(nsTArray<ContentParent*>& aArray);
 
   static void GetAllEvenIfDead(nsTArray<ContentParent*>& aArray);
 
+  const nsAString& GetRemoteType() const;
+
   enum CPIteratorPolicy {
     eLive,
     eAll
   };
 
   class ContentParentIterator {
   private:
     ContentParent* mCurrent;