[test] Fix cctest/test-strings/Regress1402187 for non sandbox builds

Increase length of strings in the test to ensure they are cachable
external strings even when the sandbox is disabled.

Change-Id: I1228e1abb1d88c0bb70edaeb718e1bf2f4cdd53d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4127228
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Patrick Thier <pthier@chromium.org>
Commit-Queue: Patrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85081}
This commit is contained in:
pthier 2023-01-03 17:36:38 +01:00 committed by V8 LUCI CQ
parent 8a565c39d0
commit 8d54971115

View File

@ -1398,16 +1398,17 @@ TEST(Regress1402187) {
i::Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
// This won't leak; the external string mechanism will call Dispose() on it.
const char ext_string_content[] = "prop-1234567";
OneByteVectorResource* resource = new OneByteVectorResource(
v8::base::Vector<const char>(ext_string_content, 12));
const char ext_string_content[] = "prop-1234567890asdf";
OneByteVectorResource* resource =
new OneByteVectorResource(v8::base::Vector<const char>(
ext_string_content, strlen(ext_string_content)));
const uint32_t fake_hash =
String::CreateHashFieldValue(4711, String::HashFieldType::kHash);
{
v8::HandleScope scope(CcTest::isolate());
// Internalize a string with the same hash to ensure collision.
Handle<String> intern = isolate->factory()->NewStringFromAsciiChecked(
"internalized", AllocationType::kOld);
"internalized1234567", AllocationType::kOld);
intern->set_raw_hash_field(fake_hash);
factory->InternalizeName(intern);
CHECK(intern->IsInternalizedString());
@ -1418,6 +1419,7 @@ TEST(Regress1402187) {
Handle<String> string = v8::Utils::OpenHandle(*ext_string);
string->set_raw_hash_field(fake_hash);
CHECK(string->IsExternalString());
CHECK(!StringShape(*string).IsUncachedExternal());
CHECK(!string->IsInternalizedString());
CHECK(!String::Equals(isolate, string, intern));
CHECK_EQ(string->hash(), intern->hash());