| Index: test/JsEngine.cpp |
| diff --git a/test/JsEngine.cpp b/test/JsEngine.cpp |
| index b26c794ffabb4a2a6ec2c19fe0adfceffed30c21..b45c34bedea8b35bb22fcb065252ccc600dfa0b1 100644 |
| --- a/test/JsEngine.cpp |
| +++ b/test/JsEngine.cpp |
| @@ -188,3 +188,27 @@ TEST(NewJsEngineTest, GlobalPropertyTest) |
| ASSERT_EQ(foo.AsString(), "bar"); |
| } |
| +TEST(NewJsEngineTest, MemoryLeak_NoCircularReferences) |
| +{ |
| + std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine; |
| + { |
| + weakJsEngine = AdblockPlus::JsEngine::New(); |
| + } |
| + EXPECT_FALSE(weakJsEngine.lock()); |
| +} |
| + |
| +#if UINTPTR_MAX == UINT32_MAX // detection of 32-bit platform |
|
sergei
2017/05/24 16:22:32
Although it might seem hacky, on practice it turne
hub
2017/05/24 16:31:40
We could do something like
#if UINTPTR_MAX == UI
sergei
2017/05/24 17:05:51
Since in this case it will still run, so not disab
hub
2017/05/24 18:18:07
According to this, the test will be disabled (buil
sergei
2017/05/26 10:56:43
That's a cool feature of gtest I was not aware of.
|
| +TEST(NewJsEngineTest, MemoryLeak_NoLeak) |
| +{ |
| + static_assert(sizeof(intptr_t) == 4, "It should be 32bit platform"); |
| + // v8::Isolate by default requires 32MB (depends on platform), so if there is |
| + // a memory leak than we will run out of memory on 32 bit platform because it |
| + // will allocate 32000 MB which is less than 2GB where it reaches out of |
| + // memory. Even on android where it allocates initially 16MB, the test still |
| + // makes sense. |
| + for (int i = 0; i < 1000; ++i) |
| + { |
| + AdblockPlus::JsEngine::New(); |
| + } |
| +} |
| +#endif |