diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index e5f142f8279..14873d855b7 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -52,6 +52,7 @@ #include "nsIPermissionManager.h" #include "nsISHistory.h" #include "nsNullPrincipal.h" +#include "nsIScriptError.h" #include "nsLayoutUtils.h" #include "nsView.h" @@ -1762,6 +1763,30 @@ nsFrameLoader::MaybeCreateDocShell() NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"), /* allowDelayedLoad = */ true, /* aRunInGlobalScope */ true); + // For inproc frames, set the docshell properties. + nsCOMPtr item = do_GetInterface(docShell); + nsAutoString name; + if (mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) { + item->SetName(name); + } + mDocShell->SetFullscreenAllowed( + mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) || + mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)); + bool isPrivate = mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing); + if (isPrivate) { + bool nonBlank; + mDocShell->GetHasLoadedNonBlankURI(&nonBlank); + if (nonBlank) { + nsContentUtils::ReportToConsoleNonLocalized( + NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."), + nsIScriptError::warningFlag, + NS_LITERAL_CSTRING("mozprivatebrowsing"), + nullptr); + } else { + nsCOMPtr context = do_GetInterface(mDocShell); + context->SetUsePrivateBrowsing(true); + } + } } return NS_OK; diff --git a/dom/browser-element/BrowserElementChild.js b/dom/browser-element/BrowserElementChild.js index 4996b178e0f..81747115e43 100644 --- a/dom/browser-element/BrowserElementChild.js +++ b/dom/browser-element/BrowserElementChild.js @@ -52,14 +52,5 @@ if (!('BrowserElementIsPreloaded' in this)) { var BrowserElementIsReady = true; -let infos = sendSyncMessage('browser-element-api:call', - { 'msg_name': 'hello' })[0]; -docShell.QueryInterface(Ci.nsIDocShellTreeItem).name = infos.name; -docShell.setFullscreenAllowed(infos.fullscreenAllowed); -if (infos.isPrivate) { - if (docShell.hasLoadedNonBlankURI) { - Cu.reportError("We should not switch to Private Browsing after loading a document."); - } else { - docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true; - } -} + +sendAsyncMessage('browser-element-api:call', { 'msg_name': 'hello' }); diff --git a/dom/browser-element/BrowserElementParent.js b/dom/browser-element/BrowserElementParent.js index 038434fa1f5..42f9a94c267 100644 --- a/dom/browser-element/BrowserElementParent.js +++ b/dom/browser-element/BrowserElementParent.js @@ -325,14 +325,6 @@ BrowserElementParent.prototype = { this._domRequestReady = true; this._runPendingAPICall(); } - - return { - name: this._frameElement.getAttribute('name'), - fullscreenAllowed: - this._frameElement.hasAttribute('allowfullscreen') || - this._frameElement.hasAttribute('mozallowfullscreen'), - isPrivate: this._frameElement.hasAttribute('mozprivatebrowsing') - }; }, _fireCtxMenuEvent: function(data) { diff --git a/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html b/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html index 3694f621705..c4fa25d26bb 100644 --- a/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html +++ b/dom/browser-element/mochitest/file_browserElement_SetVisibleFrames2_Outer.html @@ -15,10 +15,6 @@ iframe.addEventListener('mozbrowsershowmodalprompt', function(e) { }, 0); }, 0); } - else { - // Pass the message up to our parent. - alert(e.detail.message); - } }); document.body.appendChild(iframe); diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 93f34ffa8df..aec8a18047c 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -69,6 +69,13 @@ union MaybeNativeKeyBinding void_t; }; +struct ShowInfo +{ + nsString name; + bool fullscreenAllowed; + bool isPrivate; +}; + prio(normal upto urgent) intr protocol PBrowser { manager PContent or PContentBridge; @@ -411,6 +418,7 @@ child: * point. */ Show(nsIntSize size, + ShowInfo info, ScrollingBehavior scrolling, TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId, diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 7d850ba69dc..cd343643580 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -90,6 +90,7 @@ #include "nsIAppsService.h" #include "nsNetUtil.h" #include "nsIPermissionManager.h" +#include "nsIScriptError.h" #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") @@ -1881,10 +1882,36 @@ TabChild::DoFakeShow(const ScrollingBehavior& aScrolling, const uint64_t& aLayersId, PRenderFrameChild* aRenderFrame) { - RecvShow(nsIntSize(0, 0), aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame); + ShowInfo info(EmptyString(), false, false); + RecvShow(nsIntSize(0, 0), info, aScrolling, aTextureFactoryIdentifier, aLayersId, aRenderFrame); mDidFakeShow = true; } +void +TabChild::ApplyShowInfo(const ShowInfo& aInfo) +{ + nsCOMPtr docShell = do_GetInterface(WebNavigation()); + if (docShell) { + nsCOMPtr item = do_GetInterface(docShell); + item->SetName(aInfo.name()); + docShell->SetFullscreenAllowed(aInfo.fullscreenAllowed()); + if (aInfo.isPrivate()) { + bool nonBlank; + docShell->GetHasLoadedNonBlankURI(&nonBlank); + if (nonBlank) { + nsContentUtils::ReportToConsoleNonLocalized( + NS_LITERAL_STRING("We should not switch to Private Browsing after loading a document."), + nsIScriptError::warningFlag, + NS_LITERAL_CSTRING("mozprivatebrowsing"), + nullptr); + } else { + nsCOMPtr context = do_GetInterface(docShell); + context->SetUsePrivateBrowsing(true); + } + } + } +} + #ifdef MOZ_WIDGET_GONK void TabChild::MaybeRequestPreinitCamera() @@ -1945,6 +1972,7 @@ TabChild::MaybeRequestPreinitCamera() bool TabChild::RecvShow(const nsIntSize& aSize, + const ShowInfo& aInfo, const ScrollingBehavior& aScrolling, const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, @@ -1953,6 +1981,7 @@ TabChild::RecvShow(const nsIntSize& aSize, MOZ_ASSERT((!mDidFakeShow && aRenderFrame) || (mDidFakeShow && !aRenderFrame)); if (mDidFakeShow) { + ApplyShowInfo(aInfo); return true; } @@ -1976,7 +2005,9 @@ TabChild::RecvShow(const nsIntSize& aSize, MaybeRequestPreinitCamera(); #endif - return InitTabChildGlobal(); + bool res = InitTabChildGlobal(); + ApplyShowInfo(aInfo); + return res; } bool diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index ff0243a5e5e..8b84a78fdd2 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -317,6 +317,7 @@ public: const FileDescriptor& aFileDescriptor) MOZ_OVERRIDE; virtual bool RecvShow(const nsIntSize& aSize, + const ShowInfo& aInfo, const ScrollingBehavior& aScrolling, const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, @@ -552,6 +553,8 @@ private: const uint64_t& aLayersId, PRenderFrameChild* aRenderFrame); + void ApplyShowInfo(const ShowInfo& aInfo); + // These methods are used for tracking synthetic mouse events // dispatched for compatibility. On each touch event, we // UpdateTapState(). If we've detected that the current gesture diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 7f9f1b4e68e..0b065ce9585 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -600,7 +600,19 @@ TabParent::Show(const nsIntSize& size) unused << SendPRenderFrameConstructor(renderFrame); } } - unused << SendShow(size, scrolling, textureFactoryIdentifier, layersId, renderFrame); + + ShowInfo info(EmptyString(), false, false); + if (mFrameElement) { + nsAutoString name; + mFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name); + bool allowFullscreen = + mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) || + mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen); + bool isPrivate = mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing); + info = ShowInfo(name, allowFullscreen, isPrivate); + } + + unused << SendShow(size, info, scrolling, textureFactoryIdentifier, layersId, renderFrame); } void