Index: test/cctest/test-strings.cc |
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc |
index d7b51f8274cbaf35058f14ad7ebb38ac2866d1fb..ff3b7bddaa094edf0e5b68ad15a420378838b74f 100644 |
--- a/test/cctest/test-strings.cc |
+++ b/test/cctest/test-strings.cc |
@@ -1195,6 +1195,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; |