Bug 1313902 - IPCTabContext should not have manual de/serialization of OriginAttributes, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 31 Oct 2016 18:49:29 +0100
changeset 320337 027edb9540a7a79b0b057de10213361b27d9185e
parent 320336 531763d23d7945286fe006cc3aab671ac35ce753
child 320338 a90caac9eaeb3df6ace795bed4ffa649d0442cdf
push id30896
push userphilringnalda@gmail.com
push dateTue, 01 Nov 2016 01:36:59 +0000
treeherdermozilla-central@0899c2b63e21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1313902
milestone52.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 1313902 - IPCTabContext should not have manual de/serialization of OriginAttributes, r=qdot
dom/ipc/PTabContext.ipdlh
dom/ipc/TabContext.cpp
--- a/dom/ipc/PTabContext.ipdlh
+++ b/dom/ipc/PTabContext.ipdlh
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBrowser;
 include PBrowserOrId;
 
 using UIStateChangeType from "nsPIDOMWindow.h";
+using mozilla::DocShellOriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 
 namespace mozilla {
 namespace dom {
 
 // An IPCTabContext which corresponds to a PBrowser opened by a child when it
 // receives window.open().
 //
 // If isMozBrowserElement is false, this PopupIPCTabContext is either a
@@ -30,18 +31,18 @@ struct PopupIPCTabContext
 {
   PBrowserOrId opener;
   bool isMozBrowserElement;
 };
 
 // An IPCTabContext which corresponds to an app, browser, or normal frame.
 struct FrameIPCTabContext
 {
-  // The stringified originAttributes dictionary.
-  nsCString originSuffix;
+  // The originAttributes dictionary.
+  DocShellOriginAttributes originAttributes;
 
   // The ID of the app containing this app/browser frame, if applicable.
   uint32_t frameOwnerAppId;
 
   // The origin without originAttribute suffix for a signed package.
   // This value would be empty if the TabContext doesn't own a signed
   // package.
   nsCString signedPkgOriginNoSuffix;
--- a/dom/ipc/TabContext.cpp
+++ b/dom/ipc/TabContext.cpp
@@ -263,19 +263,17 @@ TabContext::SetTabContext(bool aIsMozBro
   mShowAccelerators = aShowAccelerators;
   mShowFocusRings = aShowFocusRings;
   return true;
 }
 
 IPCTabContext
 TabContext::AsIPCTabContext() const
 {
-  nsAutoCString originSuffix;
-  mOriginAttributes.CreateSuffix(originSuffix);
-  return IPCTabContext(FrameIPCTabContext(originSuffix,
+  return IPCTabContext(FrameIPCTabContext(mOriginAttributes,
                                           mContainingAppId,
                                           mSignedPkgOriginNoSuffix,
                                           mIsMozBrowserElement,
                                           mIsPrerendered,
                                           mPresentationURL,
                                           mShowAccelerators,
                                           mShowFocusRings));
 }
@@ -294,17 +292,16 @@ GetAppForId(uint32_t aAppId)
 
 MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
   : mInvalidReason(nullptr)
 {
   bool isMozBrowserElement = false;
   bool isPrerendered = false;
   uint32_t containingAppId = NO_APP_ID;
   DocShellOriginAttributes originAttributes;
-  nsAutoCString originSuffix;
   nsAutoCString signedPkgOriginNoSuffix;
   nsAutoString presentationURL;
   UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
   UIStateChangeType showFocusRings = UIStateChangeType_NoChange;
 
   switch(aParams.type()) {
     case IPCTabContext::TPopupIPCTabContext: {
       const PopupIPCTabContext &ipcContext = aParams.get_PopupIPCTabContext();
@@ -363,21 +360,17 @@ MaybeInvalidTabContext::MaybeInvalidTabC
 
       isMozBrowserElement = ipcContext.isMozBrowserElement();
       isPrerendered = ipcContext.isPrerendered();
       containingAppId = ipcContext.frameOwnerAppId();
       signedPkgOriginNoSuffix = ipcContext.signedPkgOriginNoSuffix();
       presentationURL = ipcContext.presentationURL();
       showAccelerators = ipcContext.showAccelerators();
       showFocusRings = ipcContext.showFocusRings();
-      originSuffix = ipcContext.originSuffix();
-      if (!originAttributes.PopulateFromSuffix(originSuffix)) {
-        mInvalidReason = "Populate originAttributes from originSuffix failed.";
-        return;
-      }
+      originAttributes = ipcContext.originAttributes();
       break;
     }
     case IPCTabContext::TUnsafeIPCTabContext: {
       // XXXcatalinb: This used *only* by ServiceWorkerClients::OpenWindow.
       // It is meant as a temporary solution until service workers can
       // provide a TabChild equivalent. Don't allow this on b2g since
       // it might be used to escalate privileges.
 #ifdef MOZ_B2G