diff options
Diffstat (limited to 'js/public/Context.h')
-rw-r--r-- | js/public/Context.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/js/public/Context.h b/js/public/Context.h index 13a18e3e05..b7f9921042 100644 --- a/js/public/Context.h +++ b/js/public/Context.h @@ -102,6 +102,25 @@ using EnsureCanAddPrivateElementOp = bool (*)(JSContext* cx, HandleValue val); JS_PUBLIC_API void SetHostEnsureCanAddPrivateElementHook( JSContext* cx, EnsureCanAddPrivateElementOp op); +/** + * Transition the cx to a mode where failures that would normally cause a false + * return value will instead crash with a diagnostic assertion. + * + * Return value: the former brittle mode setting. + */ +JS_PUBLIC_API bool SetBrittleMode(JSContext* cx, bool setting); + +class AutoBrittleMode { + bool wasBrittle; + JSContext* cx; + + public: + explicit AutoBrittleMode(JSContext* cx) : cx(cx) { + wasBrittle = SetBrittleMode(cx, true); + } + ~AutoBrittleMode() { MOZ_ALWAYS_TRUE(SetBrittleMode(cx, wasBrittle)); } +}; + } /* namespace JS */ #endif // js_Context_h |