From b0e22ea0eac27f2d55347500998adf5a67437c9d Mon Sep 17 00:00:00 2001 From: Gabor Krizsanits Date: Thu, 5 Nov 2015 12:05:56 +0100 Subject: [PATCH] Bug 1196975 - part4: waiveInterposition. r=billm --- js/xpconnect/src/Sandbox.cpp | 2 ++ js/xpconnect/src/XPCJSRuntime.cpp | 1 + js/xpconnect/src/XPCWrappedNativeScope.cpp | 6 ++++-- js/xpconnect/src/xpcprivate.h | 7 +++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index a8db444c51e4..1800edaea8f4 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -1025,6 +1025,7 @@ xpc::CreateSandboxObject(JSContext* cx, MutableHandleValue vp, nsISupports* prin priv->allowWaivers = options.allowWaivers; priv->writeToGlobalPrototype = options.writeToGlobalPrototype; priv->isWebExtensionContentScript = options.isWebExtensionContentScript; + priv->waiveInterposition = options.waiveInterposition; // Set up the wantXrays flag, which indicates whether xrays are desired even // for same-origin access. @@ -1491,6 +1492,7 @@ SandboxOptions::Parse() ParseBoolean("wantComponents", &wantComponents) && ParseBoolean("wantExportHelpers", &wantExportHelpers) && ParseBoolean("isWebExtensionContentScript", &isWebExtensionContentScript) && + ParseBoolean("waiveInterposition", &waiveInterposition) && ParseString("sandboxName", sandboxName) && ParseObject("sameZoneAs", &sameZoneAs) && ParseBoolean("freshZone", &freshZone) && diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 71c412786415..8e21cd8c8cf2 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -194,6 +194,7 @@ CompartmentPrivate::CompartmentPrivate(JSCompartment* c) , writeToGlobalPrototype(false) , skipWriteToGlobalPrototype(false) , isWebExtensionContentScript(false) + , waiveInterposition(false) , universalXPConnectEnabled(false) , forcePermissiveCOWs(false) , scriptability(c) diff --git a/js/xpconnect/src/XPCWrappedNativeScope.cpp b/js/xpconnect/src/XPCWrappedNativeScope.cpp index 81c82319ab15..0bf5f1c92b6a 100644 --- a/js/xpconnect/src/XPCWrappedNativeScope.cpp +++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp @@ -139,9 +139,11 @@ XPCWrappedNativeScope::XPCWrappedNativeScope(JSContext* cx, JSAddonId* addonId = JS::AddonIdOfObject(aGlobal); if (gInterpositionMap) { bool isSystem = nsContentUtils::IsSystemPrincipal(principal); - if (InterpositionMap::Ptr p = gInterpositionMap->lookup(addonId)) { + bool waiveInterposition = priv->waiveInterposition; + InterpositionMap::Ptr interposition = gInterpositionMap->lookup(addonId); + if (!waiveInterposition && interposition) { MOZ_RELEASE_ASSERT(isSystem); - mInterposition = p->value(); + mInterposition = interposition->value(); } // We also want multiprocessCompatible add-ons to have a default interposition. if (!mInterposition && addonId && isSystem) { diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index be6ecf408244..88d6012c36bc 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -3475,6 +3475,7 @@ public: , wantComponents(true) , wantExportHelpers(false) , isWebExtensionContentScript(false) + , waiveInterposition(false) , proto(cx) , addonId(cx) , writeToGlobalPrototype(false) @@ -3492,6 +3493,7 @@ public: bool wantComponents; bool wantExportHelpers; bool isWebExtensionContentScript; + bool waiveInterposition; JS::RootedObject proto; nsCString sandboxName; JS::RootedString addonId; @@ -3732,6 +3734,11 @@ public: // various bits of special compatibility behavior. bool isWebExtensionContentScript; + // Even if an add-on needs interposition, it does not necessary need it + // for every scope. If this flag is set we waive interposition for this + // scope. + bool waiveInterposition; + // This is only ever set during mochitest runs when enablePrivilege is called. // It's intended as a temporary stopgap measure until we can finish ripping out // enablePrivilege. Once set, this value is never unset (i.e., it doesn't follow