1 #include "js/ErrorInterceptor.h"
2 #include "jsapi-tests/tests.h"
6 // An interceptor that triggers GC:
7 struct ErrorInterceptorWithGC
: JSErrorInterceptor
{
8 void interceptError(JSContext
* cx
, JS::HandleValue val
) override
{
9 JS::PrepareForFullGC(cx
);
10 JS::NonIncrementalGC(cx
, JS::GCOptions::Shrink
, JS::GCReason::DEBUG_GC
);
16 BEGIN_TEST(testErrorInterceptorGC
) {
17 JSErrorInterceptor
* original
= JS_GetErrorInterceptorCallback(cx
->runtime());
19 ErrorInterceptorWithGC interceptor
;
20 JS_SetErrorInterceptorCallback(cx
->runtime(), &interceptor
);
22 CHECK(!execDontReport("0 = 0;", __FILE__
, __LINE__
));
24 CHECK(JS_IsExceptionPending(cx
));
25 JS_ClearPendingException(cx
);
27 // Restore the original error interceptor.
28 JS_SetErrorInterceptorCallback(cx
->runtime(), original
);
32 END_TEST(testErrorInterceptorGC
)