Bug 1514210 part 2 - Use the privileged junk scope's compartment for windows created with the system principal. r=bzbarsky

Depends on D15290

Differential Revision: https://phabricator.services.mozilla.com/D15291

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2018-12-28 11:25:48 +00:00
Родитель 9f6f1773d0
Коммит 3e7306f81a
1 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -1549,7 +1549,13 @@ static bool InitializeLegacyNetscapeObject(JSContext* aCx,
}
static JS::RealmCreationOptions& SelectZone(
nsGlobalWindowInner* aNewInner, JS::RealmCreationOptions& aOptions) {
nsIPrincipal* aPrincipal, nsGlobalWindowInner* aNewInner,
JS::RealmCreationOptions& aOptions) {
// Use the shared system compartment for chrome windows.
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
return aOptions.setExistingCompartment(xpc::PrivilegedJunkScope());
}
if (aNewInner->GetOuterWindow()) {
nsGlobalWindowOuter* top = aNewInner->GetTopInternal();
@ -1584,7 +1590,7 @@ static nsresult CreateNativeGlobalForInner(JSContext* aCx,
JS::RealmOptions options;
SelectZone(aNewInner, options.creationOptions());
SelectZone(aPrincipal, aNewInner, options.creationOptions());
options.creationOptions().setSecureContext(aIsSecureContext);