Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / js / src / jsapi-tests / testSABAccounting.cpp
blob38607bc0aa179b6128389ca6de5d79676dbf88eb
1 #include "builtin/TestingFunctions.h"
2 #include "js/SharedArrayBuffer.h"
3 #include "jsapi-tests/tests.h"
5 BEGIN_TEST(testSABAccounting) {
6 // Purge what we can
7 JS::PrepareForFullGC(cx);
8 NonIncrementalGC(cx, JS::GCOptions::Shrink, JS::GCReason::API);
10 // Self-hosting and chrome code should not use SABs, or the point of this
11 // predicate is completely lost.
12 CHECK(!JS::ContainsSharedArrayBuffer(cx));
14 JS::RootedObject obj(cx), obj2(cx);
15 CHECK(obj = JS::NewSharedArrayBuffer(cx, 4096));
16 CHECK(JS::ContainsSharedArrayBuffer(cx));
17 CHECK(obj2 = JS::NewSharedArrayBuffer(cx, 4096));
18 CHECK(JS::ContainsSharedArrayBuffer(cx));
20 // Discard those objects again.
21 obj = nullptr;
22 obj2 = nullptr;
23 JS::PrepareForFullGC(cx);
24 NonIncrementalGC(cx, JS::GCOptions::Shrink, JS::GCReason::API);
26 // Should be back to base state.
27 CHECK(!JS::ContainsSharedArrayBuffer(cx));
29 return true;
31 END_TEST(testSABAccounting)