Index: test/JsValue.cpp |
=================================================================== |
--- a/test/JsValue.cpp |
+++ b/test/JsValue.cpp |
@@ -16,7 +16,7 @@ |
*/ |
#include "BaseJsTest.h" |
- |
+#include "v8-profiler.h" |
namespace |
{ |
class JsValueTest : public BaseJsTest |
@@ -24,6 +24,7 @@ |
}; |
} |
+ |
TEST_F(JsValueTest, UndefinedValue) |
{ |
AdblockPlus::JsValuePtr value = jsEngine->Evaluate("undefined"); |
@@ -217,3 +218,52 @@ |
ASSERT_EQ("", value->AsString()); |
ASSERT_EQ(0, value->AsInt()); |
} |
+ |
+TEST_F(JsValueTest, PersistentWeakHandleDisposalComplex) |
+{ |
+ // Force GC |
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(1000000000); |
+ while (!v8::V8::IdleNotification()) {}; |
+ _sleep(500); |
+ |
+ v8::HeapProfiler heapProfiler; |
+ int numberOfHandlesBefore = 0; |
+ |
+ // Create and destroy persistent handle for an object |
+ { |
+ numberOfHandlesBefore = heapProfiler.GetPersistentHandleCount(); |
+ AdblockPlus::JsValuePtr value = jsEngine->NewObject(); |
+ } |
+ |
+ // Force GC |
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(1000000000); |
+ while (!v8::V8::IdleNotification()) {}; |
+ _sleep(500); |
+ |
+ ASSERT_EQ(numberOfHandlesBefore, heapProfiler.GetPersistentHandleCount()); |
+} |
+ |
+TEST_F(JsValueTest, PersistentWeakHandleDisposalPrimitive) |
+{ |
+ // Force GC |
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(1000000000); |
+ while (!v8::V8::IdleNotification()) {}; |
+ _sleep(500); |
+ |
+ v8::HeapProfiler heapProfiler; |
+ int numberOfHandlesBefore = 0; |
+ |
+ // Create and destroy persistent handle for a primitive |
+ { |
+ numberOfHandlesBefore = heapProfiler.GetPersistentHandleCount(); |
+ AdblockPlus::JsValuePtr value = jsEngine->NewValue(false); |
+ AdblockPlus::JsValuePtr value2 = jsEngine->NewValue(0); |
+ } |
+ |
+ // Force GC |
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(1000000000); |
+ while (!v8::V8::IdleNotification()) {}; |
+ _sleep(500); |
+ |
+ ASSERT_EQ(numberOfHandlesBefore, heapProfiler.GetPersistentHandleCount()); |
+} |