Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/JsValue.cpp

Issue 5691839784943616: Change the way persistent handles are desctructed. Add tests. (Closed)
Patch Set: Created July 10, 2014, 11:44 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/AdblockPlus/V8ValueHolder.h ('K') | « include/AdblockPlus/V8ValueHolder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
+}
« include/AdblockPlus/V8ValueHolder.h ('K') | « include/AdblockPlus/V8ValueHolder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld