summaryrefslogtreecommitdiffstats
path: root/tests/auto/v8/v8test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/v8/v8test.cpp')
-rw-r--r--tests/auto/v8/v8test.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/v8/v8test.cpp b/tests/auto/v8/v8test.cpp
index 0b299ed23c..b2734af8c3 100644
--- a/tests/auto/v8/v8test.cpp
+++ b/tests/auto/v8/v8test.cpp
@@ -54,6 +54,59 @@ using namespace v8;
} \
}
+struct MyStringResource : public String::ExternalAsciiStringResource
+{
+ static bool wasDestroyed;
+ virtual ~MyStringResource() { wasDestroyed = true; }
+ virtual const char* data() const { return "v8test"; }
+ virtual size_t length() const { return 6; }
+};
+bool MyStringResource::wasDestroyed = false;
+
+struct MyResource : public Object::ExternalResource
+{
+ static bool wasDestroyed;
+ virtual ~MyResource() { wasDestroyed = true; }
+};
+bool MyResource::wasDestroyed = false;
+
+bool v8test_externalteardown()
+{
+ BEGINTEST();
+
+ Isolate *isolate = v8::Isolate::New();
+ isolate->Enter();
+
+ {
+ HandleScope handle_scope;
+ Persistent<Context> context = Context::New();
+ Context::Scope context_scope(context);
+
+ Local<String> str = String::NewExternal(new MyStringResource);
+
+ Local<FunctionTemplate> ft = FunctionTemplate::New();
+ ft->InstanceTemplate()->SetHasExternalResource(true);
+
+ Local<Object> obj = ft->GetFunction()->NewInstance();
+ obj->SetExternalResource(new MyResource);
+
+ context.Dispose();
+ }
+
+ // while (!v8::V8::IdleNotification()) ;
+ isolate->Exit();
+ isolate->Dispose();
+
+ // ExternalString resources aren't guaranteed to be freed by v8 at this
+ // point. Uncommenting the IdleNotification() line above helps.
+// VERIFY(MyStringResource::wasDestroyed);
+
+ VERIFY(MyResource::wasDestroyed);
+
+cleanup:
+
+ ENDTEST();
+}
bool v8test_eval()
{