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

MozReview-Commit-ID: ADqVqF2XraG

--HG--
extra : rebase_source : ea5df06eb9162f9f8c5816f49fb44d9f41947126
This commit is contained in:
Kris Maglione 2017-04-15 14:23:58 -07:00
Родитель 019432d333
Коммит 602cb201f5
2 изменённых файлов: 24 добавлений и 2 удалений

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

@ -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);

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

@ -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)
{