Index: test/cctest/test-strings.cc |
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc |
index 80cbd7a62e9b2d660b72ae1432d7133a4191ed08..11e12e5f2295d19971be3e3e476bd6c7a6a7775f 100644 |
--- a/test/cctest/test-strings.cc |
+++ b/test/cctest/test-strings.cc |
@@ -1194,6 +1194,31 @@ class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { |
i::Vector<const char> data_; |
}; |
+TEST(InternalizeExternal) { |
+ i::Isolate* isolate = CcTest::i_isolate(); |
+ Factory* factory = isolate->factory(); |
+ // This won't leak; the external string mechanism will call Dispose() on it. |
+ OneByteVectorResource* resource = |
+ new OneByteVectorResource(i::Vector<const char>("prop", 4)); |
+ { |
+ v8::HandleScope scope(CcTest::isolate()); |
+ v8::Local<v8::String> ext_string = |
+ v8::String::NewExternalOneByte(CcTest::isolate(), resource) |
+ .ToLocalChecked(); |
+ Handle<String> string = v8::Utils::OpenHandle(*ext_string); |
+ CHECK(string->IsExternalString()); |
+ CHECK(!string->IsInternalizedString()); |
+ CHECK(isolate->heap()->InNewSpace(*string)); |
+ factory->InternalizeName(string); |
+ CHECK(string->IsThinString()); |
+ CcTest::CollectGarbage(i::NEW_SPACE); |
+ CcTest::CollectGarbage(i::NEW_SPACE); |
+ CHECK(string->IsInternalizedString()); |
+ CHECK(!isolate->heap()->InNewSpace(*string)); |
+ } |
+ CcTest::CollectGarbage(i::OLD_SPACE); |
+ CcTest::CollectGarbage(i::OLD_SPACE); |
+} |
TEST(SliceFromExternal) { |
FLAG_string_slices = true; |