Bug 1529684 - Part 6: Store a mIsInProcess flag to preserve WindowProxy behaviour, r=farre
Currently when we have an in-process WindowProxy object, we will attempt to either use the cached mWindowProxy value, or fetch the nsGlobalWindowOuter object from through the nsDocShell. Unfortunately, when the BrowsingContext is detached, we will fail to get the nsGlobalWindowOuter object. This happens to be OK for our test cases, as the cached mWindowProxy value doesn't have the chance to go away, but isn't acceptable long-term. These patches exascerbated that issue by causing the nsDocShell pointer itself to be cleared when it is destroyed, which caused the Remote WindowProxy logic to be triggered. To deal with that case, this patch adds a new mIsInProcess flag to continue to act like the old code-path. In the future, we will need to also handle ensuring that the nsGlobalWindowOuter lives for long enough, however that is not being done in this patch in order to land it sooner rather than later. Depends on D22763 Differential Revision: https://phabricator.services.mozilla.com/D22764
This commit is contained in:
@@ -161,6 +161,7 @@ BrowsingContext::BrowsingContext(BrowsingContext* aParent,
|
||||
mType(aType),
|
||||
mBrowsingContextId(aBrowsingContextId),
|
||||
mParent(aParent),
|
||||
mIsInProcess(false),
|
||||
mOpener(aOpener),
|
||||
mIsActivatedByUserGesture(false) {
|
||||
mCrossOriginPolicy = nsILoadInfo::CROSS_ORIGIN_POLICY_NULL;
|
||||
@@ -184,6 +185,7 @@ void BrowsingContext::SetDocShell(nsIDocShell* aDocShell) {
|
||||
// process to the parent & do other validation here.
|
||||
MOZ_RELEASE_ASSERT(nsDocShell::Cast(aDocShell)->GetBrowsingContext() == this);
|
||||
mDocShell = aDocShell;
|
||||
mIsInProcess = true;
|
||||
}
|
||||
|
||||
void BrowsingContext::Attach(bool aFromIPC) {
|
||||
@@ -241,6 +243,11 @@ void BrowsingContext::Detach(bool aFromIPC) {
|
||||
// BrowsingContext - clear our now-dead nsDocShell reference.
|
||||
mDocShell = nullptr;
|
||||
|
||||
// As our nsDocShell is going away, this should implicitly mark us as closed.
|
||||
// We directly set our member, rather than using a transaction as we're going
|
||||
// to send a `Detach` message to other processes either way.
|
||||
mClosed = true;
|
||||
|
||||
if (!aFromIPC && XRE_IsContentProcess()) {
|
||||
auto cc = ContentChild::GetSingleton();
|
||||
MOZ_DIAGNOSTIC_ASSERT(cc);
|
||||
|
||||
Reference in New Issue
Block a user