From 8a0e2dabbe7fa7367dd258b096be1a6a0822999f Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 14 Feb 2019 22:43:19 +0000 Subject: [PATCH] Bug 1527905. Switch from zone-per-tab to zone-per-toplevel-load. r=mccr8 The main reason for this change is that we don't really want to share compartments across same-origin navigations in the same tab (because that will tend to keep the oldest global involved alive, due to CCWs and XPCWrappedNatives allocated in that global). We could somehow flag compartments as not sharable when we navigate, but it's simpler to just switch zones, since we restrict our search of shareable compartments to a single zone. A side benefit is that this way the lifetime of objects in a single zone is more likely to be similar. Differential Revision: https://phabricator.services.mozilla.com/D19797 --HG-- extra : moz-landing-system : lando --- dom/base/nsGlobalWindowOuter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 36b628700b75..f9ad6142bc01 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -1796,6 +1796,12 @@ static JS::RealmCreationOptions& SelectZone( if (aNewInner->GetOuterWindow()) { nsGlobalWindowOuter* top = aNewInner->GetTopInternal(); + if (top == aNewInner->GetOuterWindow()) { + // We're a toplevel load. Use a new zone. This way, when we do + // zone-based compartment sharing we won't share compartments + // across navigations. + return aOptions.setNewCompartmentAndZone(); + } // If we have a top-level window, use its zone. if (top && top->GetGlobalJSObject()) {