OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 TEST(NewJsEngineTest, GlobalPropertyTest) | 128 TEST(NewJsEngineTest, GlobalPropertyTest) |
129 { | 129 { |
130 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); | 130 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); |
131 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar")); | 131 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar")); |
132 AdblockPlus::JsValuePtr foo = jsEngine->Evaluate("foo"); | 132 AdblockPlus::JsValuePtr foo = jsEngine->Evaluate("foo"); |
133 ASSERT_TRUE(foo->IsString()); | 133 ASSERT_TRUE(foo->IsString()); |
134 ASSERT_EQ(foo->AsString(), "bar"); | 134 ASSERT_EQ(foo->AsString(), "bar"); |
135 } | 135 } |
136 | 136 |
| 137 TEST(NewJsEngineTest, MemoryLeak_NoCircularReferences) |
| 138 { |
| 139 std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine; |
| 140 { |
| 141 weakJsEngine = AdblockPlus::JsEngine::New(); |
| 142 } |
| 143 EXPECT_FALSE(weakJsEngine.lock()); |
| 144 } |
| 145 |
| 146 TEST(NewJsEngineTest, MemoryLeak_NoLeak) |
| 147 { |
| 148 // v8::Isolate by default requires 32MB, so if there is a memory leak than |
| 149 // we will run out of memory on 32 bit platform because it will allocate |
| 150 // 32000 MB which is less than 2GB where it reaches out of memory. |
| 151 int i = 1000; |
| 152 while (i-->0) |
| 153 { |
| 154 AdblockPlus::JsEngine::New(); |
| 155 } |
| 156 } |
OLD | NEW |