Bug 1238160 - Set docshell isolation mode. r=smaug draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 17 Feb 2016 21:53:32 -0600
changeset 331750 90957ccc6bf25320562db99970da574e1127a363
parent 331749 e442d24503f0ffdcdbb3647b526e93909678a626
child 331751 3491db1202203d6d37e3c7e7d37239a65ec521f6
child 331758 5d4c844e49c7698ce59a83270a3e3e34039d2d76
child 331763 ea89fa67bd580d4bf1c2a3fe358fe089846767de
push id11069
push userbmo:jryans@gmail.com
push dateThu, 18 Feb 2016 06:17:44 +0000
reviewerssmaug
bugs1238160
milestone47.0a1
Bug 1238160 - Set docshell isolation mode. r=smaug Renames nsDocShell isBrowser* attributes to add a "Moz" prefix for clarity. Adds nsDocShell::GetIsIsolatedMozBrowserElement, which parallels GetIsInIsolatedMozBrowserElement, but only checks the immediate docshell. Adds nsDocShell::SetIsInIsolatedMozBrowserElement for the frame loader and tab child to set the isolation state. nsDocShell methods related to mozbrowser elements (and their callers) are updated to use GetIs(In)?IsolatedMozBrowserElement when checking isolation / origins and GetIsMozBrowserElement when checking frame types. MozReview-Commit-ID: 6pGD5fF47ZN
devtools/shared/layout/utils.js
docshell/base/nsDSURIContentListener.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIDocShell.idl
dom/base/nsFrameLoader.cpp
dom/base/nsGlobalWindow.cpp
dom/browser-element/BrowserElementChild.js
dom/browser-element/BrowserElementCopyPaste.js
dom/ipc/TabChild.cpp
embedding/components/windowwatcher/nsWindowWatcher.cpp
xpfe/appshell/nsContentTreeOwner.cpp
--- a/devtools/shared/layout/utils.js
+++ b/devtools/shared/layout/utils.js
@@ -29,17 +29,17 @@ const utilsFor = memoize(
  * @param {DOMWindow} win
  * @return {DOMWindow}
  */
 function getTopWindow(win) {
   let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIWebNavigation)
                     .QueryInterface(Ci.nsIDocShell);
 
-  if (!docShell.isBrowserOrApp) {
+  if (!docShell.isMozBrowserOrApp) {
     return win.top;
   }
 
   let topDocShell = docShell.getSameTypeRootTreeItemIgnoreBrowserAndAppBoundaries();
 
   return topDocShell
           ? topDocShell.contentViewer.DOMDocument.defaultView
           : null;
@@ -89,17 +89,17 @@ function getParentWindow(win) {
   if (isTopWindow(win)) {
     return null;
   }
 
   let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
                  .getInterface(Ci.nsIWebNavigation)
                  .QueryInterface(Ci.nsIDocShell);
 
-  if (!docShell.isBrowserOrApp) {
+  if (!docShell.isMozBrowserOrApp) {
     return win.parent;
   }
 
   let parentDocShell = docShell.getSameTypeParentIgnoreBrowserAndAppBoundaries();
 
   return parentDocShell
           ? parentDocShell.contentViewer.DOMDocument.defaultView
           : null;
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -327,17 +327,17 @@ nsDSURIContentListener::CheckOneFrameOpt
 
   // Traverse up the parent chain and stop when we see a docshell whose
   // parent has a system principal, or a docshell corresponding to
   // <iframe mozbrowser>.
   while (NS_SUCCEEDED(
            curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
          parentDocShellItem) {
     nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
-    if (curDocShell && curDocShell->GetIsBrowserOrApp()) {
+    if (curDocShell && curDocShell->GetIsMozBrowserOrApp()) {
       break;
     }
 
     bool system = false;
     topDoc = parentDocShellItem->GetDocument();
     if (topDoc) {
       if (NS_SUCCEEDED(
             ssm->IsSystemPrincipal(topDoc->NodePrincipal(), &system)) &&
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -800,16 +800,17 @@ nsDocShell::nsDocShell()
   , mInEnsureScriptEnv(false)
 #endif
   , mAffectPrivateSessionLifetime(true)
   , mInvisible(false)
   , mHasLoadedNonBlankURI(false)
   , mDefaultLoadFlags(nsIRequest::LOAD_NORMAL)
   , mBlankTiming(false)
   , mFrameType(eFrameTypeRegular)
+  , mIsInIsolatedMozBrowser(false)
   , mOwnOrContainingAppId(nsIScriptSecurityManager::UNKNOWN_APP_ID)
   , mUserContextId(nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID)
   , mParentCharsetSource(0)
   , mJSRunToCompletionDepth(0)
 {
   mHistoryID = ++gDocshellIDCounter;
   if (gDocShellCount++ == 0) {
     NS_ASSERTION(sURIFixup == nullptr,
@@ -2551,17 +2552,17 @@ nsDocShell::GetFullscreenAllowed(bool* a
   // Otherwise, we have a parent, continue the checking for
   // mozFullscreenAllowed in the parent docshell's ancestors.
   return parent->GetFullscreenAllowed(aFullscreenAllowed);
 }
 
 NS_IMETHODIMP
 nsDocShell::SetFullscreenAllowed(bool aFullscreenAllowed)
 {
-  if (!nsIDocShell::GetIsBrowserOrApp()) {
+  if (!nsIDocShell::GetIsMozBrowserOrApp()) {
     // Only allow setting of fullscreenAllowed on content/process boundaries.
     // At non-boundaries the fullscreenAllowed attribute is calculated based on
     // whether all enclosing frames have the "mozFullscreenAllowed" attribute
     // set to "true". fullscreenAllowed is set at the process boundaries to
     // propagate the value of the parent's "mozFullscreenAllowed" attribute
     // across process boundaries.
     return NS_ERROR_UNEXPECTED;
   }
@@ -3356,17 +3357,17 @@ nsDocShell::SetDocLoaderParent(nsDocLoad
 }
 
 NS_IMETHODIMP
 nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
 {
   NS_ENSURE_ARG_POINTER(aParent);
   *aParent = nullptr;
 
-  if (nsIDocShell::GetIsBrowserOrApp()) {
+  if (nsIDocShell::GetIsMozBrowserOrApp()) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIDocShellTreeItem> parent =
     do_QueryInterface(GetAsSupports(mParent));
   if (!parent) {
     return NS_OK;
   }
@@ -4010,16 +4011,17 @@ nsDocShell::AddChild(nsIDocShellTreeItem
   }
 
   if (aChild->ItemType() != mItemType) {
     return NS_OK;
   }
 
   aChild->SetTreeOwner(mTreeOwner);
   childDocShell->SetUserContextId(mUserContextId);
+  childDocShell->SetIsInIsolatedMozBrowserElement(mIsInIsolatedMozBrowser);
 
   nsCOMPtr<nsIDocShell> childAsDocShell(do_QueryInterface(aChild));
   if (!childAsDocShell) {
     return NS_OK;
   }
 
   // charset, style-disabling, and zoom will be inherited in SetupNewViewer()
 
@@ -6110,17 +6112,17 @@ nsDocShell::SetIsActiveInternal(bool aIs
   // children; they handle their state separately.
   nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
   while (iter.HasMore()) {
     nsCOMPtr<nsIDocShell> docshell = do_QueryObject(iter.GetNext());
     if (!docshell) {
       continue;
     }
 
-    if (!docshell->GetIsBrowserOrApp()) {
+    if (!docshell->GetIsMozBrowserOrApp()) {
       if (aIsHidden) {
         docshell->SetIsActive(aIsActive);
       } else {
         docshell->SetIsActiveAndForeground(aIsActive);
       }
     }
   }
 
@@ -13872,39 +13874,32 @@ nsDocShell::SetUserContextId(uint32_t aU
 
     docshell->SetUserContextId(aUserContextId);
   }
 
   return NS_OK;
 }
 
 /* [infallible] */ NS_IMETHODIMP
-nsDocShell::GetIsBrowserElement(bool* aIsBrowser)
-{
-  *aIsBrowser = (mFrameType == eFrameTypeBrowser);
-  return NS_OK;
-}
-
-/* [infallible] */ NS_IMETHODIMP
 nsDocShell::GetIsApp(bool* aIsApp)
 {
   *aIsApp = (mFrameType == eFrameTypeApp);
   return NS_OK;
 }
 
 /* [infallible] */ NS_IMETHODIMP
-nsDocShell::GetIsBrowserOrApp(bool* aIsBrowserOrApp)
+nsDocShell::GetIsMozBrowserOrApp(bool* aIsMozBrowserOrApp)
 {
   switch (mFrameType) {
     case eFrameTypeRegular:
-      *aIsBrowserOrApp = false;
+      *aIsMozBrowserOrApp = false;
       break;
     case eFrameTypeBrowser:
     case eFrameTypeApp:
-      *aIsBrowserOrApp = true;
+      *aIsMozBrowserOrApp = true;
       break;
   }
 
   return NS_OK;
 }
 
 nsDocShell::FrameType
 nsDocShell::GetInheritedFrameType()
@@ -13920,32 +13915,49 @@ nsDocShell::GetInheritedFrameType()
   if (!parent) {
     return eFrameTypeRegular;
   }
 
   return static_cast<nsDocShell*>(parent.get())->GetInheritedFrameType();
 }
 
 /* [infallible] */ NS_IMETHODIMP
+nsDocShell::GetIsIsolatedMozBrowserElement(bool* aIsIsolatedMozBrowserElement)
+{
+  bool result = mFrameType == eFrameTypeBrowser && mIsInIsolatedMozBrowser;
+  *aIsIsolatedMozBrowserElement = result;
+  return NS_OK;
+}
+
+/* [infallible] */ NS_IMETHODIMP
 nsDocShell::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
 {
-  *aIsInIsolatedMozBrowserElement = (GetInheritedFrameType() == eFrameTypeBrowser);
+  bool result = (GetInheritedFrameType() == eFrameTypeBrowser) &&
+                mIsInIsolatedMozBrowser;
+  *aIsInIsolatedMozBrowserElement = result;
   return NS_OK;
 }
 
 /* [infallible] */ NS_IMETHODIMP
-nsDocShell::GetIsInBrowserOrApp(bool* aIsInBrowserOrApp)
+nsDocShell::SetIsInIsolatedMozBrowserElement(bool aIsInIsolatedMozBrowserElement)
+{
+  mIsInIsolatedMozBrowser = aIsInIsolatedMozBrowserElement;
+  return NS_OK;
+}
+
+/* [infallible] */ NS_IMETHODIMP
+nsDocShell::GetIsInMozBrowserOrApp(bool* aIsInMozBrowserOrApp)
 {
   switch (GetInheritedFrameType()) {
     case eFrameTypeRegular:
-      *aIsInBrowserOrApp = false;
+      *aIsInMozBrowserOrApp = false;
       break;
     case eFrameTypeBrowser:
     case eFrameTypeApp:
-      *aIsInBrowserOrApp = true;
+      *aIsInMozBrowserOrApp = true;
       break;
   }
 
   return NS_OK;
 }
 
 /* [infallible] */ NS_IMETHODIMP
 nsDocShell::GetAppId(uint32_t* aAppId)
@@ -13983,17 +13995,17 @@ nsDocShell::GetOriginAttributes()
 
   if (mOwnOrContainingAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
     attrs.mAppId = mOwnOrContainingAppId;
   }
 
   attrs.mUserContextId = mUserContextId;
 
   if (mFrameType == eFrameTypeBrowser) {
-    attrs.mInIsolatedMozBrowser = true;
+    attrs.mInIsolatedMozBrowser = mIsInIsolatedMozBrowser;
   }
 
   return attrs;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetOriginAttributes(JS::MutableHandle<JS::Value> aVal)
 {
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -993,16 +993,19 @@ protected:
   // This flag means that mTiming has been initialized but nulled out.
   // We will check the innerWin's timing before creating a new one
   // in MaybeInitTiming()
   bool mBlankTiming;
 
   // Are we a regular frame, a browser frame, or an app frame?
   FrameType mFrameType;
 
+  // Whether we are in an isolated mozbrowser frame.
+  bool mIsInIsolatedMozBrowser;
+
   // We only expect mOwnOrContainingAppId to be something other than
   // UNKNOWN_APP_ID if mFrameType != eFrameTypeRegular. For vanilla iframes
   // inside an app, we'll retrieve the containing app-id by walking up the
   // docshell hierarchy.
   //
   // (This needs to be the docshell's own /or containing/ app id because the
   // containing app frame might be in another process, in which case we won't
   // find it by walking up the docshell hierarchy.)
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -759,58 +759,64 @@ interface nsIDocShell : nsIDocShellTreeI
 
   /**
    * Notify all attached observers that the scroll position of some element
    * has changed.
    */
   [noscript] void notifyScrollObservers();
 
   /**
-   * Returns true if this docshell corresponds to an <iframe mozbrowser>.
-   * (<iframe mozapp mozbrowser> is not considered a browser.)
-   */
-  [infallible] readonly attribute boolean isBrowserElement;
-
-  /**
    * Returns true iff the docshell corresponds to an <iframe mozapp>.
    */
   [infallible] readonly attribute boolean isApp;
 
   /**
-   * Returns isBrowserElement || isApp.
+   * Returns true if this docshell corresponds to an <iframe mozbrowser> or
+   * <iframe mozapp>.  <xul:browser> returns false here.
    */
-  [infallible] readonly attribute boolean isBrowserOrApp;
+  [infallible] readonly attribute boolean isMozBrowserOrApp;
+
+  /**
+   * Returns true if this docshell corresponds to an isolated <iframe
+   * mozbrowser>.
+   *
+   * <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
+   * mozbrowser elements.  <iframe mozbrowser noisolation> does not count as
+   * isolated since isolation is disabled.  Isolation can only be disabled if
+   * the containing document is chrome.
+   */
+  [infallible] readonly attribute boolean isIsolatedMozBrowserElement;
 
   /**
    * Returns true if this docshell corresponds to an isolated <iframe
    * mozbrowser> or if the docshell is contained in an isolated <iframe
    * mozbrowser>.
    *
    * <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
    * mozbrowser elements.  <iframe mozbrowser noisolation> does not count as
    * isolated since isolation is disabled.  Isolation can only be disabled if
    * the containing document is chrome.
    *
    * Our notion here of "contained in" means: Walk up the docshell hierarchy in
    * this process until we hit an <iframe mozapp> or <iframe mozbrowser> (or
    * until the hierarchy ends).  Return true iff the docshell we stopped on has
    * isIsolatedMozBrowserElement == true.
    */
-  [infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
+  [infallible] attribute boolean isInIsolatedMozBrowserElement;
 
   /**
    * Returns true if this docshell corresponds to an <iframe mozbrowser> or
    * <iframe mozapp>, or if this docshell is contained in an <iframe mozbrowser>
-   * or <iframe mozapp>.
+   * or <iframe mozapp>.  <xul:browser> returns false here.
    *
    * To compute this value, we walk up the docshell hierarchy.  If we encounter
-   * a docshell with isBrowserElement or isApp before we hit the end of the
-   * hierarchy, we return true.  Otherwise, we return false.
+   * a docshell with isMozBrowserOrApp before we hit the end of the hierarchy,
+   * we return true.  Otherwise, we return false.
    */
-  [infallible] readonly attribute boolean isInBrowserOrApp;
+  [infallible] readonly attribute boolean isInMozBrowserOrApp;
 
    /**
     * Indicate that this docshell corresponds to an app with the given app id.
     *
     * You may pass NO_APP_ID or UNKNOWN_APP_ID for containingAppId.  If you
     * pass NO_APP_ID, then this docshell will return NO_APP_ID for appId.  If
     * you pass UNKNOWN_APP_ID, then this docshell will search its hiearchy for
     * an app frame and use that frame's appId.
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1195,18 +1195,18 @@ nsFrameLoader::SwapWithOtherLoader(nsFra
   NS_ASSERTION(otherDoc == otherParentDocument, "Unexpected parent document");
 
   nsIPresShell* ourShell = ourDoc->GetShell();
   nsIPresShell* otherShell = otherDoc->GetShell();
   if (!ourShell || !otherShell) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
-  if (ourDocshell->GetIsBrowserElement() !=
-      otherDocshell->GetIsBrowserElement() ||
+  if (ourDocshell->GetIsIsolatedMozBrowserElement() !=
+      otherDocshell->GetIsIsolatedMozBrowserElement() ||
       ourDocshell->GetIsApp() != otherDocshell->GetIsApp()) {
       return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   if (mInSwap || aOther->mInSwap) {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
   AutoResetInFrameSwap autoFrameSwap(this, aOther, ourDocshell, otherDocshell,
@@ -1908,16 +1908,17 @@ nsFrameLoader::MaybeCreateDocShell()
 
     nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
     uint32_t containingAppId = nsIScriptSecurityManager::NO_APP_ID;
     if (containingApp) {
       NS_ENSURE_SUCCESS(containingApp->GetLocalId(&containingAppId),
                         NS_ERROR_FAILURE);
     }
     mDocShell->SetIsBrowserInsideApp(containingAppId);
+    mDocShell->SetIsInIsolatedMozBrowserElement(OwnerIsIsolatedMozBrowserFrame());
   }
 
   if (OwnerIsMozBrowserOrAppFrame()) {
     // For inproc frames, set the docshell properties.
     nsCOMPtr<nsIDocShellTreeItem> item = do_GetInterface(docShell);
     nsAutoString name;
     if (mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
       item->SetName(name);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3793,17 +3793,17 @@ nsGlobalWindow::GetParentOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return nullptr;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> parent;
-  if (mDocShell->GetIsBrowserOrApp()) {
+  if (mDocShell->GetIsMozBrowserOrApp()) {
     parent = AsOuter();
   } else {
     parent = GetParent();
   }
 
   return parent.forget();
 }
 
@@ -3959,17 +3959,17 @@ nsGlobalWindow::GetContentInternal(Error
   nsCOMPtr<nsPIDOMWindowOuter> domWindow =
     GetChildWindow(NS_LITERAL_STRING("content"));
   if (domWindow) {
     return domWindow.forget();
   }
 
   // If we're contained in <iframe mozbrowser> or <iframe mozapp>, then
   // GetContent is the same as window.top.
-  if (mDocShell && mDocShell->GetIsInBrowserOrApp()) {
+  if (mDocShell && mDocShell->GetIsInMozBrowserOrApp()) {
     return GetTopOuter();
   }
 
   nsCOMPtr<nsIDocShellTreeItem> primaryContent;
   if (aUnprivilegedCaller) {
     // If we're called by non-chrome code, make sure we don't return
     // the primary content window if the calling tab is hidden. In
     // such a case we return the same-type root in the hidden tab,
@@ -7109,17 +7109,17 @@ void
 nsGlobalWindow::ResizeToOuter(int32_t aWidth, int32_t aHeight, ErrorResult& aError, bool aCallerIsChrome)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   /*
    * If caller is a browser-element then dispatch a resize event to
    * the embedder.
    */
-  if (mDocShell && mDocShell->GetIsBrowserOrApp()) {
+  if (mDocShell && mDocShell->GetIsMozBrowserOrApp()) {
     CSSIntSize size(aWidth, aHeight);
     if (!DispatchResizeEvent(size)) {
       // The embedder chose to prevent the default action for this
       // event, so let's not resize this window after all...
       return;
     }
   }
 
@@ -7157,17 +7157,17 @@ nsGlobalWindow::ResizeByOuter(int32_t aW
                               ErrorResult& aError, bool aCallerIsChrome)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   /*
    * If caller is a browser-element then dispatch a resize event to
    * parent.
    */
-  if (mDocShell && mDocShell->GetIsBrowserOrApp()) {
+  if (mDocShell && mDocShell->GetIsMozBrowserOrApp()) {
     CSSIntSize size;
     if (NS_FAILED(GetInnerSize(size))) {
       return;
     }
 
     size.width += aWidthDif;
     size.height += aHeightDif;
 
@@ -8104,17 +8104,17 @@ nsGlobalWindow::CanClose()
 }
 
 void
 nsGlobalWindow::CloseOuter(bool aTrustedCaller)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell || IsInModalState() ||
-      (IsFrame() && !mDocShell->GetIsBrowserOrApp())) {
+      (IsFrame() && !mDocShell->GetIsMozBrowserOrApp())) {
     // window.close() is called on a frame in a frameset, on a window
     // that's already closed, or on a window for which there's
     // currently a modal dialog open. Ignore such calls.
     return;
   }
 
   if (mHavePendingClose) {
     // We're going to be closed anyway; do nothing since we don't want
@@ -8631,17 +8631,17 @@ nsGlobalWindow::CacheXBLPrototypeHandler
   mCachedXBLPrototypeHandlers->Put(aKey, aHandler);
 }
 
 Element*
 nsGlobalWindow::GetFrameElementOuter()
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
-  if (!mDocShell || mDocShell->GetIsBrowserOrApp()) {
+  if (!mDocShell || mDocShell->GetIsMozBrowserOrApp()) {
     return nullptr;
   }
 
   // Per HTML5, the frameElement getter returns null in cross-origin situations.
   Element* element = GetRealFrameElementOuter();
   if (!element) {
     return nullptr;
   }
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -21,17 +21,17 @@ function parentDocShell(docshell) {
   }
   let treeitem = docshell.QueryInterface(Ci.nsIDocShellTreeItem);
   return treeitem.parent ? treeitem.parent.QueryInterface(Ci.nsIDocShell) : null;
 }
 
 function isTopBrowserElement(docShell) {
   while (docShell) {
     docShell = parentDocShell(docShell);
-    if (docShell && docShell.isBrowserOrApp) {
+    if (docShell && docShell.isMozBrowserOrApp) {
       return false;
     }
   }
   return true;
 }
 
 if (!('BrowserElementIsPreloaded' in this)) {
   if (isTopBrowserElement(docShell)) {
--- a/dom/browser-element/BrowserElementCopyPaste.js
+++ b/dom/browser-element/BrowserElementCopyPaste.js
@@ -84,17 +84,17 @@ var CopyPasteAssistent = {
       detail.rect.bottom += currentRect.top;
       detail.rect.left += currentRect.left;
       detail.rect.right += currentRect.left;
       currentWindow = currentWindow.realFrameElement.ownerDocument.defaultView;
 
       let targetDocShell = currentWindow
           .QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIWebNavigation);
-      if(targetDocShell.isBrowserOrApp) {
+      if(targetDocShell.isMozBrowserOrApp) {
         break;
       }
     }
 
     sendAsyncMsg('caretstatechanged', detail);
   },
 };
 
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -827,16 +827,19 @@ TabChild::NotifyTabContextUpdated()
     nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
     MOZ_ASSERT(docShell);
 
     if (docShell) {
         // nsDocShell will do the right thing if we pass NO_APP_ID or
         // UNKNOWN_APP_ID for aOwnOrContainingAppId.
         if (IsBrowserElement()) {
           docShell->SetIsBrowserInsideApp(BrowserOwnerAppId());
+          // TODO: Wants to call TabContext::IsIsolatedMozBrowserElement() based
+          // on isolation in principal, which is added in a later patch.
+          docShell->SetIsInIsolatedMozBrowserElement(IsBrowserElement());
         } else {
           docShell->SetIsApp(OwnAppId());
         }
 
         OriginAttributes attrs = OriginAttributesRef();
         docShell->SetIsSignedPackage(attrs.mSignedPkg);
         docShell->SetUserContextId(attrs.mUserContextId);
     }
@@ -1070,17 +1073,17 @@ TabChild::ProvideWindow(mozIDOMWindowPro
                         mozIDOMWindowProxy** aReturn)
 {
     *aReturn = nullptr;
 
     // If aParent is inside an <iframe mozbrowser> or <iframe mozapp> and this
     // isn't a request to open a modal-type window, we're going to create a new
     // <iframe mozbrowser/mozapp> and return its window here.
     nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
-    bool iframeMoz = (docshell && docshell->GetIsInBrowserOrApp() &&
+    bool iframeMoz = (docshell && docshell->GetIsInMozBrowserOrApp() &&
                       !(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
                                         nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
                                         nsIWebBrowserChrome::CHROME_OPENAS_CHROME)));
 
     if (!iframeMoz) {
       int32_t openLocation =
         nsWindowWatcher::GetWindowOpenLocation(nsPIDOMWindowOuter::From(aParent),
                                                aChromeFlags, aCalledFromJS,
--- a/embedding/components/windowwatcher/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp
@@ -1693,17 +1693,17 @@ nsWindowWatcher::CalculateChromeFlags(mo
   if (!(chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) {
     // Remove the dependent flag if we're not opening as chrome
     chromeFlags &= ~nsIWebBrowserChrome::CHROME_DEPENDENT;
   }
 
   // Disable CHROME_OPENAS_DIALOG if the window is inside <iframe mozbrowser>.
   // It's up to the embedder to interpret what dialog=1 means.
   nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
-  if (docshell && docshell->GetIsInBrowserOrApp()) {
+  if (docshell && docshell->GetIsInMozBrowserOrApp()) {
     chromeFlags &= ~nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
   }
 
   return chromeFlags;
 }
 
 // static
 int32_t
--- a/xpfe/appshell/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/nsContentTreeOwner.cpp
@@ -876,17 +876,17 @@ nsContentTreeOwner::ProvideWindow(mozIDO
                                static_cast<nsIDocShellTreeOwner*>(this)),
                "Parent from wrong docshell tree?");
 #endif
 
   // If aParent is inside an <iframe mozbrowser> and this isn't a request to
   // open a modal-type window, we're going to create a new <iframe mozbrowser>
   // and return its window here.
   nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
-  if (docshell && docshell->GetIsInBrowserOrApp() &&
+  if (docshell && docshell->GetIsInMozBrowserOrApp() &&
       !(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
                         nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
                         nsIWebBrowserChrome::CHROME_OPENAS_CHROME))) {
 
     BrowserElementParent::OpenWindowResult opened =
       BrowserElementParent::OpenWindowInProcess(parent, aURI, aName,
                                                 aFeatures, aReturn);