зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1328423 - Add AutoAssertNoContentJS assertion (r=sfink)
MozReview-Commit-ID: KY1JwysGzno
This commit is contained in:
Родитель
9ec8074497
Коммит
abe6f421eb
|
@ -1439,3 +1439,15 @@ js::detail::IsWindowSlow(JSObject* obj)
|
|||
{
|
||||
return obj->as<GlobalObject>().maybeWindowProxy();
|
||||
}
|
||||
|
||||
AutoAssertNoContentJS::AutoAssertNoContentJS(JSContext* cx)
|
||||
: context_(cx),
|
||||
prevAllowContentJS_(cx->runtime()->allowContentJS_)
|
||||
{
|
||||
cx->runtime()->allowContentJS_ = false;
|
||||
}
|
||||
|
||||
AutoAssertNoContentJS::~AutoAssertNoContentJS()
|
||||
{
|
||||
context_->runtime()->allowContentJS_ = prevAllowContentJS_;
|
||||
}
|
||||
|
|
|
@ -2865,6 +2865,17 @@ ToWindowIfWindowProxy(JSObject* obj);
|
|||
extern bool
|
||||
AddPluralRulesConstructor(JSContext* cx, JS::Handle<JSObject*> intl);
|
||||
|
||||
class MOZ_STACK_CLASS JS_FRIEND_API(AutoAssertNoContentJS)
|
||||
{
|
||||
public:
|
||||
explicit AutoAssertNoContentJS(JSContext* cx);
|
||||
~AutoAssertNoContentJS();
|
||||
|
||||
private:
|
||||
JSContext* context_;
|
||||
bool prevAllowContentJS_;
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
class NativeProfiler
|
||||
|
|
|
@ -364,6 +364,9 @@ js::RunScript(JSContext* cx, RunState& state)
|
|||
// Since any script can conceivably GC, make sure it's safe to do so.
|
||||
cx->runtime()->gc.verifyIsSafeToGC();
|
||||
|
||||
MOZ_DIAGNOSTIC_ASSERT(cx->compartment()->isSystem() ||
|
||||
cx->runtime()->allowContentJS());
|
||||
|
||||
if (!Debugger::checkNoExecute(cx, state.script()))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -222,6 +222,7 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
|
|||
keepAtoms_(0),
|
||||
trustedPrincipals_(nullptr),
|
||||
beingDestroyed_(false),
|
||||
allowContentJS_(true),
|
||||
atoms_(nullptr),
|
||||
atomsCompartment_(nullptr),
|
||||
staticStrings(nullptr),
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace js {
|
|||
|
||||
class PerThreadData;
|
||||
class ExclusiveContext;
|
||||
class AutoAssertNoContentJS;
|
||||
class AutoKeepAtoms;
|
||||
class EnterDebuggeeNoExecute;
|
||||
#ifdef JS_TRACE_LOGGING
|
||||
|
@ -1042,6 +1043,15 @@ struct JSRuntime : public JS::shadow::Runtime,
|
|||
return beingDestroyed_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool allowContentJS_;
|
||||
public:
|
||||
bool allowContentJS() const {
|
||||
return allowContentJS_;
|
||||
}
|
||||
|
||||
friend class js::AutoAssertNoContentJS;
|
||||
|
||||
private:
|
||||
// Set of all atoms other than those in permanentAtoms and staticStrings.
|
||||
// Reading or writing this set requires the calling thread to have an
|
||||
|
|
Загрузка…
Ссылка в новой задаче