Bug 1356826: Part 4 - Add Cu.isInAutomation and Cu.crashIfNotInAutomation helpers. r=bholley

MozReview-Commit-ID: ADqVqF2XraG

--HG--
extra : rebase_source : 5b4ff1ceb7f3123f585559a954e59291c91e5554
extra : source : c46fed6e4f6a928df2b06fca6b3f004fd4bb0cc7
This commit is contained in:
Kris Maglione 2017-04-15 14:23:58 -07:00
parent f273a3c370
commit a4e4191399
2 changed files with 24 additions and 2 deletions

View File

@ -529,6 +529,12 @@ interface nsIXPCComponents_Utils : nsISupports
[implicit_jscontext]
attribute boolean ion;
// Returns true if we're running in automation and certain security
// restrictions can be eased.
readonly attribute boolean isInAutomation;
void crashIfNotInAutomation();
[implicit_jscontext]
void setGCZeal(in long zeal);

View File

@ -2916,7 +2916,7 @@ nsXPCComponents_Utils::SetWantXrays(HandleValue vscope, JSContext* cx)
NS_IMETHODIMP
nsXPCComponents_Utils::ForcePermissiveCOWs(JSContext* cx)
{
CrashIfNotInAutomation();
xpc::CrashIfNotInAutomation();
CompartmentPrivate::Get(CurrentGlobalOrNull(cx))->forcePermissiveCOWs = true;
return NS_OK;
}
@ -2927,7 +2927,7 @@ nsXPCComponents_Utils::ForcePrivilegedComponentsForScope(HandleValue vscope,
{
if (!vscope.isObject())
return NS_ERROR_INVALID_ARG;
CrashIfNotInAutomation();
xpc::CrashIfNotInAutomation();
JSObject* scopeObj = js::UncheckedUnwrap(&vscope.toObject());
XPCWrappedNativeScope* scope = ObjectScope(scopeObj);
scope->ForcePrivilegedComponents();
@ -3012,6 +3012,22 @@ nsXPCComponents_Utils::SetGCZeal(int32_t aValue, JSContext* cx)
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::GetIsInAutomation(bool* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = xpc::IsInAutomation();
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::CrashIfNotInAutomation()
{
xpc::CrashIfNotInAutomation();
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::NukeSandbox(HandleValue obj, JSContext* cx)
{