Bug 1092156 - [e10s] Don't use compartment-per-addon if window already associated with add-on (r=bholley)

This commit is contained in:
Bill McCloskey 2014-11-05 17:10:37 -08:00
parent 7cf195d449
commit 37ff17b630
2 changed files with 7 additions and 0 deletions

View File

@ -194,6 +194,7 @@
#include "mozilla/dom/SelectionChangeEvent.h"
#include "mozilla/AddonPathService.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "nsLocation.h"
@ -2264,6 +2265,7 @@ CreateNativeGlobalForInner(JSContext* aCx,
top = aNewInner->GetTop();
}
JS::CompartmentOptions options;
options.setAddonId(MapURIToAddonID(aURI));
if (top) {
if (top->GetGlobalJSObject()) {
options.setSameZoneAs(top->GetGlobalJSObject());

View File

@ -346,6 +346,11 @@ XPCWrappedNativeScope::EnsureAddonScope(JSContext *cx, JSAddonId *addonId)
MOZ_ASSERT(addonId);
MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(GetPrincipal()));
// If the global is already part of the add-on then there's no reason to
// create a new one.
if (AddonIdOfObject(global) == addonId)
return global;
// If we already have an addon scope object, we know what to use.
for (size_t i = 0; i < mAddonScopes.Length(); i++) {
if (JS::AddonIdOfObject(js::UncheckedUnwrap(mAddonScopes[i])) == addonId)