| Index: test/JsEngine.cpp |
| diff --git a/test/JsEngine.cpp b/test/JsEngine.cpp |
| index b26c794ffabb4a2a6ec2c19fe0adfceffed30c21..3a115808c3f230362b1941cbccc25fe6bd86a8e9 100644 |
| --- a/test/JsEngine.cpp |
| +++ b/test/JsEngine.cpp |
| @@ -188,3 +188,25 @@ 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()); |
| +} |
| + |
| +TEST(NewJsEngineTest, MemoryLeak_NoLeak) |
| +{ |
| + // 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. |
|
hub
2017/05/19 19:20:21
I am not convinced by this test. We run mostly on
sergei
2017/05/22 08:08:55
On 64 bit platform it will take too long to try to
|
| + int i = 1000; |
| + while (i-->0) |
|
hub
2017/05/19 19:20:21
Shouldn't this be written
while (i-- > 0)
?
Al
sergei
2017/05/22 08:08:55
Done.
|
| + { |
| + AdblockPlus::JsEngine::New(); |
| + } |
| +} |