зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1502328 - Add opener member to BrowsingContext and expose through webidl. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D10580 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c30e8ca9f0
Коммит
af6942ecbc
|
@ -284,6 +284,25 @@ BrowsingContext::GetChildren(nsTArray<RefPtr<BrowsingContext>>& aChildren)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
BrowsingContext::SetOpener(BrowsingContext* aOpener)
|
||||
{
|
||||
if (mOpener == aOpener) {
|
||||
return;
|
||||
}
|
||||
|
||||
mOpener = aOpener;
|
||||
|
||||
if (!XRE_IsContentProcess()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_DIAGNOSTIC_ASSERT(cc);
|
||||
cc->SendSetOpenerBrowsingContext(BrowsingContextId(Id()),
|
||||
BrowsingContextId(aOpener ? aOpener->Id() : 0));
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
BrowsingContext::GetRootBrowsingContexts(nsTArray<RefPtr<BrowsingContext>>& aBrowsingContexts)
|
||||
{
|
||||
|
|
|
@ -111,6 +111,13 @@ public:
|
|||
|
||||
void GetChildren(nsTArray<RefPtr<BrowsingContext>>& aChildren);
|
||||
|
||||
BrowsingContext* GetOpener()
|
||||
{
|
||||
return mOpener;
|
||||
}
|
||||
|
||||
void SetOpener(BrowsingContext* aOpener);
|
||||
|
||||
static void GetRootBrowsingContexts(
|
||||
nsTArray<RefPtr<BrowsingContext>>& aBrowsingContexts);
|
||||
|
||||
|
@ -141,6 +148,7 @@ private:
|
|||
|
||||
WeakPtr<BrowsingContext> mParent;
|
||||
Children mChildren;
|
||||
WeakPtr<BrowsingContext> mOpener;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
nsString mName;
|
||||
};
|
||||
|
|
|
@ -2243,6 +2243,9 @@ nsGlobalWindowOuter::SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
|
|||
{
|
||||
nsWeakPtr opener = do_GetWeakReference(aOpener);
|
||||
if (opener == mOpener) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(
|
||||
!aOpener || (GetBrowsingContext() && GetBrowsingContext()->GetOpener() ==
|
||||
aOpener->GetBrowsingContext()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2255,6 +2258,13 @@ nsGlobalWindowOuter::SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
|
|||
mOpener = opener.forget();
|
||||
NS_ASSERTION(mOpener || !aOpener, "Opener must support weak references!");
|
||||
|
||||
if (mDocShell && aOpener) {
|
||||
// TODO(farre): Here we really wish to only consider the case
|
||||
// where 'aOriginalOpener' is false, and we also really want to
|
||||
// move opener entirely to BrowsingContext. See bug 1502330.
|
||||
GetBrowsingContext()->SetOpener(aOpener->GetBrowsingContext());
|
||||
}
|
||||
|
||||
// Check that the js visible opener matches! We currently don't depend on this
|
||||
// being true outside of nightly, so we disable the assertion in optimized
|
||||
// release / beta builds.
|
||||
|
@ -7868,3 +7878,9 @@ nsAutoPopupStatePusherInternal::~nsAutoPopupStatePusherInternal()
|
|||
{
|
||||
nsContentUtils::PopPopupControlState(mOldState);
|
||||
}
|
||||
|
||||
mozilla::dom::BrowsingContext*
|
||||
nsPIDOMWindowOuter::GetBrowsingContext() const
|
||||
{
|
||||
return mDocShell ? nsDocShell::Cast(mDocShell)->GetBrowsingContext() : nullptr;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace mozilla {
|
|||
class AutoplayPermissionManager;
|
||||
namespace dom {
|
||||
class AudioContext;
|
||||
class BrowsingContext;
|
||||
class ClientInfo;
|
||||
class ClientState;
|
||||
class ContentFrameMessageManager;
|
||||
|
@ -929,6 +930,8 @@ public:
|
|||
*/
|
||||
inline nsIDocShell *GetDocShell() const;
|
||||
|
||||
mozilla::dom::BrowsingContext* GetBrowsingContext() const;
|
||||
|
||||
/**
|
||||
* Set a new document in the window. Calling this method will in most cases
|
||||
* create a new inner window. This may be called with a pointer to the current
|
||||
|
|
|
@ -14,4 +14,6 @@ interface BrowsingContext {
|
|||
readonly attribute nsIDocShell? docShell;
|
||||
|
||||
readonly attribute unsigned long long id;
|
||||
|
||||
readonly attribute BrowsingContext? opener;
|
||||
};
|
||||
|
|
|
@ -6098,3 +6098,39 @@ ContentParent::RecvDetachBrowsingContext(const BrowsingContextId& aContextId,
|
|||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentParent::RecvSetOpenerBrowsingContext(
|
||||
const BrowsingContextId& aContextId,
|
||||
const BrowsingContextId& aOpenerContextId)
|
||||
{
|
||||
RefPtr<ChromeBrowsingContext> context = ChromeBrowsingContext::Get(aContextId);
|
||||
|
||||
if (!context) {
|
||||
MOZ_LOG(BrowsingContext::GetLog(),
|
||||
LogLevel::Debug,
|
||||
("ParentIPC: Trying to set opener already detached 0x%08" PRIx64,
|
||||
(uint64_t)aContextId));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
if (!context->IsOwnedByProcess(ChildID())) {
|
||||
// Where trying to set opener on a child BrowsingContext in
|
||||
// another child process. This is illegal since the owner of the
|
||||
// BrowsingContext is the proccess with the in-process docshell,
|
||||
// which is tracked by OwnerProcessId.
|
||||
|
||||
// TODO(farre): To crash or not to crash. Same reasoning as in
|
||||
// above TODO. [Bug 1471598]
|
||||
MOZ_LOG(BrowsingContext::GetLog(),
|
||||
LogLevel::Warning,
|
||||
("ParentIPC: Trying to set opener on out of process context 0x%08" PRIx64,
|
||||
context->Id()));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<BrowsingContext> opener = BrowsingContext::Get(aOpenerContextId);
|
||||
context->SetOpener(opener);
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
@ -685,6 +685,10 @@ public:
|
|||
const BrowsingContextId& aContextId,
|
||||
const bool& aMoveToBFCache) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvSetOpenerBrowsingContext(
|
||||
const BrowsingContextId& aContextId,
|
||||
const BrowsingContextId& aOpenerContextId) override;
|
||||
|
||||
protected:
|
||||
void OnChannelConnected(int32_t pid) override;
|
||||
|
||||
|
|
|
@ -1190,6 +1190,14 @@ parent:
|
|||
*/
|
||||
async DetachBrowsingContext(BrowsingContextId aContextId,
|
||||
bool aMoveToBFCache);
|
||||
|
||||
/**
|
||||
* Set the opener of browsing context with id 'aContextId' to the
|
||||
* browsing context with id 'aOpenerId'.
|
||||
*/
|
||||
async SetOpenerBrowsingContext(BrowsingContextId aContextId,
|
||||
BrowsingContextId aOpenerContextId);
|
||||
|
||||
both:
|
||||
async AsyncMessage(nsString aMessage, CpowEntry[] aCpows,
|
||||
Principal aPrincipal, ClonedMessageData aData);
|
||||
|
|
Загрузка…
Ссылка в новой задаче