Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / js / src / jsapi-tests / testErrorInterceptorGC.cpp
blob67dac2f2dd216e2f071081c4a01ba73d1d8d3114
1 #include "js/ErrorInterceptor.h"
2 #include "jsapi-tests/tests.h"
4 namespace {
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);
14 } // namespace
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);
30 return true;
32 END_TEST(testErrorInterceptorGC)