mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 02:25:34 +00:00
Bug 865745 - Hold a strong ref to the global for the duration that each nsFrameScriptCx is on the stack. r=smaug
These things currently do a complicated refcounting dance to avoid destroying the cx until all the consumers of it are gone. That stuff can mostly go away now that we're just using the SafeJSContext, but DestroyCx also nulls out the global, so we should make sure to keep that alive for anyone that might be using it.
This commit is contained in:
parent
ba3407d692
commit
b4f2e0c87d
@ -2224,6 +2224,7 @@ public:
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mFrameLoader->mChildMessageManager.get());
|
||||
if (tabChild && tabChild->GetInnerManager()) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> kungFuDeathGrip(tabChild->GetGlobal());
|
||||
nsFrameScriptCx cx(static_cast<EventTarget*>(tabChild), tabChild);
|
||||
|
||||
StructuredCloneData data;
|
||||
|
@ -285,6 +285,11 @@ class nsFrameScriptExecutor
|
||||
{
|
||||
public:
|
||||
static void Shutdown();
|
||||
already_AddRefed<nsIXPConnectJSObjectHolder> GetGlobal()
|
||||
{
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> ref = mGlobal;
|
||||
return ref.forget();
|
||||
}
|
||||
protected:
|
||||
friend class nsFrameScriptCx;
|
||||
nsFrameScriptExecutor() : mCx(nullptr), mCxStackRefCnt(0),
|
||||
|
@ -1445,6 +1445,7 @@ TabChild::DispatchMessageManagerMessage(const nsAString& aMessageName,
|
||||
cloneData.mDataLength = buffer.nbytes();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> kungFuDeathGrip(GetGlobal());
|
||||
nsFrameScriptCx frameScriptCx(static_cast<nsIWebBrowserChrome*>(this), this);
|
||||
// Let the BrowserElementScrolling helper (if it exists) for this
|
||||
// content manipulate the frame state.
|
||||
@ -2009,6 +2010,7 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
|
||||
const ClonedMessageData& aData)
|
||||
{
|
||||
if (mTabChildGlobal) {
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> kungFuDeathGrip(GetGlobal());
|
||||
nsFrameScriptCx cx(static_cast<nsIWebBrowserChrome*>(this), this);
|
||||
StructuredCloneData cloneData = UnpackClonedMessageDataForChild(aData);
|
||||
nsRefPtr<nsFrameMessageManager> mm =
|
||||
|
Loading…
Reference in New Issue
Block a user